Python.use(better,Tkinter)《余録》Example 26-6
|記事一覧|
Python.use(better, Tkinter)
Example 26-6 《Python3.1》
《著》森こねこ・小粒ちゃん+∞《監修》小泉ひよ子とタマゴ倶楽部
第0版♪1993/11/25 ● 第1版♪2006/10/28
〓 Example 26-6:Tcl/Tk 版
Practical Programming in Tcl and Tk
- 作者: Brent Jones, Ken Welch
- 出版社/メーカー: Prentice Hall
- 発売日: 2003/06/10
- メディア: ペーパーバック
- クリック: 3回
- この商品を含むブログ (5件) を見る
# # Example 26-6 # All combinations of -sticky settings. # set index 0 foreach x {news ns ew " " new sew wsn esn nw ne sw se n s w e} { frame .f$x -borderwidth 2 -relief ridge -width 40 -height 40 grid .f$x -sticky news \ -row [expr $index/4] -column [expr $index%4] label .l$x -text $x -background white grid .l$x -sticky $x -padx 2 -pady 2 \ -row [expr $index/4] -column [expr $index%4] incr index }
〓 Example 26-6:Python 版
同等のコードを Python で記述すると、次のようになります。
>>> ex_sticky()
from tkinter import * def ex_sticky(): root = Tk() root.title("Ex26-6: sticky settings") root.geometry("240x240") wh = 50; bw = 2 for index, x in enumerate(powerset("NEWS")): ry, cx = index//4, index%4 w = Frame(root, borderwidth=bd, relief=RIDGE, width=wh, height=wh, bg="cyan", ) w.grid(sticky="NEWS", row=ry, column=cx) w = Label(root, text=x) w.grid(sticky=x, padx=bd, pady=bd, row=ry, column=cx) root.mainloop()
Last updated♪2009/08/25