- 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
조회 수: 2 (최근 30일)
이전 댓글 표시
Dear experts,
is there a way for the user to create new gui-elements, while the developed application is actually running?
For example:
- 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
Background:
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
- editbox_1
- popupmenu_1
- checkbox_1
and then another set
- editbox_2
- popupmenu_2
- checkbox_2
up to set
- editbox_x
- popupmenu_x
- checkbox_x
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)
editbox_function()
end
댓글 수: 0
채택된 답변
Adam Danz
2022년 11월 9일
편집: Adam Danz
2022년 11월 10일
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.
Some considerations
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.
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Migrate GUIDE Apps에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!