Blinkdagger proudly presents Pimp My Gui, a series that will provide our readers with tips and tricks on how they can make their GUIs beautiful on both the inside and outside.

Matlab Logo In the previous post, we talked about using a custom menu bar to retain functionality while clearing up space on a GUI. In this post, we’re going to discuss how to implement a “help” feature for your GUI. The help feature should be informative and simple so that any person can learn how to use the GUI quickly. The help feature should offer other useful information such as the version number, author, and other tidbits of information.

In the last post, we ended up with this GUI, but we never did anything for the “help” portion of the GUI:

Zane's GUI

Help

Contents

How to use this GUI: Quick User Guide

A simple but effective way to implement a help screen is to create another standalone GUI. For example, I created a standalone GUI that consists of only a static text component. I populated the text field with some helpful information regarding the GUI and detailed a succinct user’s guide.

Help GUI Skeleton

When the GUI is called by the user, the user will see the following:

Help GUI

Of course, you can add more tidbits and information depending on the actual GUI. You might also want to add a FAQ section here if you feel your GUI needs some extra explanation. If you can’t fit all the information into one screen, you can also utilize pushbuttons that will change the static text when the button is pressed.

About this GUI

I also created a stand alone GUI for the “About”. This part should inform the user about what version of MATLAB the GUI was designed on, date of creation, name of author, some contact information, and the version number of the GUI.

Help GUI Stand Alone

When the GUI is called by the user, the user will see the following:

About GUI

Putting it all together

All we have to do now is to call the appropriate help GUI in the appropriate callback, pretty straightforward stuff. When the menu items for the help menu was created, MATLAB automatically created callbacks for each menu item.

Help

the callback for the “How to use this GUI” menu item is:

function helpGUI_Callback(hObject, eventdata, handles)
 
%this is the name of the help GUI that contains the help information
helpGUI_description

the callback for the “About this GUI” menu item is

function aboutGui_Callback(hObject, eventdata, handles)
 
%this command calls the GUI that has the "about" information
aboutGUI_description

Addpath

I have found that the addpath command within MATLAB can really help you keep your files organized. If your GUI utilizes other m-files or images, it can be advantageous to store them in appropriate subdirectories.

you can store them in a separate directory and simply add the path of that directory. It can get a little crowded in the main directory of your GUI, so its usually a good idea to put all your sub functions and sub GUIs in a lower level folder.

For example, the following image shows how I originally had my m-files organized. The main GUI files are Tutor_Commuter_QQ_05.fig and Tutor_Commuter_QQ_05.m. The rest of the files are used in creating the help.

Add Path 1

In the following image, you can see how I reorganized the files. All the files except the main files are placed in the subfunctions folder.
Add Path 2

Now, all that has to done is to add the path of the subfunctions within the Opening Function of the main GUI.

%the addpath adds the subfunctions folder onto the MATLAB path. m-files
%within this directory will be run as if it were in the same directory as the 
%main GUI itself
 
%the fullfile command combines directory names and parts
 
%pwd is the "present working directory", which in this case will be where
%the main GUI is located
addpath(fullfile(pwd,'subfunctions');

Next Time

It looks like we’ve revamped Zane’s GUI so that it’s obtained a shade of respectability. If you guys have any more ideas on what can be done, we’d love to hear about it. In the near future, we’ll open up the floor and ask for GUIs from our readers! Until next time . . .