필터 지우기
필터 지우기

MATLAB GUI callback to open a new figure?

조회 수: 6 (최근 30일)
Rahul Pillai
Rahul Pillai 2017년 11월 3일
댓글: Rahul Pillai 2017년 11월 3일
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

답변 (1개)

Geoff Hayes
Geoff Hayes 2017년 11월 3일
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
Rahul Pillai
Rahul Pillai 2017년 11월 3일
Is this call to the other GUI supposed to be inside the pushbackbutton callback function?

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Interactive Control and Callbacks에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by