Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

clock

Status
Not open for further replies.

turtlejack

Technical User
Jan 25, 2005
26
US
I am wanting the time to appear when ya press the button.
whats wrong with this code?

button .b -text "press button for time" -command [clock format [clock seconds]]
pack .b
 
actually,I would like for the text to change to the time upon pressing the button
 
If you want to change the system time, you need to use the "exec" command. That makes it system dependant. What is the syntax for changing the time on your system?

Bob Rashkin
rrashkin@csc.com
 
actually what I want to happen, is when I depress the button that displays "press button for time",I want the time to appear in its place.
 
Ah. You use "configure" for that. Here's what I would do, starting from what you have:

button .b -text "press button for time" -command [red]btime[/red]
pack .b
[red]proc btime {} {
set tnow [clock seconds]
set tstr [clock format $tnow -format "%x %T"]
.b configure -text $tstr
}
[/red]


Bob Rashkin
rrashkin@csc.com
 
thank you soo much,it works great.any super great online tutorials for beginners?I have read some...but,always interested in more.
 
I don't know of any for Tcl, itself, other than the help pages that come with the installation. I find them to be very instructive. As for Tk, I recommend the demos that are installed with ActiveState. You can look at all the code that runs them.

Bob Rashkin
rrashkin@csc.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top