Linking code to a Gui

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...

Respuestas (1)

Image Analyst
Image Analyst el 6 de Nov. de 2015

0 votos

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 comentarios

JB
JB el 6 de Nov. de 2015
Editada: JB el 6 de Nov. de 2015
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
Image Analyst
Image Analyst el 6 de Nov. de 2015
"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 el 6 de Nov. de 2015
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

Iniciar sesión para comentar.

Categorías

Más información sobre File Operations en Centro de ayuda y File Exchange.

Etiquetas

Preguntada:

JB
el 6 de Nov. de 2015

Comentada:

JB
el 6 de Nov. de 2015

Community Treasure Hunt

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

Start Hunting!

Translated by