saving state via

From: Kevin Ready (kready_at_taec.toshiba.com)
Date: 02/20/04


Date: 19 Feb 2004 15:48:05 -0800

Hello tcl'ers--

I am trying to find a 'best practice' method for saving / loading
widget states in a tcl/tk application. My application will have
several hundred related entry boxes, combo boxes etc., so I am looking
for a way of iterating through my toplevel window's child objects and
saving my application state as an array:
######################################################
### Current unsatisfactory strategy
### SAVE ARRAY BY BRUTE FORCE
######################################################
###SAVE ARRAY
...
 array set myGlobals [list {cbSPC0} [Toplevel1 setvar cbSPC0]
{cbSPC1} [Toplevel1 setvar cbSPC1] {cbSPC2} [Toplevel1 setvar cbSPC2]
 ]###List out all variables in application by hand.
}
...
###LOAD ARRAY
source $filename
foreach id [array names myGlobals] {
               Toplevel1 setvar $id $myGlobals($id)
}
######################################################

I found this post, which suggests a method of fetching your windows
children, but I have not been able to get it to work--I always get
"bad window path name" no matter what I pass in to it.

From: Roy Terry (royterry@earthlink.net)
Subject: Re: tcl/tk:saving state of widgets??
Newsgroups: comp.lang.tcl
Date: 2002-02-01 21:31:22 PST

...
proc wfind {{win .}} {
 set out $win
 foreach w [lsort -dictionary [winfo children $win]] {
  lappend out " [wfind $w]"
 } return $out
...

Can anybody suggest an alternative method of fetching a list of
widgets and values and saving them?

Kevin Ready
Toshiba America Electronics Components - STI Design Center
Austin, Texas



Relevant Pages

  • Problem when switching from SoapClient to WebServicesClientProtocol
    ... I have a working C# class library that acts as a soap client. ... over the formatting of the soap body: ... It all boils down to the "this.invoke" method requiring an object array ... //populate the test widgets array ...
    (microsoft.public.dotnet.framework.webservices.enhancements)
  • array of Tkinter variables?
    ... I was hoping that I could use an array ... of StringVar variables to attach to these widgets, ... The University of Texas at Austin ...
    (comp.lang.python)
  • Re: Saving configuration options from POST data
    ... Some of them should be parsed before saving to file. ... Fields names have no prefix and are equal to $cfg array's indexes. ... Saving data: ... Array: ...
    (comp.lang.php)
  • Re: Class in a Class
    ... Because a strongly typed collection of Nodes is NOT a LinkedList! ... an array of Widgets ... allowing you to create strongly typed linked lists! ...
    (microsoft.public.dotnet.languages.vb)
  • Re: ttk::checkbutton - I think, its a bug
    ... value for those widgets that implement the getter. ... linked to an array entry (with a dedicated array for ... for a long time whereby it basically did not work ...
    (comp.lang.tcl)