2
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

TclAdvent Calendar 2018

Day 3

Tcl/TkでHello, world!

Last updated at Posted at 2018-12-02

Tk編

タイトルでHello, world!

hello.tcl
wm title . "Hello, world!"

よくあるHello, world!

hello.tcl
pack [label .l -text "Hello, world!"]

細切れにHello, world!

hello.tcl
set buffer "Hello, world!"
set length [string length $buffer]
for {set i 0} {$i < $length} {incr i} {
	lappend labels [label .l$i -text [string index $buffer $i]]
}
grid {*}$labels

ボタンを押したらHello, world!

hello.tcl
pack [button .b -text click! -command [list tk_messageBox -message "Hello, world!"]]

ダブルクリックでHello, world!

hello.tcl
pack [label .l -textvariable buffer]
bind . <Double-1> [list set buffer "Hello, world!"]

ちょっと遅れてHello, world!

hello.tcl
pack [label .l -textvariable buffer]
after 3000 [list set buffer "Hello, world!"]

閉じようとしたらHello, world!

hello.tcl
bind . <Destroy> [list tk_messageBox -message "Hello, world!"]
2
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?