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?

1 次查看(过去 30 天)
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

采纳的回答

Robert Cumming
Robert Cumming 2013-8-9
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} );

更多回答(1 个)

Bassam ElGhoul
Bassam ElGhoul 2018-8-9
how to use this function for GUI

类别

Help CenterFile Exchange 中查找有关 Migrate GUIDE Apps 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by