How I make a pushbutton visible using another pushbutton in a GUI?

"Pushbutton 1" shows and work with graphical data essential to the "pushbutton 2" subprogram task. Pushing "pushbutton 2" before "pushbutton 1" leads to error. I want to make "pushbutton 2" inaccesible in the GUI until user press "pushbutton 1". How can I do it?

 採用された回答

Azzi Abdelmalek
Azzi Abdelmalek 2013 年 11 月 5 日
編集済み: Azzi Abdelmalek 2013 年 11 月 5 日

3 投票

You can use the properties 'enable' or 'visible'
set(handles.pushbutton1,'enable','off')
%or
set(handles.pushbutton1,'visible','off')

3 件のコメント

CarlosCEAM
CarlosCEAM 2013 年 11 月 5 日
編集済み: CarlosCEAM 2013 年 11 月 5 日
In property inspector I set pushbutton 2 as "off", and then I have this code:
% --- Executes on button press in pushbutton1.
function pushbutton1_Callback(hObject, eventdata, handles)
set(handles.pushbutton2, 'enable','on')
The button shows grayed out, but pushing "pushbutton 1" doesn't make any change on "pushbutton 2". Am I missing something?
Image Analyst
Image Analyst 2013 年 11 月 5 日
Set a breakpoint there and see if it actually executes that line. You can also use the 'visible' property to hide it or show it. Enable property enables or disables (grays out) the button. You might also try adding a drawnow after the set() call though it should not be necessary.
Azzi Abdelmalek
Azzi Abdelmalek 2013 年 11 月 5 日
編集済み: Azzi Abdelmalek 2013 年 11 月 5 日
Don't forget to save your m-file

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

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File 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