【发布时间】:2020-11-14 14:16:46
【问题描述】:
box 的左侧与some_label 的左侧对齐。我无法设置宽度,使some_label 的右侧也与box 的右侧对齐,因为不同宽度值之间的增量太大。 35 的width 使some_label 的右端太靠左,而 36 的width 使其太靠右。
from tkinter import *
root = Tk()
root.geometry('500x500')
box = Frame(root, width=383, height=246, bg='black')
box.place(x=241, y=65, anchor=CENTER)
some_label = Label(root, text='Some Label', borderwidth=1, relief='solid')
some_label.place(x=50, y=210)
some_label.config(width=35, font=('TkDefaultFont', 15)) # whether width is 35 or 36, the label never aligns with the box
mainloop()
【问题讨论】:
标签: python tkinter widget label width