2016-12-10 1 views
1

私は2つのプッシュボタンを持つメインGUIを持っています。最初のボタンはサブグイを開き、もう1つのボタンは'Enable'=Offの「実行」プッシュボタンです。グレーでクリックできません。私はこのコマンドでイネーブルを「オン」にすることができることを知っています:set(handles.start_pushbutton,'Enable','on'); "閉じる"ボタンをクリックすることによって、このコマンドをサブGUIで実行します。サブギのクローズボタンをクリックした後にmainguiでプッシュボタンを表示する

function pushbutton_Beenden_Callback(hObject, eventdata, handles) 
closereq; 
set(handles.start_pushbutton,'Enable','on'); 

私は彼にコマンドを設定するように指示できますが、メインGUIにはどのように伝えますか?

Error: Reference to non-existent field 'start_pushbutton'

答えて

1

あなたstart_pushbuttonメイン GUIで定義されているので、それはあなたのサブGUIのhandles構造では使用できません。メインGUIのハンドルをサブGUIのhandles構造体に保存するか、 subGUIコールバック内から次に

% 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); 

% Get the GUIDATA from the parent GUI 
parentdata = guidata(handles.parentGUI); 

% Change the pushbutton property 
set(parentdata.start_pushbutton, 'Enable', 'on'); 

それとも、あなたが他のGUIからそれを見つけることができるようにuicontrolTagを使用することができます。

% 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') 
+0

ありがとうございます:) – jdoubleu

関連する問題