App Designer: How do I make the code view editable?

7 Ansichten (letzte 30 Tage)
Sarah Cuddy-Walsh
Sarah Cuddy-Walsh am 5 Feb. 2018
Bearbeitet: per isakson am 20 Feb. 2018
Hello,
I am running Matlab R2016a in Windows 10. I am trying to test out appdesigner on my machine. In my matlab installation there isn't an AppDesigner button under apps but if I type
>> appdesigner
at the command line, it opens.
Once opened, I am able to start dragging components and arranging them in design view. I seem to have full functionality in doing this.
When I switch to code-view however, the generated code is all on one line and since the first line is commented, none of it is used when run. Also I don't seem to be able to edit this code. (see below image and code at end)
Is this user error? How do I make my AppDesigner functional?
Thanks!
Sarah
The following is the code when trying to create a simple app like this: https://www.mathworks.com/help/matlab/creating_guis/create-and-run-a-simple-app-using-app-designer.html
It is all displayed on one line.
classdef App2 < matlab.apps.AppBase\n\n % Properties that correspond to app components\n properties (Access = public)\n UIFigure matlab.ui.Figure % UI Figure\n LabelSemicircularGauge matlab.ui.control.Label % Semici...\n SemicircularGauge matlab.ui.control.SemicircularGauge % [0 100]\n LabelSlider matlab.ui.control.Label % Slider\n Slider matlab.ui.control.Slider % [0 100]\n end\n\n methods (Access = private)\n\n % Code that executes after component creation\n function startupFcn(app)\n \n end\n\n % Slider value changed function\n function SliderValueChanged(app)\n value = app.Slider.Value;\n \n end\n end\n\n % App initialization and construction\n methods (Access = private)\n\n % Create UIFigure and components\n function createComponents(app)\n\n % Create UIFigure\n app.UIFigure = uifigure;\n app.UIFigure.Position = [100 100 640 480];\n app.UIFigure.Name = 'UI Figure';\n setAutoResize(app, app.UIFigure, true)\n\n % Create LabelSemicircularGauge\n app.LabelSemicircularGauge = uilabel(app.UIFigure);\n app.LabelSemicircularGauge.HorizontalAlignment = 'center';\n app.LabelSemicircularGauge.Position = [265 167 109 15];\n app.LabelSemicircularGauge.Text = 'Semicircular Gauge';\n\n % Create SemicircularGauge\n app.SemicircularGauge = uigauge(app.UIFigure, 'semicircular');\n app.SemicircularGauge.Position = [259 197 120 65];\n\n % Create LabelSlider\n app.LabelSlider = uilabel(app.UIFigure);\n app.LabelSlider.HorizontalAlignment = 'right';\n app.LabelSlider.Position = [212 323 33 15];\n app.LabelSlider.Text = 'Slider';\n\n % Create Slider\n app.Slider = uislider(app.UIFigure);\n app.Slider.ValueChangedFcn = createCallbackFcn(app, @SliderValueChanged);\n app.Slider.Position = [266 329 150 3];\n end\n end\n\n methods (Access = public)\n\n % Construct app\n function app = App2()\n\n % Create and configure components\n createComponents(app)\n\n % Register the app with App Designer\n registerApp(app, app.UIFigure)\n\n % Execute the startup function\n runStartupFcn(app, @startupFcn)\n\n if nargout == 0\n clear app\n end\n end\n\n % Code that executes before app deletion\n function delete(app)\n\n % Delete UIFigure when app is deleted\n delete(app.UIFigure)\n end\n end\nend

Akzeptierte Antwort

Prasanth Sunkara
Prasanth Sunkara am 20 Feb. 2018
Hi Sarah, I believe this could be due to corrupted paths. You can try the following commands to see if it solves the issue.
An now see if your app designer is working fine now. If this solves the issue, use 'savepath' command to confirm the settings .
Please note that App Designer wont appear in the APPS Tab of the MATLAB GUI.
Hope this helps!
-Prasanth

Weitere Antworten (0)

Kategorien

Mehr zu Develop Apps Using App Designer finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by