Effacer les filtres
Effacer les filtres

MATLAB GUI callback to open a new figure?

6 vues (au cours des 30 derniers jours)
Rahul Pillai
Rahul Pillai le 3 Nov 2017
Commenté : Rahul Pillai le 3 Nov 2017
Hello. I am trying to run a GUI program which opens when I run the source script file. When the script is run, a window opens with a pushbutton inside of it. When the user clicks on the pushbutton I want this window to close and a new one to open (or even better, the new window should replace the old one at the exact location on the screen). The next screen will also be a figure with its own set of pushbuttons and callbacks etc. I have figured out how to close the figure when the pushbutton is clicked by entering the required commands in the callback. However I can't seem to open a new figure. It leads to a destroyedcallback error and also says that the figure I tried to open didn't exist (although it does exist in the same location as the source script file). The pushbutton for the main window looks like this:
% --- Executes on button press in prob1push.
function prob1push_Callback(hObject, eventdata, handles)
% hObject handle to prob1push (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
h_help = findobj('Tag','prob1push');
if (isempty(h_help))
% Do something here -- window doesn't currently exist
else
closereq;
end

Réponses (1)

Geoff Hayes
Geoff Hayes le 3 Nov 2017
Rahul - just call the name of the second GUI. i.e. if the name of the other GUI is OtherGUI, then just call it as
hGui = OtherGui('Visible','off');
to open it but keep it invisible. You can then use hGUI to change the position of the GUI and then make it re-appear.
set(hGui,'Position',[x y w h]);
set(hGui,'Visible', 'on');
where `[x y u v]` is the new position (and dimensions) of the GUI.
  1 commentaire
Rahul Pillai
Rahul Pillai le 3 Nov 2017
Is this call to the other GUI supposed to be inside the pushbackbutton callback function?

Connectez-vous pour commenter.

Catégories

En savoir plus sur Interactive Control and Callbacks dans Help Center et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by