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?

조회 수: 2 (최근 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 CenterFile Exchange에서 Entering Commands에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by