Programmatically add AppDesigner uicontrol
1 visualizzazione (ultimi 30 giorni)
Mostra commenti meno recenti
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?
0 Commenti
Risposte (2)
Sean de Wolski
il 6 Giu 2016
How's this?
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])
end
5 Commenti
Sean de Wolski
il 8 Giu 2016
You can add a property in the app that would be a structure that contains the buttons, you can then change that structure as you add buttons.
Arsalan jamialahmadi
il 6 Feb 2019
I have the same issue . I have created the structure and saved the handle inside the structure:
app.index=app.index+1;
c=uibutton(app.InterfaceTab);
app.a.b(app.index)=c;
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.
width=100;
app.a.b(app.index).Position(3)=width;
J. Webster
il 6 Giu 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.
2 Commenti
J. Webster
il 8 Giu 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.
Vedere anche
Categorie
Scopri di più su Migrate GUIDE Apps in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!