필터 지우기
필터 지우기

Linking code to a Gui

조회 수: 1 (최근 30일)
JB
JB 2015년 11월 6일
댓글: JB 2015년 11월 6일
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일
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
Image Analyst
Image Analyst 2015년 11월 6일
"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

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

카테고리

Help CenterFile Exchange에서 App Building에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by