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 件のコメント
Luke Barnard
Luke Barnard 2013 年 8 月 11 日
Dear Robert,
Thank you for you help, as you suggested I was able to use this method to solve my problem.
Many thanks,
Luke

サインインしてコメントする。

その他の回答 (1 件)

Bassam ElGhoul
Bassam ElGhoul 2018 年 8 月 9 日
how to use this function for GUI

カテゴリ

Help Center および File ExchangeMigrate GUIDE Apps についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by