# -*-coding:utf-8-*-
#设置Button文本在控件上的显示位置
'''
anchor:指定组件的位置,可用的值为:
n(north)
s(south)
w(west)
e(east)
和
ne(north east)
nw(north west)
se(south east)
sw(south west)
'''
from tkinter import *
root = Tk()
for a in ['n', 's', 'e', 'w', 'ne', 'nw', 'se', 'sw']:
Button(root, text = 'anchor', anchor = a, width = 30, height = 4).pack()
root.mainloop()
本文展示了一个使用Tkinter库创建GUI应用程序的例子,通过不同锚点设置,演示了按钮在窗口中的八种定位方式,包括'n'、's'、'e'、'w'、'ne'、'nw'、'se'和'sw'。
1万+

被折叠的 条评论
为什么被折叠?



