python模块tkinter的widget讲解

demo
原文

1. options

1
2
3
4
5
6
val = cget(“option”) => string
config(option=value, …)
configure(option=value, …)
val = elem["option"]
elem["option"] = "value"
button = Button(frame, {"text": "QUIT", "fg": "red", "command": frame.quit})

2. print the method and options

1
2
print (elem.keys())
print (dir(elem))

3. styling

1
2
rgb = widget.winfo_rgb("red")
red, green, blue = rgb[0]/256, rgb[1]/256, rgb[2]/256

3. fonts

1
2
3
4
5
6
7
8
9
10
11
("Times", 10, "bold")
("Helvetica", 10, "bold italic")
("Symbol", 8)
"Times 10 bold"
"Helvetica 10 bold italic"
"Symbol 8"
# tkFont module
tkFont.Font(family="Times", size=10, weight=tkFont.BOLD)
tkFont.Font(family="Helvetica", size=10, weight=tkFont.BOLD,
slant=tkFont.ITALIC)
tkFont.Font(family="Symbol", size=8)

4. Text Formatting

1
2
justify = # option to LEFT or RIGHT. The default value is CENTER.
wraplength = # option to set a maximum width,

1. border

1
2
3
4
5
6
borderwidth (or bd)
relief = # SUNKEN, RAISED, GROOVE, RIDGE, and FLAT.
# Focus Highlights #
highlightcolor
highlightbackground
highlightthickness

1. cursor

1
2

×

纯属好玩

扫码支持
扫码打赏,你说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

文章目录
  1. 1. 1. options
  2. 2. 2. print the method and options
  3. 3. 3. styling
  4. 4. 3. fonts
  5. 5. 4. Text Formatting
  6. 6. 1. border
  7. 7. 1. cursor
,