5.0

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

uibutton: GUI pushbuttons with better labels

by Douglas Schwarz

 

13 Apr 2006 (Updated 10 Mar 2010)

Code covered by the 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' and the Rotation property to set the angle of rotation of the text. 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')

Can also create something that looks like a text uicontrol.

Acknowledgements
This submission has inspired the following:
3D Puma Robot Demo, Euler angle, DCM, Quaternion, and Euler Vector Conversion/Teaching GUI
MATLAB release MATLAB 7.8 (R2009a)
Zip File Content  
Other Files license.txt,
uibutton.m
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.

07 Mar 2010

Added ability to set the text rotation angle.

10 Mar 2010

Fixed bug introduced in previous update.

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
pushbutton tex latex greek uicontrol tibor 25 Feb 2010 14:32:26
pushbutton tex latex greek uicontrol Patrizia Richner 13 Jul 2010 05:35:22
example Patrizia Richner 13 Jul 2010 05:36:16

Contact us at files@mathworks.com