home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!haven.umd.edu!darwin.sura.net!spool.mu.edu!agate!darkstar.UCSC.EDU!helios.UCSC.EDU!de
- From: de@helios.UCSC.EDU (De Clarke)
- Newsgroups: comp.lang.tcl
- Subject: Tk/Wish beginner seeks advice on use of text widget
- Date: 12 Jan 1993 02:32:38 GMT
- Organization: UCO/Lick Observatory
- Lines: 55
- Message-ID: <1itak6INNqr2@darkstar.UCSC.EDU>
- NNTP-Posting-Host: helios.ucsc.edu
- Summary: variable scoping in wish scripts seems weird?
-
-
- I can't figure out why the tcl executed with the -command flag from
- a wish script will recognize some variables but not others.
- For example, when the "load" button is pressed (see below), although
- text has been entered in the text widget $w.bot.raval, I get a tcl
- error no such variable.
-
- sample code --------------
- .....
-
- text $w.bot.raval -width 8 -height 1 -relief raised -border 1
-
- pack append $w.bot $w.bot.raval {left}
-
- button $w.bot.load -text "load" -command \
- "set entry [${w.bot.raval} get 1.0 end]"
-
- .....
- ---------------------------
-
- Before I put the curlies around $w.bot.raval, tcl complained
- about "w" being undefined -- couldn't handle the dots in the var name.
- Tcl appears to be allergic to variable names containing "." whereas
- wish uses them routinely. [?]
-
- or take this example:
-
- button $w.bot.dismiss -text "go away" -command \
- "puts stdout $var1; puts stdout $var2; destroy $w"
-
- In this instance, var1 and var2 were correctly written to stdout,
- but window $w was not destroyed ("No such variable $w") -- however,
- when I split it into two buttons:
-
- button $w.bot.show -text "show" -command "puts stdout $var1; puts stdout $var2"
- button $w.bot.dismiss -text "go away" -command "destroy $w"
-
- then both buttons worked! So what is so different about three commands
- separated by semicolons vs one command on its own?
-
- Does anyone have a good theory about this? I'm perplexed.
-
- Or, alternatively, what is the best way in wish to prompt the user for a
- very short text entry (like an integer format i3 or whatever)...?
- And how can I get their input into a tcl variable without needing
- another button-push to do so? I can't find any example of this
- in the widget demos, though they cover almost everything else I
- would ever want to do.
-
- email please, I doubt that the whole world is fascinated by my
- dumb beginner questions.
- ..............................................................................
- : De Clarke, Computing Resources Mgr. UCO/Lick Observatory, UCSC :
- : de@helios.ucsc.edu | Due to budgetary shortfalls, the light at the end of :
- : de@portal.bitnet | the tunnel has been turned off. --Anon :
-