Matlab 在子GUI中单击关闭按钮后,使按钮在maingui中可见
我有一个带有两个按钮的主gui。第一个按钮打开一个子GUI,另一个按钮是“运行”按钮,它是Matlab 在子GUI中单击关闭按钮后,使按钮在maingui中可见,matlab,user-interface,matlab-figure,Matlab,User Interface,Matlab Figure,我有一个带有两个按钮的主gui。第一个按钮打开一个子GUI,另一个按钮是“运行”按钮,它是'Enable'=Off。它是灰色的,不可点击。我知道我可以通过以下命令打开启用按钮:set(handles.start_按钮、'enable'、'on') 我通过单击“关闭”按钮在子GUI中执行此命令 我如何告诉他在主gui中设置命令 错误:引用不存在的字段“启动按钮” 由于在主GUI中定义了start\u按钮,因此它在子GUI的句柄结构中不可用。您需要在子GUI的句柄结构中存储主GUI的句柄 % Fro
'Enable'=Off
。它是灰色的,不可点击。我知道我可以通过以下命令打开启用按钮:set(handles.start_按钮、'enable'、'on')代码>
我通过单击“关闭”按钮在子GUI中执行此命令
我如何告诉他在主gui中设置命令
错误:引用不存在的字段“启动按钮”
由于在主GUI中定义了start\u按钮
,因此它在子GUI的句柄
结构中不可用。您需要在子GUI的句柄
结构中存储主GUI的句柄
% From within your main GUI
hfig = subGUI();
% Add the (current) main GUI handle to the subGUI handles
handles = guidata(hfig);
handles.parentGUI = hObject;
guidata(hfig, handles);
然后从子GUI回调中:
% Get the GUIDATA from the parent GUI
parentdata = guidata(handles.parentGUI);
% Change the pushbutton property
set(parentdata.start_pushbutton, 'Enable', 'on');
或者您可以在uicontrol
上使用标签
,以便您可以从其他GUI中找到它
% From the GUI that has this button
uicontrol('Tag', 'MyPushButton')
% From the button that was defined in the parent GUI
button = findall(0, 'Tag', 'MyPushButton');
set(button, 'Enable', 'on')
% From the GUI that has this button
uicontrol('Tag', 'MyPushButton')
% From the button that was defined in the parent GUI
button = findall(0, 'Tag', 'MyPushButton');
set(button, 'Enable', 'on')