HELP!! MATLAB APP DESIGNER BUTTON PUSH AND PANEL VISIBILITY

조회 수: 43 (최근 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개)

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 CenterFile Exchange에서 App Building에 대해 자세히 알아보기

제품


릴리스

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by