フィルターのクリア

How can I get another window after clicking on the push button?

39 ビュー (過去 30 日間)
Afsana Chowdhury
Afsana Chowdhury 2014 年 10 月 30 日
コメント済み: Sumayyah Alhydary 2021 年 4 月 6 日
I am making a tictactoe game. At first a window will come asking for the players' name. Then when the push button written "play" on it is clicked the window will change i.e. the window containing the game's plot will come.

採用された回答

Orion
Orion 2014 年 10 月 30 日
Hi,
In your pushbutton callback, just close the current figure and open/call the new one.
function PlayButton_callback(...)
% close current figure
closereq;
% open the new one
GamePlotFigure(...);
  3 件のコメント
Orion
Orion 2014 年 10 月 30 日
What I called GamePlotFiqure is a name I made up for the example.
let say You have 2 gui : the main one called tictactoe, and the second playgame
the main is launched in Matlab when you call the script tictactoe.m
with the play button, you want to do 2 actions : close the main gui and open the playgame gui.
so in the callback of the play button from the main gui :
function PlayButton_callback(hobject, evendata, handles)
% close the current figure, which is the main one when you click the play button
closereq;
% call the script which open the playgame gui
playgame(...);
here, closereq close the main gui and playgame (your script) open the second one.
Vinayak Appasaheb Bhatte
Vinayak Appasaheb Bhatte 2018 年 6 月 27 日
playgame(...); What do I fill in the dotted lines?

サインインしてコメントする。

その他の回答 (1 件)

Ana Gonçalves
Ana Gonçalves 2020 年 6 月 4 日
編集済み: Ana Gonçalves 2020 年 6 月 4 日
Hi guys, I did the following structure, and it works!
Use the command open to load a new GUI file (.fig) as in my example:
% --- Executes on button press in pushbutton5. Run Data analysis when pressing the button
function pushbutton5_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton5 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
strGui2 = ('C:\Users\Desktop\Matlab Ana\AnalysisTab.fig'); %Set your GUI file's location
open (strGui2); %Open the new GUI
closereq; %Close the actual GUI
  1 件のコメント
Sumayyah Alhydary
Sumayyah Alhydary 2021 年 4 月 6 日
Thank you that was very helpful!
Is there away to edit it so it doesn't reopen a new figure each time I click on the pushbutton?
because what I'm doing is to draw things on the figure and whenever I click again on the pushbutton a new empty figure shows up.
Thanks in advance!!!

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeGraphics Object Programming についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by