MATLAB Creating Graphical User Interfaces

(Barry) #1

14 Examples of UIs Created Programmatically


Program List Master


The List Master UI code file contains 22 functions, organized into five groups, which are
described below.

List Master Main Program

The main function, listmaster, opens a figure window. Then, listmaster calls the
local function, lm_make_file_menu, to create the File menu. The following table
describes the menu items and lists their callbacks.

Menu Item How Used Callback
Open... Opens an existing List Master figure lmopen
New... Creates a List Master by adding controls
to the initial UI or to a new figure if the
existing one already contains a list

lmnew

Import
list...

Loads list data from a workspace cell array lmwsimport

Export
list...

Creates a cell array or text file containing the
current list

lmwsexport,
lmfileexport
Save Saves current List Master and its contents as
a FIG-file

lmsave

Save as... Saves current List Master to a different FIG-
file

lmsaveas

Quit Exits List Master, with option to save first lmquit

After creating a blank UI with a File menu, the listmaster function exits.

The main function sets up the figure as follows:

fh = figure('MenuBar','none', ...
'NumberTitle','off', ...
'Name','ListMaster', ...
'Tag','lmfigtag', ...
'CloseRequestFcn', @lmquit, ...
'Units','pixels', ...
'Position', pos);
Turning off the MenuBar eliminates the default figure window menus, which the
program later replaces with its own File menu. NumberTitle is turned off to eliminate a
figure number in its title bar.
Free download pdf