我希望输入的文本向左移动,但要做到这一点,无论是侧面还是锚点都可以这样做。我正在使用tkinter和python 3。
queue_frame = tk.Frame(master_frame)
queue_frame.pack()
queue_hash = tk.Label(queue_frame, text='#', width=3, font=('Arial', 14, 'bold'))
queue_hash.pack(side=tk.LEFT)
queue_name = tk.Label(queue_frame, text='Name', width=15, justify=tk.LEFT, font=('Arial', 14, 'bold'))
queue_name.pack(side=tk.LEFT)
queue_question_asked = tk.Label(queue_frame, text='Question Asked', width=25, font=('Arial', 14, 'bold'), justify=tk.LEFT)
queue_question_asked.pack(side=tk.LEFT)
queue_time = tk.Label(queue_frame, text='Time', width=15, font=('Arial', 14, 'bold'), justify=tk.LEFT)
queue_time.pack(side=tk.LEFT)
非常感谢您。
答案 0 :(得分:2)
此处引用了标签选项http://effbot.org/tkinterbook/label.htm
将锚与选项“ w”一起使用,如果您添加了救济=凸起,您将看到标签内文本的相对位置。
import tkinter as tk
master_frame = tk.Tk()
queue_frame = tk.Frame(master_frame)
queue_frame.pack()
queue_hash = tk.Label(queue_frame,
text='#',
width=3,
relief='raised')
queue_hash.pack(side=tk.LEFT)
queue_name = tk.Label(queue_frame,
text='Name',
width=15,
anchor='w',
relief='raised')
queue_name.pack(side=tk.LEFT)
queue_question_asked = tk.Label(queue_frame,
text='Question Asked',
width=25,
relief='raised',
anchor='w')
queue_question_asked.pack(side=tk.LEFT)
queue_time = tk.Label(queue_frame,
text='Time',
width=15,
relief='raised',
anchor='w')
queue_time.pack(side=tk.LEFT)
master_frame.mainloop()