Re: Save/load values of text entry
From: SM Ryan (wyrmwif_at_tango-sierra-oscar-foxtrot-tango.fake.org)
Date: 09/07/04
- Next message: R. Dale Thomas: "Re: Pipe command output to listbox"
- Previous message: Kurt Sierens: "Building tktreectrl on windows"
- In reply to: Varno: "Save/load values of text entry"
- Next in thread: Chris Nelson: "Re: Save/load values of text entry"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Tue, 07 Sep 2004 18:00:52 -0000
"Varno" <alexis.dubois@autoliv.com> wrote:
# Hello all,
#
# I'm trying to write a little script with a GUI which offer to users to
# enter some values and generate a formated text file with these values.
# My problem is the following: some users want me to create a load/save menu
# to be able to save set of values and to use it later. The menu is ok but
# not the fonction behind it.
#
# I've try to do it like this (save fonction)
#
# set filename [tk_getSaveFile -parent .top43 -title {Save a configuration
# file...}
# ]
#
# array set Parameters {x 4 y 5 z 6}
# set filex {file exist $filename}
# if { $filex == 1 } {
# file delete $filename
# } else {
# saveState $filename Parameters
# }
#
# This is ok and it generate a file which contains the string "x 4 y 5 z 6"
# but I want the values of my text entry to be written instead of this
# string. But I don't know how to do...
# And the other problem is that I can't load this generated file...(x, y and
# z are real name of some of my variables)
If you want to write the characters of a text widget, you should be able to do
something like
set channel [open .... w]
puts -nonewline $channel [.text get 1.0 end]
close $channel
and load with
set channel [open .... r]
.text delete 1.0 end
.text insert 1.0 [read -nonewline $channel]
close $channel
You can also save tags with a bit cleverness and [.text dump ....]
An entry widget is similar
set channel [open .... w]
puts $channel [.entry get]
close $channel
and load with
set channel [open .... r]
.entry delete 0 end
.entry insert 0 [read $channel]
close $channel
-- SM Ryan http://www.rawbw.com/~wyrmwif/ I love the smell of commerce in the morning.
- Next message: R. Dale Thomas: "Re: Pipe command output to listbox"
- Previous message: Kurt Sierens: "Building tktreectrl on windows"
- In reply to: Varno: "Save/load values of text entry"
- Next in thread: Chris Nelson: "Re: Save/load values of text entry"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|