Sujet : Re: I am failing to get a hide/show dialog to show more than once
De : ralfixx (at) *nospam* gmx.de (Ralf Fassel)
Groupes : comp.lang.tclDate : 27. Jun 2024, 09:46:39
Autres entêtes
Message-ID : <ygav81uu61c.fsf@akutech.de>
References : 1 2 3
User-Agent : Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux)
* Mark Summerfield <
mark@qtrac.eu>
| proc test::on_options {} {
| if {![winfo exists .optionsForm]} {
| puts "on_options init"
| toplevel .optionsForm
| set on_close [lambda {} {dialog hide .optionsForm}]
| wm title .optionsForm "Options — [tk appname]"
--<snip-snip>--
I make a habit of putting the layout of any widget structure in
variables, so if I decide to add another frame or toplevel or whatever,
I just need to change the variables and leave the rest of the code
unchanged:
proc test::on_options {} {
set w(optionsForm) .optionsForm
set w(optionsLabel) $w(optionsForm).label
set w(optionsClose) $w(optionsForm).closeButton
if {![winfo exists $w(optionsForm)]} {
puts "on_options init"
toplevel $w(optionsForm)
set on_close [lambda {} [list dialog hide $w(optionsForm)]]
wm title $w(optionsForm) "Options — [tk appname]"
ttk::label $w(optionsLabel) -text "Options go here"
grid $w(optionsLabel) -row 0 -column 0
ttk::button $w(optionsClose) -text Close -command $on_close
grid $w(optionsClose) -row 1 -column 0
...
Say I need the options frame as child of a different widget than ".",
I could just change the proc to
proc test::on_options {top} {
set w(optionsForm) $top.optionsForm
...
and be done.
HTH
R'