Ken & Mike on the MATLAB Desktop
August 3rd, 2009
More dialogs than you can shake a stick at
I’m going to continue my dialog discussion from two weeks ago with more of the MATLAB dialog gallery. I feel a bit like a car salesman, we’ve got so many dialogs to choose from. I’ve grouped them into two categories: dialogs for messages, and dialogs for setting/getting things.
The first group is the msgbox and it’s specialized variants: warndlg, errordlg, and helpdlg. Msgbox is a basic dialog that presents a message to the user with an “OK” button. The warning, error, and help dialogs are all special cases of msgbox with the icon pre-chosen:
The second group provides common dialogs that are either system, Java, or Handle Graphics based, depending on the dialog and platform. These are dialogs for dealing with files, printing, and picking fonts and colors.
File Picker(s)
uigetfile, uiopen, and uigetdir are all file/folder browsers for selecting a file from the system and returning the result to MATLAB. The uiputfile and uisave are for selecting files for saving as determined by whatever your program wants (uiputfile) or for saving workspace variables (uisave).
Here’s what they look like on Windows and MAC
Setting Fonts and Colors
Sometimes you want to present the chooser with a dialog specialized for selecting a complex data type. We’ve provided two dialogs: one for selecting fonts uisetfont, and one for selecting a color uisetcolor.
I didn’t cover printdlg and printpreview which are dialogs for printing MATLAB figure windows. I recommend checking them out on your own. There’s also a progressbar waitbar:
If all these predefined UI’s aren’t enough for you, check out the MATLAB file exchange. Last week’s pick of the week was STRUCTDLG, a dialog for editing the fields of a struct. This week they’ll highlight another submission in the same vein.
By
Michael Katz
Mike is a developer on the MATLAB Desktop team. When not describing himself in the third person, biking, homebrewing, or rooting for the home team, he's busy trying to make the world a better place for programming.
14:08 UTC |
Posted in MATLAB GUI |
Permalink |
You can follow any responses to this entry through the RSS 2.0 feed.
You can skip to the end and leave a response. Pinging is currently not allowed.
Leave a Reply
|
My suggest you remove the minimize button on the dialogs in the first groups. Message boxes usually don’t have a minimize button.
Petter,
I will forward your suggestion on to the message box developers. Remember thought that these dialogs do not have to be modal.
One of the nice features in msgbox, that I found most users are not aware of, is the fact that msgbox supports Tex markup. This enables messages in a variety/combination of fonts, colors, symbols etc. While documented, it is regrettable that such a useful feature is hidden/implied in the last sentence or two of the msgbox doc page. I would suggest adding a simple example and a screenshot to the doc page, that would immediately show this feature’s importance.
For those interested, the text properties are a corollary of the fact that under the hood, msgbox is simply a resized figure with hidden axes containing the icon image and text. This text handle can be modified during msgbox creation as indicated in the doc page, or after creation using set(findall(hMsgbox,’type’,'text’), …). For example:
hMsgbox = msgbox('simple text'); hMsgText = findall(hMsgbox,'type','text'); newMsgStr = '\color{red}\fontsize{14}\bf\it No !!!'; set(hMsgText, 'Interpreter','tex', 'string',newMsgStr);