display an icon (in png format) in a cell of a uitable

Hi,
I need to build a table that displays the status of a service in a GUI I am working on. I am using the uitable to display this information. In the first column I need to place the required icon (tick if on, cross if off etc). I can't seem to find how to do this anywhere. I have no clue at all. Please help.
Thanks. Varsha

 Réponse acceptée

Nicolas
Nicolas le 13 Juin 2011
actually you nearly had it.
the problem is your html code.
properly it should say:
'<IMG SRC="http://mathworks.com/logo.tif">'
...and it works!

4 commentaires

For me it just gets the broken link icon.
It is not impossible that a firewall is interfering, but that does seem unlikely from what I remember of our firewall configuration.
Has someone tried this with
uitable('Data',{'<HTML><IMG SRC="http://mathworks.com/logo.tif"></HTML>'})
Well, except for the semi-colon near the end: the Answers comment system automatically inserted that for me :(
Jan
Jan le 13 Juin 2011
@Walter: Even the browser does not find a logo.tif at mathworks.com - try it: http://www.mathworks.com/logo.tif . In consequence the broken link icon is not a failure.
Jan
Jan le 13 Juin 2011
@Nicolas: Although it is nicer, you do *not* have to close HTML tags in the UICONTROLs.

Connectez-vous pour commenter.

Plus de réponses (1)

There is no documented way to do this.
You can take advantage of the fact that text cells will be interpreted as HTML if they are in the proper format, such as
'<HTML><IMG="http://mathworks.com/logo.tif" >'
Using that I have been able to get the "broken link" icon, but I have not yet been able to get an actual image up. And you have to do nasty things to cell widths and fontsize to make room for the image.
If there is a mechanism for this, it would probably be described at Yair's undocumented matlab site

1 commentaire

Jan
Jan le 13 Juin 2011
Try an existing and local file:
pic = fullfile(matlabroot, 'toolbox', 'image', 'icon', 'icon_info.png');
uitable('Data', {['<html><img src="file:/', pic, '"></html>']})

Connectez-vous pour commenter.

Catégories

En savoir plus sur Develop Apps Using App Designer dans Centre d'aide et File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by