Week+of+1-28+to+2-3

January 29th and 31st
It's GUI time. It's time for me to comb my way through Chapter 9, the introduction to Graphical User Interfaces. The author opens Chapter 9 by informing the reader that the chapter is largely procedural and is simply a guide through the process of creating a GUI which, in itself, is not terribly difficult. He assures the reader that this should not be intimidating or be seen as complex merely because of its length - he explains that this chapter is supposed to be a thorough way to communicate important core concepts of GUI making to the reader. It turns out that GUIs are saved in two files, one with the suffix '.fig' and the other with an 'm' file. This 'm' file holds a template for GUI programming. This template is shaped by the programmer to fit his wants. Section 9.1 is about the file creation saving. The 'guide' command in MATLAB opens up the Graphical User Interface Development Environment, the platform for creating GUIs. In its pure form, it looks like the following picture: The window for creating GUIs itself is pretty basic - it has a set of buttons on the top for saving and for the editor, and on the left it has a collection of buttons for creating objects in the GUI. I will address each of these creation buttons and briefly explain them. This first button is simply there for switching from creation back to the mouse. This button is called 'select' by MATLAB. The second button, 'pushbutton', is for creating buttons that activates something upon a click. The next button, 'slider', is for creating a dynamic slider bar for number selection. 'radiobutton' creates a button that can change between selected and unselected each time it is clicked. 'checkbox' serves essentially the same purpose as a radio button but with a check rather than a dot. 'edit textbox' creates a text box that allows the user to input string or number information via typing 'static textbox' creates a text box for the display of text (used for labels, displaying results, etc) 'pop-up menu' creates a menu from which one choice can be selected by the user 'listbox' creates a menu much like the pop-up menu, except a list box can be scrolled through and can have multiple items selected 'togglebutton' stays pressed down until unclicked, and assumedly toggles a certain action while pressed down 'table' creates a table for displaying data 'axes' creates a surface on which to display two- or three-dimensional graphics 'panel' creates a mechanism for visually grouping the various other tools 'button group' creates a group of radio buttons, of which only one can be selected at a time 'activeX control' creates a module for activating an ActiveX control the programmer creates, but is extremely dangerous as poor ActiveX programming can crash MATLAB

The book suggested to get familiar with placing and sizing objects, even though it hasn't yet explained how to make them function. So I made a few things and the picture is below. The author then stresses that it is helpful practice to end each GUI file name in "Tool" to avoid confusion further down the road. So, I saved my dumb tool and then MATLAB created a hefty code file which it opened in the editor. The author also explains that the '.fig' file that is saved with the same title as the '.m' code file is not editable by a human and is in binary and can only really be used through the GUIDE window. The author instructs the reader to not worry about the code in the '.m' file at this point, so I went on and executed the program just to play around with the buttons and menus, etc. Below is a snapshot of that.

Section 9.2 is about using buttons in a GUI to cause the program to begin doing an action. The book guides through the process of creating a GUI that displays some text if the user pushes a button. This begins by becoming familiar with the Property Inspector and learning how to manipulate the properties of a GUI element. The Properties inspector shows quite a variety of properties of the button and is interactive for editing them. Below is a picture of my GUI after my first few changes. I highlighted the values that I changed. The changes and effects are pretty self-explanatory since the GUI is displayed as well. Now I saved the GUI and MATLAB has generated the template code and opened it in the editor. I am to focus on the 'winButton Callback' function. Below is what MATLAB gives to me. I then added the line below to display some text when the button is clicked (more specifically, when the button is clicked and then released). This causes the line "You are a winner!" to be displayed in the Command Window every time the button in the GUI is pressed. Below is a video of me clicking the button 3 times to display this functionality. media type="custom" key="22065936" The author concludes section 9.2 by dropping in the suggestion that, as often as possible, you should write other functions and call them up from that 'Callback' function in order to keep things from getting muddy, rather than writing a whole bunch of code in the GUI program that has yet to be compiled because it could mess stuff up. Section 9.3 reverses the communication lines addressed in 9.2 - rather than having the GUI object activate stuff in the program, it discusses how to make the program do stuff to the GUI object. So, the book guides the reader through the creation of a Slider GUI. I began following the book's instructions, and two interesting things I came across were two new types of editing in the Property Inspector. They are pop up windows and are shown below. The one on the left is what comes up when you edit a vector quantity in the Property Inspector. It is a list of each of the quantities that organizes vertically, and each item can be edited individually, and there are buttons on the bottom for adding and deleting elements. The one on the right is what comes up when you edit a string quantity that has spaces, etc and is likely to be much longer than just a standard string name. This is essentially just a simple text box. After editing a few things in the Property Inspector, I came out with the basic GUI form shown below.

As it is time for me to leave QuarkNet, the programming side of this exercise will come next week.