Posted to tcl by kbk at Thu Feb 22 17:56:48 GMT 2007view pretty

# In production code, I'd 'wm title', 'wm style' etc to make the dialog
# look spiffy, but you're concerned with geometry management. I'd also
# add some bindings so that <Key-Return> would trigger the 'OK' action, and
# so on.

package require Tk
package require msgcat
namespace import msgcat::mc

toplevel .pwdialog

frame .pwdialog.body
label .pwdialog.body.l1 -text [mc "User ID:"]
entry .pwdialog.body.e1 -width 12 -textvariable userID -exportselection false
label .pwdialog.body.l2 -text [mc "Password:"]
entry .pwdialog.body.e2 -textvariable password -width 12 \
    -exportselection false -show \u2022
grid .pwdialog.body.l1 -row 0 -column 0 -sticky e
grid .pwdialog.body.l2 -row 1 -column 0 -sticky e
grid .pwdialog.body.e1 -row 0 -column 1 -sticky ew
grid .pwdialog.body.e2 -row 1 -column 1 -sticky ew
grid columnconfigure .pwdialog.body 1 -weight 1

frame .pwdialog.buttons
button .pwdialog.buttons.ok -text [mc OK] -command authenticate
button .pwdialog.buttons.cancel -text [mc Camcel] \
    -command [list destroy .pwdialog]

grid .pwdialog.buttons.ok .pwdialog.buttons.cancel -pady 10 -padx 10 -sticky ew
grid columnconfigure .pwdialog.buttons {0 1} -uniform A

grid .pwdialog.body -padx 10 -pady 10
grid .pwdialog.buttons