#!/bin/sh
# bttn3.tcl \
exec tclsh "$0" ${1+"$@"}
proc push_button {} {
global age
set name [.ent get]
.txt insert end "Hello $name,\n You are $age years old."
}
#Globle Variables
set age 10
#GUI building
frame .frm -background yellow -borderwidth 5 -relief flat ;
label .lab -text "Enter name:"
entry .ent
button .but -text "push Me" -command "push_button"
#age
scale .scl -label "Age :" -orient h -digit 2 -from 0 -to 50 -variable age -tickinterval 50
#Text Area
frame .textarea -background red -borderwidth 2
text .txt -yscrollcommand ".srl_y set" -xscrollcommand ".srl_x set" -width 50 -height 10
scrollbar .srl_y -command ".txt yview" -orient v
scrollbar .srl_x -command ".txt xview" -orient h
#Geometry Management
pack .lab -in .frm
pack .ent -in .frm
pack .frm
pack .scl
pack .but
grid .txt -in .textarea -row 1 -column 1
grid .srl_y -in .textarea -row 1 -column 2 -sticky ns
grid .srl_x -in .textarea -row 2 -column 1 -sticky ew
pack .textarea
# bttn3.tcl \
exec tclsh "$0" ${1+"$@"}
proc push_button {} {
global age
set name [.ent get]
.txt insert end "Hello $name,\n You are $age years old."
}
#Globle Variables
set age 10
#GUI building
frame .frm -background yellow -borderwidth 5 -relief flat ;
label .lab -text "Enter name:"
entry .ent
button .but -text "push Me" -command "push_button"
#age
scale .scl -label "Age :" -orient h -digit 2 -from 0 -to 50 -variable age -tickinterval 50
#Text Area
frame .textarea -background red -borderwidth 2
text .txt -yscrollcommand ".srl_y set" -xscrollcommand ".srl_x set" -width 50 -height 10
scrollbar .srl_y -command ".txt yview" -orient v
scrollbar .srl_x -command ".txt xview" -orient h
#Geometry Management
pack .lab -in .frm
pack .ent -in .frm
pack .frm
pack .scl
pack .but
grid .txt -in .textarea -row 1 -column 1
grid .srl_y -in .textarea -row 1 -column 2 -sticky ns
grid .srl_x -in .textarea -row 2 -column 1 -sticky ew
pack .textarea
just change ns --> ne and ew ---> sw , then you can figure out what actually 'sticky' command does
ReplyDelete