MATLAB Creating Graphical User Interfaces

(Barry) #1

14 Examples of UIs Created Programmatically


List Master looks for the listmaster_icons.mat MAT-file when creating a new UI
(from File > New menu). The files senators110cong.mat and senators110th.txt
are not required to create or operate a UI; you can use either one to populate a new List
Master UI with data using File > import list.

To obtain copies of the files for this example, follow these steps:

1 Set your current folder to one in which you have write access.
2 Copy the example files and open listmaster.m in the Editor by executing these
commands:

copyfile(fullfile(docroot,'techdoc','creating_guis','examples',...
'listmaste*.*'),pwd), fileattrib('listmaste*.*','+w'),
copyfile(fullfile(docroot,'techdoc','creating_guis','examples',...
'senators110*.*'),pwd),fileattrib('senators110*.*','+w'),
edit listmaster.m

Use the UI


The UI can create new instances of itself with File > New at any time, and any number
of these instances can be open at the same time.

Start List Master

To start using List Master, make sure listmaster.m is on your path, and run the main
function.

1 >> listmaster

ans =
1
The function opens a blank UI with the title ListMaster and a File menu and
returns its figure handle.
2 Select New from the File menu to start a new list.

The program presents a dialog box (using inputdlg).
3 Type a name for the list you want to create and click OK.

The New menu item's callback, lmnew, prompts the user for a list name and creates the
UI window with all the UI components.
Free download pdf