Tkinter简单组件

from tkinter import *
import tkinter.filedialog

root = Tk()
root.geometry("800x800")

# 设置窗口标题
root.title('裂痕检测系统')

text1 = StringVar()
text1.set("模型路径:") #可变的Lable内容

def loadmodel():  #按钮的动作
    path = tkinter.filedialog.askopenfilename()
    text1.set("模型路径:"+path)
    global model
    model = load_model(path)

def loadimage():  #加载图片,并通过画布canvas实现覆盖
    global show
    select_file = tkinter.filedialog.askopenfilename()
    text2.set("图片路径:"+select_file)
    #e.set(select_file)
    load = Image.open(select_file)
    load = load.resize((227,227))
    show = ImageTk.PhotoImage(load)

    cv.create_image((227,227), image = show)
    cv.pack()

button1 = tkinter.Button(root, text ="load_model", command = loadmodel, font=("幼圆", 20))   #command链接按钮动作
button1.pack()

label1 = tkinter.Label(root,textvariable = text1, font=("幼圆", 20)) #textvariable动态的lable文本
label1.pack()

cv = Canvas(root)
cv.pack()

root.mainloop()

你可能感兴趣的:(tkinter)