HELP!! MATLAB APP DESIGNER BUTTON PUSH AND PANEL VISIBILITY
    조회 수: 16 (최근 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 Apps Using App Designer에 대해 자세히 알아보기
			
	Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!


