from tkinter import *
import tkinter as tk
from PIL import ImageTk
from PIL import Image
def get_img(filename, width, height):
im = Image.open(filename).resize((width, height))
im = ImageTk.PhotoImage(im)
return im
def main():
'''
注意: 背景图片im_root/im_root1这些,必须得是在主界面函数里进行加载,换个地方不行了,不知道为啥
'''
root = Tk()
root.geometry('1000x600+180+100')
root.resizable(False, False)
canvas_root = tk.Canvas(root, width=1000, height=600)
im_root = get_img('./background/background.jpg', 1000, 600)
canvas_root.create_image(500, 300, image=im_root)
canvas_root.pack()
im_root1 = get_img('./background/one.jpg', 100, 40)
img_label = Label(root, text='欢迎使用J波检测', image=im_root1)
img_label.place(x=3, y=3, width=100, height=40)
mainloop()
if __name__ == '__main__':
main()