How to create a GUI with changing buttons?
조회 수: 2 (최근 30일)
이전 댓글 표시
Good morning,
I am looking for a possibility to create a GUI (with GUIDE, if possible) with changing buttons. This means, that the GUI offers two seperate bundles of functions and I would like the user to choose at the beginning which bundle to use and the other bundle to disappear, to fold up, or something similar.
Does anybody know how to do this?
Thank you!
(P.s.: I am still working with Matlab R2007b and I don't have to possibility to upgrade)
댓글 수: 6
Adam
2019년 10월 17일
You can add programmatic components to panels that you lay out as placeholders in GUIDE. You can't put GUIDE components inside programmatic ones though, only the other way round. So you can have a mostly GUIDE-based GUI in which you put an empty panel (for which you can turn off border, etc if you wish, to make it invisible).
Then in your code you can use this panel as a parent for whatever you want to do programmatically, including tabbed panels, layouts, java components, or anything you wish.
답변 (1개)
CAM
2019년 10월 17일
Another possibility is to use the same set of buttons for both options, but assign associated properties (String label) within the OpeningFcn. You can do this with a separate mat-file that holds a table (or cell array) of settings for each button and bundle option. (Table columns: [Option1], [Option2], ... . Table rows: button1Label, button1FcnHandle, button2Label, ...).
OpeningFcn: Load the file. Ask the user for their bundle choice. Create a "subtable" of the settings based on the bundle choice. Save the subtable to the UserData property of one of the objects (or guidata or appdata). Assign the button labels from the subtable.
When the user clicks a button, read the subtable from UserData. Look up its function handle (@MyFcnHandleName) for that button in the subtable and run it.
fhAnalysis = str2func(tblWorking(button2FcnHandle));
[output] = fhAnalysis(inputs);
댓글 수: 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!