Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion Groups
Mathematics
General TopicsResearchOperations ResearchStatisticsMathematical LogicNumerical AnalysisUndergraduate MathAlgebra HelpRecreational Math
Math Software
MapleMathematicaMATLABScilabSASSPSS

Math Forum / Math Software / MATLAB / October 2008



Tip: Looking for answers? Try searching our database.

Passing handles between GUIs via a loaded file

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
William - 06 Oct 2008 07:46 GMT
Hi,

I have a GUI with pulldown menus and editable text boxes.  I am trying  to save the configuration of all the editable text boxes and pulldown menus to a file that can be loaded the next time the user wants to use the GUI.  

I can run the GUI properly if I start from scratch(All of the handles operate normally).  The problem is, when I rerun the GUI and load in the configuration file, I get an 'Invalid handle object' error.  Does anyone know a way to do this?

Currently, I am saving the handles structure from the previously open GUI into the configuration file.  I then reopen the GUI and load in the saved configuration file.  When the file is loaded, I am copying over the handles structure from the previously opened GUI.  I noticed that some of the numbers change slightly between the two handles (i.e. checkbox3 goes from 320.0040 to 320.0039).  Could this be causing the problem?  

Please let me know if you know a way to save the configuration and data of a GUI into a config file that can be loaded back into the GUI so the user can pick up where he/she left off.

Thanks!!

Bill King
Steven Lord - 06 Oct 2008 14:33 GMT
> Hi,
>
[quoted text clipped - 13 lines]
> the numbers change slightly between the two handles (i.e. checkbox3 goes
> from 320.0040 to 320.0039).  Could this be causing the problem?

I don't believe we state anywhere in the documentation that when a Handle
Graphics object is saved to a FIG-file and reloaded its handle will remain
the same.  Therefore I don't think you should make that assumption.
Instead, I'd key off the Tag property of the objects -- save the appropriate
data in a struct, then store those structs as fields of a main struct, with
the Tag of the object being the fieldname in the main struct.

For instance, if the main struct is saveddata, then saveddata.Pushbutton1
would be a struct containing the saved data for the object whose Tag is
Pushbutton1.

To restore the state, take advantage of the fact that this two-input form of
SET works:

   SET(H,a) where a is a structure whose field names are object
   property names, sets the properties named in each field name
   with the values contained in the structure.

set(handles.Pushbutton1, saveddata.Pushbutton1)

Signature

Steve Lord
slord@mathworks.com

William - 07 Oct 2008 04:32 GMT
Hi Steve,

Thanks for the quick reply!  Am I correct in thinking that the way to save the entire handles structure of a pop-up menu is with:

myStruct.popupmenu1 = get(handles.popupmenu1);

I have now saved each handles structure for all of the components of my GUI.  The problem I am seeing now, is that when I use the command:

set(handles.popupmenu1,myStruct.popupmenu1);

I get the following error:

Error using ==> set
Attempt to modify read-only uicontrol property: 'BeingDeleted'.

Is there something I need to disable to be able to copy the entire handles structure for each GUI component?

I also want to add that during the opening function of my main GUI, I copy the entire handles structure into a new structure called hFig_main (hFig_main = handles;).  I have two other GUIs which work along this one and they use the handles structures hFig_plot and hFig_output.  In my main GUI, the code above is actually:

myStruct.popupmenu1 = get(hFig_main.popupmenu1); and
set(hFig_main.popupmenu1,myStruct.popupmenu1);

Will this cause additional issues with copying the handles from each component.  My initial assumption is that it shouldn't cause issues.  I have been wrong many times before, however!

Thanks again for your help!!

Respectfully,
Bill King
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.