- Parent: you'll need to assign the app's figure or a uipanel or uitab in your app as the parent of the component
- Position: You'll need to set the component's position within the app - this is the main benefit of designing the layout within AppDesigner rather than doing so programmatically. Consider using a Grid Layout Manager.
- Property management: You'll need to store the handle to the added components somehwere within the app so the handles are accessible within the app.
AppDesigner / GUIDE: generate unknown number of new GUI elements as a function
1 view (last 30 days)
is there a way for the user to create new gui-elements, while the developed application is actually running?
- The application shows an Import button
- each time the user presses the import button, a new set of gui elements is created and their callback functions can be executed
I have an application (created with GUIDE and later compiled) that handles sensor data. The user sometimes only has 1 sensor but sometimes more sensors to analyze (e.g. up to 16). For each sensor, it requires a set of gui elements (and callback functions) that manages/displays sensor properties.
Currrently I need to provide all 16 sets of gui elements in order to support 16 sensors... if i want to support 20 sensors i would need to create new sets of gui elements and fill their callback functions with life.
My question is if I can automatically create the set of gui elements
and then another set
up to set
and assign a function to the accoring callback function. such as
- editbox_x_callback (that always calls the function "editbox_function"), where x could be any number
function editbox_x_callback(hObject, eventdata, handles)
Adam Danz on 9 Nov 2022
Edited: Adam Danz on 10 Nov 2022
Your quesiton specifies AppDesigner and GUIDE but don't use GUIDE since it will be removed in a future release.
Yes, you can programmatically add components to your app in AppDesigner.
App Components have their own functions that you can use to add them to a figure. Example: uicheckbox; Check out the Component Library for reference to other ui components.
But it's not necessarily the best idea
Dynamic components may lead to inconsistencies to the user experience of your app. How did I enter this data last time, where did that component go? It may be difficult for you, as an analyst, to understand where the user's data came from.
An alternative would be to set up a tab group or a set of uipanels that contain all of the possible components but control their enable-state of visible-state as needed. This way, all components already exist, they are positioned within App Designer, and you'll avoid the snags listed in the bullet points above.