Creating Graphical User Interfaces - The MathWorks - #45

/ 520


catalogue search
P. 01
P. 02
P. 03
P. 04
P. 05
P. 06
P. 07
P. 08
P. 09
P. 10
P. 11
P. 12
P. 13
P. 14
P. 15
P. 16
P. 17
P. 18
P. 19
P. 20
P. 21
P. 22
P. 23
P. 24
P. 25
P. 26
P. 27
P. 28
P. 29
P. 30
P. 31
P. 32
P. 33
P. 34
P. 35
P. 36
P. 37
P. 38
P. 39
P. 40
P. 41
P. 42
P. 43
P. 44
P. 45
P. 46
P. 47
P. 48
P. 49
P. 50


See other catalogues for The MathWorks

Text version of the page
Programming a Simple GUI
Programming a Simple GUI
In this section...
"AddingCodetothe M-file"onpage2-21 "Generating Data to Plot" on page 2-21 "Programming the Pop-Up Menu" on page 2-24 "Programming the Push Buttons" on page 2-25
Adding Code to the M-file
When you saved your GUI in the previous topic, "Saving the GUI Layout" on page 2-19, GUIDE created two files: a FIG-file simple_gui.fig that contains the GUI layout, and an M-file simple_gui.m that contains the code that controls the GUI. But the GUI didn't do anything because there was no code in the M-file to make it work. This topic shows you how to add code to the M-file to make it work. There are three steps:
Generating Data to Plot
This topic shows you how to generate the data to be plotted when the user clicks a button. This data is generated in the opening function. The opening function is the first callback in every GUIDE-generated GUI M-file. You can use it to perform tasks that need to be done before the user has access
to the GUI.
In this example, you add code that creates three data sets to the opening function. The code uses the MATLAB® functions peaks, membrane,and sine.
1 Display the opening function in the M-file editor. If the GUI M-file, simple_gui.m, is not already open in your editor, open it by selecting M-file Editor from the View menu. In the editor, click the function icon I on the toolbar, then select simple_gui_OpeningFcn in the pop-up menu that displays.
2-21

pageCatalog pdf di En 2012-06-22-01