Guide Popupmenu adding an image?

3 visualizaciones (últimos 30 días)
Christopher
Christopher el 14 de Nov. de 2014
Comentada: Image Analyst el 16 de Nov. de 2014
How can you add an image to a popupmenu using guide? An example picture of what I am trying to do is shown below. I have been trying to figure this out with no luck. Any help is appreciated.

Respuesta aceptada

Image Analyst
Image Analyst el 16 de Nov. de 2014
You can get that at Yair's site undocumented MATLAB.

Más respuestas (1)

Jan
Jan el 15 de Nov. de 2014
You can include images using HTML:
Icon = fullfile(matlabroot,'/toolbox/matlab/icons/matlabicon.gif');
IconURI = ['"file:/', strrep(Icon, '\', '/'), '"'];
uicontrol('Style', 'popupmenu', ...
'String', {'Hello', ['<html><img src=', IconURI, '> String']})
  4 comentarios
Christopher
Christopher el 16 de Nov. de 2014
Awesome, that seems to work. Now I just need to figure out how to adjust the spacing. The icon show's up almost on the text.
Is it better to leave the popupmenu strings empty and just reference them this way when using the images? So If I want to use there selection to perform operations such as:
contents = get(hObject,'Value')
switch contents
case 1
set(handles.edit1, 'Visible', 'off');
set(handles.text5, 'Visible', 'off');
case 2
% a=imread('11.png');
% imshow(a);
otherwise
end
Image Analyst
Image Analyst el 16 de Nov. de 2014
That's not right. Look at the code in comments. What you call contents is actually the index that is selected. To get the contents and index:
selectedIndex = get(handles.popup1, 'Value');
allContents = get(handles.popup1,'string');
selectedContents = allContents{selectedIndex};

Iniciar sesión para comentar.

Categorías

Más información sobre Migrate GUIDE Apps en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by