Re: Save/load values of text entry

From: SM Ryan (wyrmwif_at_tango-sierra-oscar-foxtrot-tango.fake.org)
Date: 09/07/04


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.


Relevant Pages

  • Re: ASM Cassette Images in TRS-80 Emulator
    ... David Keil's TRS-80 Model III/4/4P emulator. ... One of the progress asterisks changes to a C, and the load prematurely stops. ... Picking apart the *.CAS file that I was trying to load had initially suggested that the filename was "SPWAR" There is other data in the file, of course, but that plaintext seemed like a good guess. ...
    (comp.sys.tandy)
  • Re: Strange Failure Mode in FreeBSD 4.11
    ... # filename - will load the rules in the given filename ... I'm sure that if you put your custom rules in a shell file that you can use rc or cron to load those rules at boot time; you'd just need to be careful with rule numbering, maybe use ipfw sets for rule ordering, etc. ... Greg Barniskis, Computer Systems Integrator ...
    (freebsd-questions)
  • [DSPack]Rendering a 2nd video doesnt work on user pc, but fine on dev. pc
    ... The following code is designed to load a video. ... It works on the development pc but only the first time on the user pc. ... Folder + Filename are correct. ... StopPos:= ClipDuration; ...
    (borland.public.delphi.thirdpartytools.general)
  • Re: Assembly.Load() exception
    ... You did not specify the filename or you forgot to put the extention on the ... TestModule needs to have an extention. ... > This is throwing the following exception: ... > Could not load file or assembly ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Save/load values of text entry
    ... > I'm trying to write a little script with a GUI which offer to users to ... > not the fonction behind it. ... > saveState $filename Parameters ... I don't see an implementation of saveState. ...
    (comp.lang.tcl)