Has anyone found a way to enable/disable tabs in App Designer?

97 ビュー (過去 30 日間)
Matt Calton
Matt Calton 2016 年 8 月 22 日
編集済み: Jason Kulpe 2020 年 8 月 13 日
I am building a fairly simple GUI in I have tried implementations using findjobj, such as:
jtabgroup=findjobj(tabgrp);
jtabgroup.setEnabledAt(1,0);
but I am unsure if the app class can be read the same way (I'm very new to Java implementations). Any help would be much appreciated!
  1 件のコメント
Paolo Fiore
Paolo Fiore 2020 年 4 月 18 日
編集済み: Paolo Fiore 2020 年 4 月 18 日
I found a possible way:
app.tabNameYouWantToDisable.Parent=[];
this will make the specific tab disappear from the GUI.
When you are done with the code execution you can reassign its parent:
app.tabNameYouWantToDisable.Parent=app.TabGroup;
I found this while using Matlab R2020a.

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

採用された回答

David Barry
David Barry 2016 年 8 月 25 日
I don't believe that you can yet enable/disable tabs in MATLAB and this is something I have requested from them. Using findjobj with App Designer components is probably not going to be much use to you anyway as they are no longer Java Swing components like their uicontrol predecessors.

その他の回答 (3 件)

Adam Danz
Adam Danz 2020 年 7 月 7 日
As of r2020a, there isn't an option to set the visibility or 'enable' property of a tab. However, you can control which tabs can be selected via the use of a SelectionChangedFcn.
Here's a demo that uses check boxes to determine whether a tab can be selected:

Jason Kulpe
Jason Kulpe 2020 年 8 月 13 日
編集済み: Jason Kulpe 2020 年 8 月 13 日
In my App I need to disable a tab's features (not the tab itself) while a process is occuring. My solution is to recursively find the children components of a given tab and set component.Enable = true or false. For graphics purposes I dont disable uilabels, etc (doesn't look great), so I exlude these. Edit: using MATLAB R2019a
function setEnableWithChildren(app, component, value)
% Recursively set enable status for all items
if isa(component, 'matlab.ui.control.Label') || isa(component, 'matlab.ui.control.Lamp')
return % Don't enable labels, etc.
end
if isprop(component, 'Enable')
if isa(component, 'matlab.ui.control.Table')
if value
component.Enable = 'on'; % Table uses on/off
else
component.Enable = 'off';
end
else
component.Enable = value;
end
end
if isprop(component, 'Children')
children = allchild(component);
else
children = [];
end
for child = reshape(children, 1, [])
app.setEnableWithChildren(child, value);
end
end

Desmond Ng
Desmond Ng 2019 年 7 月 1 日
編集済み: Desmond Ng 2019 年 7 月 1 日
Use app.TabGroup.Visible='off';

カテゴリ

Help Center および File ExchangeMigrate GUIDE Apps についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by