如何使用Python Tkinter在一行中显示多个标签?

问题描述 投票:1回答:1

enter image description here我有一个程序可以在带有多个标签的GUI屏幕上显示文本。但是所有标签都在新行中显示文本,我想在单行中显示文本。代码如下:

from tkinter import *
import tkinter as tk

win = Tk()
win.title("Label Screen")
win.geometry("800x600+50+50")
win.config(bg='white')

label1=Label(win, text="Label 1", font=("Calibri",24,"bold"), bg='white')
label1.pack(pady=15)

label2=Label(win, text="Label 2", font=("Calibri",24,"bold"), bg='white')
label2.pack(pady=15)

label3=Label(win, text="Label 3", font=("Calibri",24,"bold"), bg='white')
label3.pack(pady=15)

win.mainloop()
python tkinter label
1个回答
0
投票

执行此操作:

label1.pack(side=tk.Left,pady=15)
label2.pack(side=tk.Left,pady=15)
label3.pack(side=tk.Left,pady=15)

进一步阅读:https://effbot.org/tkinterbook/pack.htm

© www.soinside.com 2019 - 2024. All rights reserved.