HELP!! MATLAB APP DESIGNER BUTTON PUSH AND PANEL VISIBILITY
22 次查看(过去 30 天)
显示 更早的评论
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
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
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Develop uifigure-Based Apps 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!