Linking code to a Gui
1 回表示 (過去 30 日間)
古いコメントを表示
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...
0 件のコメント
回答 (1 件)
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
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.
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!