Programmatically add AppDesigner uicontrol
5 views (last 30 days)
Show older comments
Greg on 6 Jun 2016
Commented: Arsalan jamialahmadi on 6 Feb 2019
I have a CSV file with a list of m-files, and I want an AppDesigner GUI to have 1 button per m-file. Let's pretend all each button does is call "edit(mfile#)" for the appropriate number. Since all controls are explicit properties of the app, it gets very angry trying to create controls inside the startupFcn. It also does not seem to like using the GraphicsPlaceholder to pack multiple controls into a single app property.
I'm using a workaround that is effective for my current need, but might not be next time. I know the maximum number of m-files, and declaring an app property as a button doesn't actually create the button. So, I manually create the maximum properties, then fill as I read the CSV file.
Any other thoughts or suggestions?
Sean de Wolski on 6 Jun 2016
fig = uifigure;
panel = uipanel(fig,'Position',[1 1 500 500]);
bg = uibuttongroup(panel,'Position', [50 50 100 500]);
n = 10;
g = gobjects(n,1);
for ii = 1:n
uibutton('Parent',bg,'Position',[10 ii*30 50 30])
Arsalan jamialahmadi on 6 Feb 2019
I have the same issue . I have created the structure and saved the handle inside the structure:
But now there is no way to call the stored handle. Following code gives error:
Error: Unable to perform assignment because dot indexing is not supported for variables of this type.
J. Webster on 6 Jun 2016
Instead of generating buttons, I think it would be better to populate a Drop Down with the names of the files, and open them that way, either on a selection changed callback, or with a separate button that opens the file based on the current selected value.
Generating buttons on the fly is generally never done for a reason.
J. Webster on 8 Jun 2016
functionally of course they'd be the same. The main issue for me is layout. I suppose if you know you'll never have more than a few buttons, it may not be a big deal. But what if you have 15? 33? or more? Obviously it could be problematic.
Also, how do you generate the callbacks for when the buttons are pressed?
I understand about customers and all, but this is just a really bad way to do it.
Find more on Develop Apps Using App Designer in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!Start Hunting!