import tkinter as tk
from tkinter import filedialog, messagebox, ttk
from PIL import Image, ImageTk
import os
import cv2
import matplotlib.pyplot as plt
import numpy as np
from datetime import datetime
import sys
class ImageMatcherApp:
def __init__(self, root):
self.root = root
self.root.title("图像匹配系统")
self.root.minsize(1500, 1000)
self.current_image_path = None
self.model_library_path = None
self.matched_image_path = None
self.create_main_interface()
def create_main_interface(self):
self.main_frame = ttk.Frame(self.root, padding="10")
self.main_frame.grid(row=0, column=0, sticky=(tk.W, tk.E, tk.N, tk.S))
self.create_image_display_area()
self.create_control_buttons()
self.create_path_display()
self.create_status_bar()
self.create_progress_bar()
def create_image_display_area(self):
self.image_frame = ttk.Frame(self.main_frame)
self.image_frame.grid(row=0, column=0, columnspan=3, pady=10)
self.labels = []
self.label_texts = ["输入图像", "匹配图像", "二维图结果"]
for i in range(3):
frame = ttk.LabelFrame(self.image_frame, text=self.label_texts[i])
frame.grid(row=0, column=i, padx=15)
canvas = tk.Canvas(frame, width=400, height=400)
canvas.grid(row=0, column=0, padx=10, pady=10)
label = ttk.Label(canvas, text=f"请选择{
self.label_texts[i]}")
label.place(relx=0.5, rely=0.5, anchor="center")
self.labels.append(label)
def create_control_buttons(self):
self.button_frame = ttk.Frame(self.main_frame)
self.button_frame.grid(row=1, column=0, columnspan=3, pady=20)
style = ttk.Style()
style.configure('Large.TButton', padding=(20, 10))
self.upload_button = ttk.Button(
self.button_frame,
text="上传图像",
command=self
标签:create,Python,self,ttk,image,import,图像匹配,frame,图形用户界面
From: https://blog.csdn.net/huanghm88/article/details/145043000