Linking code to a Gui

2 visualizaciones (últimos 30 días)
JB
JB el 6 de Nov. de 2015
Comentada: JB el 6 de Nov. de 2015
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
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
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 Startup and Shutdown en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by