我有一个名为GUI_main的GUI,其中有一个名为pushbutton_GUI_main 。 我目前实现了以下回调函数:
function pushbutton_GUI_main_Callback(hObject, eventdata, handles) GUI_sub其中GUI_sub是另一个在单击pushbutton_GUI_main时打开的GUI。 但是,我想要以下内容:
function pushbutton_GUI_main_Callback(hObject, eventdata, handles) if (GUI_sub == open) close(GUI_sub) else GUI_sub也就是说,使用pushbutton_GUI_main我希望能够打开和关闭GUI_sub 。
I have a GUI called GUI_main in which I have a pushbutton called pushbutton_GUI_main. I currently have the following callback function implemented:
function pushbutton_GUI_main_Callback(hObject, eventdata, handles) GUI_subWhere GUI_sub is another GUI that opens when you click on pushbutton_GUI_main. However, I want something like the following:
function pushbutton_GUI_main_Callback(hObject, eventdata, handles) if (GUI_sub == open) close(GUI_sub) else GUI_subThat is, with pushbutton_GUI_main I want to be able to open and close GUI_sub.
最满意答案
正如excaza所说, 句柄是在GUI中传递数据或信息的好方法。 另一种方式,如果由于某种原因你不想存储GUI句柄,也许如果可以独立创建GUI_sub就是搜索图形句柄。
subGuiH = findall(0,'Name','GUI_sub'); if ~isempty(subGuiH) close(subGuiH); end GUI_sub;可以通过添加来缩小搜索范围
findall(0,'Type','figure','Name','GUI_sub')根据您的Matlab版本,您还可以结帐
As excaza says, handles is a great way to pass data or information in a GUI. Another way, if you for some reason don't want to store the GUI handle, perhaps if the GUI_sub could be created independently is to search for the figure handle.
subGuiH = findall(0,'Name','GUI_sub'); if ~isempty(subGuiH) close(subGuiH); end GUI_sub;The search could be narrowed by adding
findall(0,'Type','figure','Name','GUI_sub')Depending on your Matlab version, you could also checkout groot
更多推荐
发布评论