import tkinter as tk
chuangkou=tk.Tk()
chuangkou.title("我的GUI")
sw=chuangkou.winfo_screenwidth()
sh=chuangkou.winfo_screenheight()
sw_=(sw-400)/2
sh_=(sh-350)/2
chuangkou.geometry("400x350+{:.0f}+{:.0f}".format(sw_,sh_))
**#label**
label1=tk.Label(chuangkou,text="你好")
label1.pack()
label2=tk.Label(chuangkou,bitmap="question")
label2.pack()
image_file=tk.PhotoImage(file=r"C:\Users\许博\Desktop\welcome.gif")
label3=tk.Label(chuangkou,image=image_file)
label3.pack()
chuangkou.mainloop()
Python tkinter库(label)
最新推荐文章于 2023-12-14 22:30:08 发布
本文通过实例演示了如何使用Python的Tkinter库创建GUI界面,包括窗口尺寸设置、居中显示及Label组件的使用,涉及图像加载和显示,适合初学者快速上手。
1995

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



