Reputation: 23
I want to run following tcl/tk code in single window, but when I run the below using wish yep.tcl
it opens two windows as in picture below. I want only one window i.e okie
What changes are required?
proc yep {} {
toplevel .t
wm geometry .t 300x200-5+40
wm title .t "okie"
label .t.n -text "CELL"
grid .t.n -rowspan 2 -columnspan 5
}
yep
Upvotes: 1
Views: 273
Reputation: 137567
You're creating another toplevel window, .t
, in addition to the default one called .
. To work with only a single window, either use the default one or withdraw the default one.
proc yep {} {
wm geometry . 300x200-5+40
wm title . "okie"
label .n -text "CELL"
grid .n -rowspan 2 -columnspan 5
}
yep
proc yep {} {
toplevel .t
wm geometry .t 300x200-5+40
wm title .t "okie"
label .t.n -text "CELL"
grid .t.n -rowspan 2 -columnspan 5
# Hide the unwanted window
wm withdraw .
# Make the application go away when we close the visible window
wm protocol .t WM_DELETE_WINDOW { exit }
}
yep
Upvotes: 2
Reputation: 13252
The command toplevel
creates an extra window. If you just want to use the main window, skip the invocation of toplevel
and use .
instead of .t
. (.t.n
becomes .n
, of course.)
Upvotes: 1