Hello, I am new with GUI stuff, i have a code that is taking input of date,time,year from user,
i want it to be connected with pop-up menus in the GUI i created.
start_date =[2015, 1, 1];
The follwing is the code for year popup menu in GUI,as year uses popup menu 2:
%Executes on selection change in popupmenu2.
function popupmenu2_Callback(hObject, eventdata, handles)
% --- Executes during object creation, after setting all properties.
function popupmenu2_CreateFcn(hObject, eventdata, handles)
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
Help will be highly appreciated...

답변 (1개)

Image Analyst
Image Analyst 2015년 11월 6일

0 개 추천

You need to populate the popup with some items the user can select. You can do that with GUIDE in the Property Inspector (double click the control), or in your OpeningFcn() with the set(handles.popupmenu2, 'String', itemsList) function call.
You need to put some code in the popupmenu2_Callback() function. What do you want it to do when the user selects an item from the popup control? Whatever it is, put those commands into the popup's callback function.

댓글 수: 3

JB
JB 2015년 11월 6일
편집: JB 2015년 11월 6일
Hey,thanks alot for replying. I didnt got 'populate the popup'?
I want upon selection from popup enteries the selected enteries should be stored in "start_date" which is 1x6 double. For example if user selects 2015 from the popup,it should be stored as
start_date =[2015, 1, 1];
same for date & month. Thanks again
"Populate the popup" means that you have to enter some items into it so that the user can select one. Otherwise it will be empty. How did you put the items into the popup? For example, you say that the user can select 2015 from the popup, so somehow you must have gotten that 2015 to be inside the popup. And perhaps you populated it with other years also. Maybe you did that in GUIDE by setting the string property, or maybe you did it with code like this:
% Create list of things to appear in the popup.
itemsList = {'2013', '2014', '2015', '2016'};
% Right now, the popup might be empty or have
% some other things in it that you setup before.
% Send that list, that variable, itemsList, to the popup.
set(handles.popupmenu2, 'String', itemsList)
% Now user will see the list of years in the popup.
JB
JB 2015년 11월 6일
I used string property in Guide to fill up the pop up menu. I am attaching the demo file. Problem is i want to link it with a matrix that is saving the date. The name of the matrix saving date is:
start_date .
your help will give a jumpstart to my task. Thanks in advance

댓글을 달려면 로그인하십시오.

카테고리

도움말 센터File Exchange에서 File Operations에 대해 자세히 알아보기

질문:

JB
2015년 11월 6일

댓글:

JB
2015년 11월 6일

Community Treasure Hunt

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

Start Hunting!

Translated by