wish main window...
- From: "sunos.x86@xxxxxxxxx" <sunos.x86@xxxxxxxxx>
- Date: 6 Oct 2005 15:05:34 -0700
hello all...
I'm new to tk, and i need a little application, that just ask to the
user the name of the workstation. I have the code that follows, but
when i did run the code, two windows are showed. One of then is blank.
I want just the window that asks the question. :)
Thanks.
The code:
#!/bin/sh
# \
exec wish8.4 "$0" ${1+"$@"}
proc Dialog_Create {top title args} {
global dialog
if [winfo exists $top] {
switch -- [wm state $top] {
normal {
# Raise a buried window
raise $top
}
withdrawn -
iconic {
# Open and restore geometry
wm deiconify $top
catch {wm geometry $top
$dialog(geo,$top)}
}
}
return 0
} else {
eval {toplevel $top} $args
wm title $top $title
return 1
}
}
proc Dialog_Wait {top varName {focus {}}} {
upvar $varName var
# Poke the variable if the user nukes the window
bind $top <Destroy> [list set $varName cancel]
# Grab focus for the dialog
if {[string length $focus] == 0} {
set focus $top
}
set old [focus -displayof $top]
focus $focus
catch {tkwait visibility $top}
catch {grab $top}
# Wait for the dialog to complete
tkwait variable $varName
catch {grab release $top}
focus $old
}
proc Dialog_Dismiss {top} {
global dialog
# Save current size and position
catch {
# window may have been deleted
set dialog(geo,$top) [wm geometry $top]
wm withdraw $top
}
}
proc Dialog_Prompt { string } {
global prompt
set f .prompt
if [Dialog_Create $f "Identificação da Estação"
-borderwidth 10] {
message $f.msg -text $string -aspect 1000
entry $f.entry -textvariable prompt(result)
set b [frame $f.buttons]
pack $f.msg $f.entry $f.buttons -side top -fill x
pack $f.entry -pady 5
button $b.ok -text OK -command {set prompt(ok) 1}
pack $b.ok
bind $f.entry <Return> {set prompt(ok) 1 ; break}
bind $f.entry <Control-c> {set prompt(ok) 0 ; break}
}
set prompt(ok) 0
Dialog_Wait $f prompt(ok) $f.entry
Dialog_Dismiss $f
if {$prompt(ok)} {
return $prompt(result)
} else {
return {}
}
}
set estacao [ Dialog_Prompt "Digite o nome da Estação:" ]
puts $estacao
exit 0
.
- Follow-Ups:
- Re: wish main window...
- From: Jeff Godfrey
- Re: wish main window...
- Prev by Date: Re: Loading tk84.dll dynamically (on Windows boxes)
- Next by Date: Re: wish main window...
- Previous by thread: Embedding Files in a starpack/starkit...
- Next by thread: Re: wish main window...
- Index(es):