HELP!! MATLAB APP DESIGNER BUTTON PUSH AND PANEL VISIBILITY

37 ビュー (過去 30 日間)
hgrlk
hgrlk 2021 年 5 月 21 日
編集済み: Shuba Nandini 2023 年 2 月 28 日
Hello, I'm working with matlab app designer. I want to design something that when I select the button group, a panel appears. But I cannot do it. I want the panel to appear when I make a selection on the button.
I write app.Panel.Visible = 1; but it didnt work.
classdef app1 < matlab.apps.AppBase
% Properties that correspond to app components
properties (Access = public)
UIFigure matlab.ui.Figure
ButtonGroup matlab.ui.container.ButtonGroup
Button matlab.ui.control.ToggleButton
end
% Callbacks that handle component events
methods (Access = private)
% Selection changed function: ButtonGroup
function ButtonGroupSelectionChanged(app, event)
selectedButton = app.ButtonGroup.SelectedObject;
app.Panel.Visible=1;
end
end
  1 件のコメント
Anurag Kurle
Anurag Kurle 2022 年 7 月 5 日
Hello,
Here's the link addressing the same issue.

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

回答 (1 件)

Shuba Nandini
Shuba Nandini 2023 年 2 月 28 日
編集済み: Shuba Nandini 2023 年 2 月 28 日
Hello,
I understand that you are having trouble with button group and Panel visibility.
According to my research, I have come up with the following steps which can help you to open panel. Your code looks correct but to open a panel when the buttongroup is selected, you must define the property for the panel in the app’s properties section before it’s visibility is set to 1.
Please look at the example below:
classdef app1 < matlab.apps.AppBase
% Properties that correspond to app components
properties (Access = public)
UIFigure matlab.ui.Figure
ButtonGroup matlab.ui.container.ButtonGroup
Button matlab.ui.control.ToggleButton
Panel matlab.ui.container.Panel % Define a property for the panel
end
% Callbacks that handle component events
methods (Access = private)
% Selection changed function: ButtonGroup
function ButtonGroupSelectionChanged(app, event)
selectedButton = app.ButtonGroup.SelectedObject;
app.Panel.Visible='on'; % Set the visibility of the panel to 'on'
end
end
end
As in above code, Visible Property of panel is set ‘on’ instead of ‘1’. This is because the Visible Property of MATLAB UI Component can either be set ‘on’ or ‘off’.
Refer the below links for more information:
Thanks

カテゴリ

Help Center および File ExchangeDevelop uifigure-Based Apps についてさらに検索

製品


リリース

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by