5.0

5.0 | 6 ratings Rate this file 181 downloads (last 30 days) File Size: 2.93 KB File ID: #10743

uibutton: GUI pushbuttons with better labels

by Douglas Schwarz

 

13 Apr 2006 (Updated 20 Apr 2006)

Code covered by BSD License  

Creates pushbutton uicontrol labeled with TeX or LaTeX strings.

Download Now | Watch this File

File Information
Description

Have you ever wanted to create a pushbutton uicontrol containing a Greek letter, some other mathematical expression or even just a multi-line label? This function will do it for you. It is very easy to use as it accepts all the same arguments as uicontrol with the addition of the Interpreter property which you can set to 'tex' or 'latex'. Also, you can pass in a cell array of strings for the String property to get a multi-line label. For example,

  uibutton('String','Set \beta','Interpreter','tex')

Acknowledgements
This submission has inspired the following:
3D Puma Robot Demo
MATLAB release MATLAB 7.0.4 (R14SP2)
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Comments and Ratings (9)
15 Apr 2006 Peter Nave  
16 Apr 2006 Jiro Doke

Very nice. I like how you create an image and use that as an ICON for the buttons. This guarantees that it behaves exactly like uicontrols.

One comment: when the style is TEXT, it creates a text object. In the code, you comment that it doesn't return the handle because it is not a UICONTROL. You should probably say something about that in the help text. Also, if someone (by mistake) asks for the handles, as in h=uibutton('style', 'text', ...), it gives an error because hout is not assigned. Maybe there's a better response to this, such as returning an empty variable or displaying a message.

04 Jun 2006 ebrahim sepidbar

pushbotton

19 Sep 2006 Trevor Fichera

Just what I needed. I am using it in Matlab Ver. 6.5.0 (R13.0.1). I had trouble with the isscalar(h) command, but I replaced it with ~any(size(h)-1) and it works great.
For multiline text buttons, try
uibutton(h,'String',' Print\newlineReport','HorizontalAlignment','center')
where h is the handle of an existing uicontrol button.

If anyone knows of a good LaTeX reference online, I would appreciate the post.

19 Feb 2008 Agnieszka Herman

Great! Works without any problems and it saved me really lots of time. Thank you!

30 Mar 2008 ding lu

very good

15 Apr 2008 Micke M

I would like to know where in the GUI-code to put the uibutton(...);

(For those of us that are quite new to GUIs)

15 Apr 2008 Matthew Adler

When I try to run this I get an error. I am able to generate the pushbutton with greek symbol, to size it and place it in the position I want with code:

alpha_button = uibutton('String','\alpha','Interpreter','tex','Position', [219 570 50 25]);

When I execute my GUI, however, the callback from my main pushbutton is not accessed. Also, if I move the symbol pushbutton into any position with 'position' I get the following error:

Error in ==> getframe at 35
  x=capturescreen(varargin{:});

Error in ==> uibutton at 146
frame = getframe(ax);

Error in ==> lcgui>lcgui_OutputFcn at 78
alpha_rand = uibutton('String','\alpha','Interpreter','tex','Position', [219 570 50 25]);

Error in ==> gui_mainfcn at 248
        [varargout{1:nargout}] = feval(gui_State.gui_OutputFcn, gui_hFigure, [], gui_Handles);

Error in ==> lcgui at 40
    [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});

Error in ==> Lehigh_Corrosion_Fatigue at 10
set(lcgui,'HandleVisibility','on')

??? Error using ==> Lehigh_Corrosion_Fatigue
Error using ==> capturescreen
The rectangle passed to getframe must be at least partially on screen.

??? Error while evaluating uicontrol Callback

28 Apr 2009 Emery  
Please login to add a comment or rating.
Updates
17 Apr 2006

Added ability to pass in figure or uipanel handle as first argument. Changed documentation.

20 Apr 2006

Now make background pixels transparent thereby making button look more like a normal button.

Tag Activity for this File
Tag Applied By Date/Time
gui tools Douglas Schwarz 22 Oct 2008 08:22:15
example Douglas Schwarz 22 Oct 2008 08:22:15
pushbutton tex latex greek uicontrol Douglas Schwarz 22 Oct 2008 08:22:15
example Petros Mpogiatzis 21 Jan 2009 08:53:53
example Campion 12 May 2009 10:00:48
 

MATLAB Central Terms of Use

NOTICE: Any content you submit to MATLAB Central, including personal information, is not subject to the protections which may be afforded information collected under other sections of The MathWorks, Inc. Web site. You are entirely responsible for all content that you upload, post, e-mail, transmit or otherwise make available via MATLAB Central. The MathWorks does not control the content posted by visitors to MATLAB Central and, does not guarantee the accuracy, integrity, or quality of such content. Under no circumstances will The MathWorks be liable in any way for any content not authored by The MathWorks, or any loss or damage of any kind incurred as a result of the use of any content posted, e-mailed, transmitted or otherwise made available via MATLAB Central. Read the complete Terms prior to use.

Contact us at files@mathworks.com