当前位置: 代码迷 >> 综合 >> Python tkinter编程之Button_6 设置Button文本在控件上的显示位置
  详细解决方案

Python tkinter编程之Button_6 设置Button文本在控件上的显示位置

热度:98   发布时间:2024-01-26 07:30:08.0
# -*-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()

 

  相关解决方案