Clear Filters
Clear Filters


This question is closed. Reopen it to edit or answer.

Strange behavior of GUI with GUIDE

1 view (last 30 days)
Julien on 26 Sep 2013
Closed: MATLAB Answer Bot on 20 Aug 2021
I'm trying to build a GUI by combining GUIDE and the GUI Layout Toolbox. I would like to build a multitab GUI very quickly, but with a large amount of components. It takes a long time to write the code, and I would like to focus on the callback's and not on the components positionning.
To do so, I found a way that could work :
  • build each tab content wrapped in a panel in separate GUIDE figure,
  • write a main script that open figures in invisible mode
  • add the panels in each tabs
The process is working well if we take care to change units of all components to "normalized" (it is also a tip to resize easyly GUI's created with GUIDE)
For the moment I see three ways to do this : In the following code, create_Pipe is a nested function that opens the fig PipePanel created with GUIDE, get the handles structure A
  • 1) generate the mfile that include the handles of each components and use copyobj(panel,tab).
function create_Pipe()
  • 2) Change the Parent of the panel:
function create_Pipe()
It works, my components (all children of the panel) are well transferred, I have acces to all components properties with struc A.
But when I close and reload, it doesent work (invalid object/handles)
When I launch PipePanel with the code of GUIDE, nothings appears. When I reload GUIDE, all become OK
I really don't understand what happens !
  • 3) Generate only the figure, and retrieve all components using findobj. It works but not the more efficient way
Do you have any Idea about the bug, or an other solution to import components with handles ?
Thank you in advance

Answers (1)

Julien on 26 Sep 2013
I found a solution, it seems well working. It could be a process to create multitab GUI's with GUIDE.
  • - Put all the components of the tab wrapped in a panel within GUIDE
  • - Place the components as you want and change all the units to "normalized"
  • - Create a new figure with a tabpanel container (the same size of your panel is better. If you put all to normalized, all components will keep the defined ratio)
  • - open in invisible mode the GUI figure corresponding to the current tab,
  • - copy the main panel object and set the tab panel as the new parent (copyobj)
Now we need to retrieve all components handles to acces their properties. this can be done with a simple function:
function handles=childHandles(hParent)
%Find all the children handles
%Find all the children name defined within GUIDE
%Create a new handle structure
for i=1:length(handVal)
this will output a new handles structure of all cloned components.
I don't know if there is most simple solution, but it is a good way for me to save time when building complex GUI. (GUI Layout is very usefull, but the number of command lines become veeeery long when you have a lot of components). If somebody is interresed by a complete example, I could provide one on file exchange when I will have some free time.
  1 Comment
Julien on 26 Sep 2013
I precise that you will need to download the great GUI Layout toolbox on file exchange to acces tabpanels: GUI Layout toolbox

This question is closed.


Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!