Creating Graphical User Interfaces |
The following examples illustrate various ways to call a GUI named my_gui
with different arguments. All arguments are passed to the opening function in the GUI M-file.
my_gui
with no arguments opens my_gui
.
H = my_gui
returns the handle to my_gui
.
my_gui('Property', Value,...)
, where 'Property'
is a valid figure property, opens my_gui
using the given property-value pair. You can call the GUI with more than one property-value pair.
my_gui('Position', [71.8 44.9 74.8 19.7])
opens the GUI at the specified position, since Position
is a valid figure property. See the reference page for figure
for a list of figure properties.
my_gui('My_function', hObject, eventdata, handles,...)
calls the subfunction My_function
in the GUI M-file with the given input arguments.
my_gui('Key_word', Value,...)
, where 'Key_word'
is any string that is not a valid figure property or the name of a subfunction, creates a new my_gui
, and passes the pair 'Key_word'
, Value
to the opening function in the GUI M-file via varargin
.
my_gui('Temperature', 98.6)
opens the GUI and passes the vector ['Temperature', 98.6]
to the opening function.
See An Address Book Reader for an example that uses this syntax. The example creates a GUI called address_book
. Calling the GUI with the syntax address_book('book', my_contacts)
opens the GUI with the MAT-file my_contacts
, which contains a list of names and addresses you want to display. Note that you can use any string that is not a valid figure property or the name of a callback in place of the string 'book'
. See the reference page for figure
for a list of figure properties.
Callbacks | Managing GUI Data with the Handles Structure |