How can I make the contents of a pop-up box in a GUI dependent on the selection of another pop-up box in the same GUI?
3 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Luke Barnard
el 9 de Ag. de 2013
Respondida: Bassam ElGhoul
el 9 de Ag. de 2018
Dear All,
I have a large number of image files from an experiment and I am building a small and simple gui to make browsing through them less laborious.
Specifically, I have a sequence of images from two cameras, say A and B, which take photos at certain times t1...tn (7 times), and multiple positions, x1...xn (16 positions).
I have so far built a working GUI which provides pop up menus to select the camera, and time, and from this builds a filename for one position (which has a form similar to 'A_tn_xn.png') and process and display the image. This works okay, but is limited to the one position.
My problem has been introducing a pop up box for the position variables, and this is because the position variable has different values for camera A and B. Therefore, I would like the contents of the list in the position pop up box to be dependent on the user selection of the camera.
Presently I have been unable to work out how best to acheive this.
Any help or pointers would be appreciated,
Many thanks, Luke
0 comentarios
Respuesta aceptada
Robert Cumming
el 9 de Ag. de 2013
The code below should show you an example of what you could do linking 2 pop menus and contents.
Maybe from that you can work out what else you need to do in your situation.
% parent list
items = { 'A', 'B' };
% secondary list
secondList{1} = { 'A1' 'A2' };
secondList{2} = { 'B1' 'B2' };
% create a fig
hf = figure;
% create a anonymous function for the parent list callback
anon = @(x,y,z) set ( z, 'string', secondList{get(x,'value')} );
% create the uicontrol popup menus
h1 = uicontrol ( 'parent', hf, 'style', 'popupmenu', 'units', 'normalized', ...
'position', [ 0 0.0 1 0.2], 'string', {''} );
h2 = uicontrol ( 'parent', hf, 'style', 'popupmenu', 'units', 'normalized', ...
'position', [ 0 0.2 1 0.2], 'string', items, 'Callback', {anon h1} );
Más respuestas (1)
Ver también
Categorías
Más información sobre Entering Commands en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!