做一个欢迎界面,如下图。点击"进入"按钮,就可以进入新界面。

记录 python-tkinter包利用Label插入图片(一)

新界面:

记录 python-tkinter包利用Label插入图片(一)

代码如下:

import tkinter as tk

root = tk.Tk()
root.geometry('650x450+150+100')
root.title('检测J波界面化')
root.resizable(False, False)
#设置条形框
photo = tk.PhotoImage(file="C:\\Users\\happy\\.spyder-py3\\hello\\hello.gif") 
Lab= tk.Label(root,text='欢迎使用J波检测',compound='center',font = ('微软雅黑',30),image= photo)
Lab.pack()#设置主界面
   
def new_window():
    window1 = tk.Toplevel(root)
    window1.geometry('650x450+150+100')
    lab1 = tk.Label(window1,text='hello')
    lab1.pack()

but = tk.Button(root,text='进入',bg = 'green',command=new_window) #传递
but.pack()

root.mainloop()    

注意:

python默认支持 图片格式为.gif。

相关文章:

  • 2021-05-23
  • 2021-05-09
  • 2022-12-23
  • 2021-12-17
  • 2021-04-13
  • 2021-06-25
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-08-04
  • 2022-12-23
  • 2021-05-15
  • 2022-12-23
  • 2021-12-21
  • 2022-12-23
相关资源
相似解决方案