tk again (question)

Peter L. Peres plp-ysDPMY98cNQDDBjDh4tngg at public.gmane.org
Mon Mar 1 19:46:55 UTC 2004


Thanks, excellent answer ! I could not locate that info until now. See
below for more:

On Mon, 1 Mar 2004, Tim Writer wrote:

--snip--
>
> The format of the list returned by itemconfigure is documented (more or less)
> by "man Tk_ConfigureInfo".  This should help:
>
>     # This first part is identical to your script
>     set c .c
>     canvas $c
>     pack $c
>     $c create rectangle 10 10 20 20 -fill blue -tags {one two}
>     set o [$c itemconfigure 1]
>
>     # Now create a script to create another rectangle with same attributes
>     set script [list $c create rectangle 30 30 40 40]
>     foreach configSpec $o {
>         foreach {argvName dbName dbClass defValue curValue} $configSpec {}
>         lappend script $argvName $curValue
>     }
>
>     # Create new rectangle
>     eval $script

This is clear. Now I understand that I only need to record those options
which are different from default to recreate the options, so I could
write:

	...
	foreach configSpec $o {
		foreach {argvName dbName dbClass defValue curValue} \
			$configSpec {} {

			# not sure about != {} or != "" - should be the same
			if {($curValue != {}) && ($defValue != $curValue)} {
				lappend script $argvName $curValue
			}
		}
	}

Nice!

thanks again,

Peter
--
The Toronto Linux Users Group.      Meetings: http://tlug.ss.org
TLUG requests: Linux topics, No HTML, wrap text below 80 columns
How to UNSUBSCRIBE: http://tlug.ss.org/subscribe.shtml





More information about the Legacy mailing list