Info

La pregunta está cerrada. Vuélvala a abrir para editarla o responderla.

Writing callback for gui

1 visualización (últimos 30 días)
vedesh Mohit
vedesh Mohit el 3 de En. de 2020
Cerrada: MATLAB Answer Bot el 20 de Ag. de 2021
hey,
I have to create a GUI that allows the user to construct a logic circuit from a menu using NOT, AND and OR gates. The gates are required to be placed in a static position in the construction window. How do I go about writing a callback for the pushbutton that when the user clicks the button, a popup menu appears to ask the user which section to place the gate?

Respuestas (2)

Walter Roberson
Walter Roberson el 3 de En. de 2020
valid_sections = {'A3', 'B17', 'Thorax', 'Trailing L2 point'};
choice = menu('Choose a section to place into', valid_sections);
if choice == 0
user did not select anything
else
section_name = valid_sections{choice};
now do something based upon section_name
end
  1 comentario
Walter Roberson
Walter Roberson el 3 de En. de 2020
You can improve the above by something like,
if ~isfield(handles, 'used_sections')
handles.used_sections = {};
end
valid_sections = {'A3', 'B17', 'Thorax', 'Trailing L2 point'};
available_sections = setdiff(valid_sections, handles.used_sections);
choice = menu('Choose a section to place into', available_sections);
if choice == 0
user did not select anything
else
section_name = valid_sections{choice};
now do something based upon section_name
%update list of used sections
handles.used_sections{end+1} = section_name;
guidata(hObject, handles);
end

Image Analyst
Image Analyst el 3 de En. de 2020
Are you using GUIDE or App Designer? Either way, the source code will have a callback for the pushbutton. If using GUIDE, right click on the button and say "view callback", then, in the callback function, you can use either questdlg() or menu() to get the user's choice of NOT, AND, or OR.
  1 comentario
vedesh Mohit
vedesh Mohit el 3 de En. de 2020
yes i am using guide

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by