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:

errordlg
errdlg Error Dialog
warndlg
warndlg Warning Dialog
helpdlg
helpdlg Help Dialog

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

uigefile dialog on Windows
uigefile dialog on Macintosh

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.

uisetfont font picker
uisetcolorfont picker

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:

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.

3 Responses to “More dialogs than you can shake a stick at”

  1. Petter replied on :

    My suggest you remove the minimize button on the dialogs in the first groups. Message boxes usually don’t have a minimize button.

  2. Mike replied on :

    Petter,

    I will forward your suggestion on to the message box developers. Remember thought that these dialogs do not have to be modal.

  3. Yair Altman replied on :

    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);
    

Leave a Reply

Wrap code fragments inside <pre> tags, like this:

<pre class="code">
a = magic(3);
sum(a)
</pre>

If you have a "<" character in your code, either follow it with a space or replace it with "&lt;" (including the semicolon).


Ken & Mike work on the MATLAB Desktop team.
  • DP: Hi i have a problem with ezplot3, i want to plot more than i curve in the same graph but hold on command...
  • Ken: Hi Arsalan, Unfortunately there is no way to get the new Editor API in older versions of MATLAB. -Ken
  • Arsalan: Hi, I am very excited about the MATLAB API for editor because right now i am working on a project and i need...
  • Johannes: Since I started using matlab-emacs some days ago I never experienced Emacslink. But I experienced some...
  • Francisco J. Beron-Vera: Hi all, I have recently learned about ViEmu (http://www.vimemu.c om) which, for Vi/Vim...
  • OysterEngineer: When I first learned of the Publish feature in MatLab, I thought it might be useful to help to...
  • Ken: Hi Herve, I’m not quite sure what you mean by “stand-alone&# 8221; mode? -Ken
  • Herve: I wonder when the publish fonction will be supported in standalone mode.
  • Mike: Ravi, What you described should work as far I understand it. Please follow up with technical support. With a...
  • Mike: @Daniel, Thanks for that note.

These postings are the author's and don't necessarily represent the opinions of The MathWorks.