Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
greek symbols in GUI

Subject: greek symbols in GUI

From: Jonas

Date: 27 Oct, 2007 22:24:17

Message: 1 of 17

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!

Subject: greek symbols in GUI

From: Dan

Date: 28 Oct, 2007 00:28:19

Message: 2 of 17

"Jonas " <joslaa02@student.umu.se> wrote in message
<fg0dqh$lt9$1@fred.mathworks.com>...
> 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!

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

Subject: greek symbols in GUI

From: Jonas

Date: 28 Oct, 2007 10:02:35

Message: 3 of 17

"Dan " <dpcore@yahoo.com> wrote in message <fg0l33
$b7u$1@fred.mathworks.com>...
> "Jonas " <joslaa02@student.umu.se> wrote in message
> <fg0dqh$lt9$1@fred.mathworks.com>...
> > 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!
>
> 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

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?

Subject: greek symbols in GUI

From: Doug Schwarz

Date: 28 Oct, 2007 13:25:31

Message: 4 of 17

In article <fg1mnr$foh$1@fred.mathworks.com>,
 "Jonas " <joslaa02@student.umu.se> wrote:

> "Dan " <dpcore@yahoo.com> wrote in message <fg0l33
> $b7u$1@fred.mathworks.com>...
> > "Jonas " <joslaa02@student.umu.se> wrote in message
> > <fg0dqh$lt9$1@fred.mathworks.com>...
> > > 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!
> >
> > 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
>
> 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?


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.

Subject: greek symbols in GUI

From: Jonas

Date: 28 Oct, 2007 18:47:49

Message: 5 of 17

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

Subject: greek symbols in GUI

From: Doug Schwarz

Date: 28 Oct, 2007 22:30:52

Message: 6 of 17

In article <fg2lgl$ses$1@fred.mathworks.com>,
 "Jonas " <joslaa02@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.

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

Subject: greek symbols in GUI

From: Jonas

Date: 29 Oct, 2007 20:24:42

Message: 7 of 17

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?

Subject: greek symbols in GUI

From: Doug Schwarz

Date: 29 Oct, 2007 22:25:54

Message: 8 of 17

In article <fg5fia$epv$1@fred.mathworks.com>,
 "Jonas " <joslaa02@student.umu.se> wrote:

> 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?

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.

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

Subject: greek symbols in GUI

From: Yair Altman

Date: 30 Oct, 2007 00:22:23

Message: 9 of 17

"Jonas " <joslaa02@student.umu.se> wrote in message
<fg5fia$epv$1@fred.mathworks.com>...
> 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?

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

Subject: greek symbols in GUI

From: Jonas

Date: 30 Oct, 2007 11:13:51

Message: 10 of 17

> 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.

Subject: greek symbols in GUI

From: Travis Bennett

Date: 3 Aug, 2008 03:45:05

Message: 11 of 17

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.

Subject: greek symbols in GUI

From: Bruno Luong

Date: 3 Aug, 2008 09:03:01

Message: 12 of 17

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

Subject: greek symbols in GUI

From: Bruno Luong

Date: 3 Aug, 2008 09:08:02

Message: 13 of 17

"Travis Bennett" <dontspam.me@gmail.com> wrote in message
<g739k1$ajs$1@fred.mathworks.com>...
> Try
>
> uicontrol(['string','<html>π</html>'])
>

Type Correction:

uicontrol('string','<html>π</html>')

Bruno

Subject: greek symbols in GUI

From: Nash Dima

Date: 12 Aug, 2010 13:02:06

Message: 14 of 17

Doug Schwarz <see@sig.for.address.edu> wrote in message <see-5CACE8.09253028102007@71-129-133-66.dollamir.com>...
> In article <fg1mnr$foh$1@fred.mathworks.com>,
> "Jonas " <joslaa02@student.umu.se> wrote:
>
> > "Dan " <dpcore@yahoo.com> wrote in message <fg0l33
> > $b7u$1@fred.mathworks.com>...
> > > "Jonas " <joslaa02@student.umu.se> wrote in message
> > > <fg0dqh$lt9$1@fred.mathworks.com>...
> > > > 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!
> > >
> > > 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
> >
> > 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?
>
>
> 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.


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

Thanks

Subject: greek symbols in GUI

From: Nash Dima

Date: 12 Aug, 2010 13:41:06

Message: 15 of 17

Doug Schwarz <see@sig.for.address.edu> wrote in message <see-5CACE8.09253028102007@71-129-133-66.dollamir.com>...
> In article <fg1mnr$foh$1@fred.mathworks.com>,
> "Jonas " <joslaa02@student.umu.se> wrote:
>
> > "Dan " <dpcore@yahoo.com> wrote in message <fg0l33
> > $b7u$1@fred.mathworks.com>...
> > > "Jonas " <joslaa02@student.umu.se> wrote in message
> > > <fg0dqh$lt9$1@fred.mathworks.com>...
> > > > 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!
> > >
> > > 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
> >
> > 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?
>
>
> 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.


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

Thanks

Subject: greek symbols in GUI

From: Yair Altman

Date: 12 Aug, 2010 16:37:04

Message: 16 of 17

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

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

Yair Altman
http://UndocumentedMatlab.com

Subject: greek symbols in GUI

From: Sameera Prematilake

Date: 5 Jul, 2012 14:18:07

Message: 17 of 17

"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.

Tags for this Thread

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us