Save / Load Gui handles

11 visualizaciones (últimos 30 días)
Pablo Jeken Rico
Pablo Jeken Rico el 16 de Jul. de 2018
Comentada: Pablo Jeken Rico el 30 de Nov. de 2018
Hi, I have written a GUI (guide) with lots of buttons and settings. I want to save the states and load them with the same gui. Unaffortunately if I save handles and load it, a new figure (or several figures) with the settings appear. How can I avoid it?
I also noticed, that the structure I load into the gui is written into the workspace after the callback is completed. The gui just recognises the struct as an empty struct.
Save state (inside save button Callback)
seq = handles;
save(filename,'seq');
end
Load state (inside load button callback)
seq = matfile(filename,'Writable',true);
handles = setSequency(hObject,handles,seq); % Sees seq as an empty struct
end
  2 comentarios
Marc Youcef
Marc Youcef el 27 de Nov. de 2018
Same problem here as well. I would like to avoid having to get data from all GUI components using get function, store them, then load them and fill all the GUI components with set function.
Ideally I would like to do as you but I save it into .MAT file and it is able to load then the GUI but I lose any link with my main program.
Any help is appreciated.
Thanks.
Marc.
Luna
Luna el 27 de Nov. de 2018
Hi There! Same problem for me too!.
I have asked a similar question with my codes are attached below link.
It is a small app which adds people and their information to the table by a small settings window. After adding some people rows, I click on a table row then click edit button, I want to get the same settings window filled with corresponding user informations.
I have a lot of popup menu's, so each time set all and calculate popup menu's index and assign the value causes too much complexity.
There should be an easy way to save it like a screenshot. Any help is appreciated!!
Thank you!

Iniciar sesión para comentar.

Respuesta aceptada

Marc Youcef
Marc Youcef el 30 de Nov. de 2018
Hi, after a long discussion with Mathworks support, it seems that there is no ways to save/load a figure handle directly and still access to the main output call of the UI like : Output=MyUI(SavedHandle).
You have to write loops to save each and every variable from your GUI into a MAT file and then load them to finally set again each and every control from your GUI to the loaded variable.
Not convenient at all.
  2 comentarios
Luna
Luna el 30 de Nov. de 2018
Yes, exactly I have searched that aswell and there is no easy way to do it.
Faster and easiest way is creating the array of ui elements and assign the values with a for loop.
But most of the times ui elements styles will be different so this can create a complexity.
Pablo Jeken Rico
Pablo Jeken Rico el 30 de Nov. de 2018
I think this could be a nice improvement to GUIs...

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Migrate GUIDE Apps en Help Center y File Exchange.

Productos


Versión

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by