GUI File Edit View Layout Tools Help 最郾以函哈 t Select Align Objects ox Push But Vertical Push Button O Radio Bu Distribute Push Button olT Edit Text Static Tex Static Te Horizontal Popup Menu 四 a Popup M To learn more about the layout editor, see "Laying Out GUis- The Layout
2 Example: Creating a GUI 2-8 To learn more about the Layout Editor, see “Laying Out GUIs — The Layout Editor” on page 4-2
Programming the gUI Programming the GUI After laying out the gul, the next step is to program it. This section explains how to do so. The section covers Setting properties for the GUI components · Opening the guI M-fle The opening function Sharing data between callbacks Adding code to the opening function Adding code to the callbacks Using the Object Browser to identify callbacks Set Properties for the GUl Components To set the properties of each GUI component, select the Property Inspector from the View menu to display the property Inspector. When you select a component in the Layout Editor, the Property Inspector displays the component's properties If no component is selected, the Property Inspector displays the properties of the GUI figure, as shown in the following figure BProperty Inspector bKeyPressFcn NumberTitle 10.252.586 Name pr。 perty Scroll down the list of properties until you come to Name. In the field next to Name, type Simple GUI, as shown in the following figure. This is the title that is displayed at the top of the gui 2-9
Programming the GUI 2-9 Programming the GUI After laying out the GUI, the next step is to program it. This section explains how to do so. The section covers • Setting properties for the GUI components • Opening the GUI M-file • The opening function • Sharing data between callbacks • Adding code to the opening function • Adding code to the callbacks • Using the Object Browser to identify callbacks Set Properties for the GUI Components To set the properties of each GUI component, select the Property Inspector from the View menu to display the Property Inspector. When you select a component in the Layout Editor, the Property Inspector displays the component’s properties. If no component is selected, the Property Inspector displays the properties of the GUI figure, as shown in the following figure. Name Property Scroll down the list of properties until you come to Name. In the field next to Name, type Simple GUI, as shown in the following figure. This is the title that is displayed at the top of the GUI
Example: Creating a GUI String Property You can set the label in a gui component by its String property. For example, to set the label of the top push button, select the push button in the Layout Editor and then scroll down in the Property Inspector until you come to String In the field to the right of string, change Push Button to Surf, as shown in the following figure I Propert EK uncontrol (pushbutton"Surf Position 156.615.3081321 SidestEp [0.010.1 ag pushbutton Tooltip string UIContextMenu You can view the change by clicking the layout Editor. Similarly, change the String property of the middle push button to Mesh, the bottom push button to Contour and the static Text to Select Data Pop-up Menu Items. To set pop-up menu items, select the popup menu in the Layout Editor. In the Property Inspector, click the icon El next to String. This pens the String property edit box. Delete Popup Menu in the String property edit box, and type peaks, membrane, and sinc on three separate lines, as shown in the following figure 2-10
2 Example: Creating a GUI 2-10 String Property You can set the label in a GUI component by its String property. For example, to set the label of the top push button, select the push button in the Layout Editor and then scroll down in the Property Inspector until you come to String. In the field to the right of String, change Push Button to Surf, as shown in the following figure. You can view the change by clicking the Layout Editor. Similarly, change the String property of the middle push button to Mesh, the bottom push button to Contour, and the Static Text to Select Data. Pop-up Menu Items. To set pop-up menu items, select the popup menu in the Layout Editor. In the Property Inspector, click the icon next to String. This opens the String property edit box. Delete Popup Menu in the String property edit box, and type peaks, membrane, and sinc on three separate lines, as shown in the following figure:
Programming the gUI E Property Inspector 口区 ca uncontrol (peaks) SelectionHighlight 于on 0.010.1 String peaks embrane cancel When you click on the Layout Editor, the gui appears as in the following 2-11
Programming the GUI 2-11 When you click on the Layout Editor, the GUI appears as in the following figure
Example: Creating a GUI Fil Edt View Layout Tools Help 0a回的cB卧以图啥 x Select t Radio Button 区 Checkbox nr Edit Ted Tar Static Text Select D减 rm Slider E! List Bs Popup Menu lback and Tag Properties The Callback property specifies the callback- the function in the gui M-file that gets called when a user activates the component for example, by clicking a push button. When you first add a component to the layout, its Callback property is set to the string % automatic, as shown in the following figure 口x DK uncontrol (push button1"Push Button") BusyAction %automatic vIon When you save or run the Gui, guide converts this string to one that calls a function in the generated M-file GUIDE uses the component's Tag property to 2-12
2 Example: Creating a GUI 2-12 Callback and Tag Properties The Callback property specifies the callback — the function in the GUI M-file that gets called when a user activates the component, for example, by clicking a push button. When you first add a component to the layout, its Callback property is set to the string %automatic, as shown in the following figure. When you save or run the GUI, GUIDE converts this string to one that calls a function in the generated M-file. GUIDE uses the component’s Tag property to