Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

greek symbols in GUI

242 views
Skip to first unread message

Jonas

unread,
Oct 27, 2007, 6:24:17 PM10/27/07
to
Hello, I'm building a GUI and I like to know how to get a
greek symbol for example in a static text or in a push
button. I'd then like to write

set(handles.static_text,'String','\alpha')

to display the greek letter alpha but this doesn't work.
Thanks!

Dan

unread,
Oct 27, 2007, 8:28:19 PM10/27/07
to
"Jonas " <josl...@student.umu.se> wrote in message
<fg0dqh$lt9$1...@fred.mathworks.com>...

There is a submission on the file exchange for doing this
at http://www.mathworks.com/matlabcentral/fileexchange/
loadFile.do?objectId=10743&objectType=file

Dan

Jonas

unread,
Oct 28, 2007, 6:02:35 AM10/28/07
to
"Dan " <dpc...@yahoo.com> wrote in message <fg0l33
$b7u$1...@fred.mathworks.com>...

Yes, that is one way to do it, although it is easy to run
the function i wonder if there is a simpler way to do it?

Doug Schwarz

unread,
Oct 28, 2007, 9:25:31 AM10/28/07
to
In article <fg1mnr$foh$1...@fred.mathworks.com>,
"Jonas " <josl...@student.umu.se> wrote:


If all you want is Greek letters then you can just use the Symbol font:

set(handles.static_text,'String','a','FontName','symbol')

--
Doug Schwarz
dmschwarz&ieee,org
Make obvious changes to get real email address.

Jonas

unread,
Oct 28, 2007, 2:47:49 PM10/28/07
to
Well, I also need subscript letters so that I can write a
variable with its index.

Doug Schwarz

unread,
Oct 28, 2007, 6:30:52 PM10/28/07
to
In article <fg2lgl$ses$1...@fred.mathworks.com>,
"Jonas " <josl...@student.umu.se> wrote:

> Well, I also need subscript letters so that I can write a
> variable with its index.

Well, that's okay because the Symbol font has normal numbers. It should
look fine.

Jonas

unread,
Oct 29, 2007, 4:24:42 PM10/29/07
to
But what about a letter in normal size plus a subscript.
For example to get a title for a plot with subscripts one
would write

title('E_\theta');

So is there any simple way of doing this for a GUI control
such as in a static text? Or is this really a limitation in
GUI controls?

Doug Schwarz

unread,
Oct 29, 2007, 6:25:54 PM10/29/07
to
In article <fg5fia$epv$1...@fred.mathworks.com>,
"Jonas " <josl...@student.umu.se> wrote:

No, there's no simple way. UIcontrols don't use the tex or latex
renderers, I don't know why. Anyway, that's why I wrote uibutton. Just
use that.

Yair Altman

unread,
Oct 29, 2007, 8:22:23 PM10/29/07
to
"Jonas " <josl...@student.umu.se> wrote in message
<fg5fia$epv$1...@fred.mathworks.com>...

You can use an undocumented feature of all Matlab
uicontrols, which is the fact that they use underlying Java
Swing controls, and these in turn accept any valid HTML
strings. So you can do the following for example:

uicontrol('string','<html><b>1<sub>2</sub>3<sup>4</sup>5</b></html>')

This is equivalent to the tex string '\bf1_23^45\rm'. You
can set font faces, colors, sizes, bold/italic and any other
valid HTML 3.0 property. It's limited, but should do the
trick in most conceivable cases.

The same is true for tooltips, by the way: try setting
multi-line (<br>) multi-colored (<font color="red"> ...
</font>) tooltip once and you'll never use the standard
boring single-line black tooltip again...

And just in case you were wondering - yes, it also works for
menus, listboxes etc.

Yair Altman
http://ymasoftware.com

Jonas

unread,
Oct 30, 2007, 7:13:51 AM10/30/07
to
> You can use an undocumented feature of all Matlab
> uicontrols, which is the fact that they use underlying
Java
> Swing controls, and these in turn accept any valid HTML
> strings. So you can do the following for example:
>
> uicontrol
('string','<html><b>1<sub>2</sub>3<sup>4</sup>5</b></html>')
>
> This is equivalent to the tex string '\bf1_23^45\rm'. You
> can set font faces, colors, sizes, bold/italic and any
other
> valid HTML 3.0 property. It's limited, but should do the
> trick in most conceivable cases.
>
> The same is true for tooltips, by the way: try setting
> multi-line (<br>) multi-colored (<font color="red"> ...
> </font>) tooltip once and you'll never use the standard
> boring single-line black tooltip again...
>
> And just in case you were wondering - yes, it also works
for
> menus, listboxes etc.
>
> Yair Altman
> http://ymasoftware.com
>

Hello, this was a great feature I didn't know about.
However, this works with every uicontrol except with static
text, the one I needed. So I guess the text uicontrol
doesnt' have this underlying Java Swing control. But thanks
to all of you who tried to help.

Travis Bennett

unread,
Aug 2, 2008, 11:45:05 PM8/2/08
to
Try

uicontrol(['string','<html>&#960;</html>'])

and use a decimal value for the stuff between the html tags.
You'll get a pi button.

The values can be found at the handy chart at
http://htmlhelp.com/reference/html40/entities/symbols.html

I just wish it would work for disp() too.

Bruno Luong

unread,
Aug 3, 2008, 5:03:01 AM8/3/08
to
Hello,

The java syntax '<html>&lambda</html>' works great on the
recent MATLAB version with greek lambda.

But it does not work on a GUI fig created by 2006B version:
The text appears as it is on the screen:'<html>
&lambda</html>'. Is there a way to make it work on 2006B?

Thanks,

Bruno

Bruno Luong

unread,
Aug 3, 2008, 5:08:02 AM8/3/08
to
"Travis Bennett" <donts...@gmail.com> wrote in message
<g739k1$ajs$1...@fred.mathworks.com>...

> Try
>
> uicontrol(['string','<html>&#960;</html>'])
>

Type Correction:

uicontrol('string','<html>&#960;</html>')

Bruno

Nash Dima

unread,
Aug 12, 2010, 9:02:06 AM8/12/10
to
Doug Schwarz <s...@sig.for.address.edu> wrote in message <see-5CACE8.0...@71-129-133-66.dollamir.com>...


Hi,
Is it possible to make a string for static txt not only with greek letters, ie Impedance (&#937;) using the symbol font? Any other alternatives?

Thanks

Nash Dima

unread,
Aug 12, 2010, 9:41:06 AM8/12/10
to

Yair Altman

unread,
Aug 12, 2010, 12:37:04 PM8/12/10
to
> Is it possible to make a string for static txt not only with greek letters, ie Impedance (&#937;) using the symbol font? Any other alternatives?

Of course it is possible: http://undocumentedmatlab.com/blog/customizing-matlab-labels/

Yair Altman
http://UndocumentedMatlab.com

Sameera Prematilake

unread,
Jul 5, 2012, 10:18:07 AM7/5/12
to
"Travis Bennett" wrote in message <g739k1$ajs$1...@fred.mathworks.com>...
> Try
>
> uicontrol(['string','<html>?</html>'])
>
> and use a decimal value for the stuff between the html tags.
> You'll get a pi button.
>
> The values can be found at the handy chart at
> http://htmlhelp.com/reference/html40/entities/symbols.html
>
> I just wish it would work for disp() too.

This worked for my pop-up menu.

Thanks for every ones help.

KFrenkie

unread,
Dec 31, 2015, 5:55:14 AM12/31/15
to
Hi all,

I have a question while it still does not for me. It just gives the <html>.... string instead of the wanted kg/m^2 with superscript :(.

uicontrol(handles.PAT_DATA_PANEL3,'Style','text','string','<html><b>kg/m</sup>2</b></html>','Units','normalized','Position', [.85 .325 .15 .05],'BackgroundColor',Panelcolor,'HorizontalAlignment', 'left');

What am I doing wrong?

tried all the methods mentioned above!
Greetings, Martijn

"Sameera Prematilake" wrote in message <jt47mv$ncb$1...@newscl01ah.mathworks.com>...

Yair Altman

unread,
Dec 31, 2015, 7:36:17 AM12/31/15
to
"KFrenkie" wrote in message <n631i7$bk9$1...@newscl01ah.mathworks.com>...
HTML is supported by all uicontrols *EXCEPT* for labels (style='text'). Read the solution to this problem here: http://undocumentedmatlab.com/blog/customizing-matlab-labels

Yair Altman
http://UndocumentedMatlab.com

0 new messages