diff --git a/Windows/main.py b/Windows/main.py index 03221553e5fe2ee99c173d659330f71f6d40337f..aa60ca28aefc52fd2856b24fb66af353ecbe5c1f 100644 --- a/Windows/main.py +++ b/Windows/main.py @@ -32,14 +32,14 @@ from PIL import Image, ImageTk import pandas as pd import matplotlib from matplotlib import pyplot as plt -import seaborn as sns +#import seaborn as sns import tempfile import os from matplotlib.backends.backend_tkagg import FigureCanvasTkAgg import matplotlib.pyplot as plt -import tensorflow as tf +#import tensorflow as tf diff --git a/integration/integrate.py b/integration/integrate.py index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..3edb8670f00862beefcdcc795d1e46ec127c8aa1 100644 --- a/integration/integrate.py +++ b/integration/integrate.py @@ -0,0 +1,97 @@ +import tkinter as tk +from tkinter import ttk + +import serial + + +class Interface: + def __init__(self): + print("start") + + def create_popup(self): + popup = tk.Tk() + popup.title("Project") + + # Set the initial size and position of the popup window + width = 1000 + height = 600 + screen_width = popup.winfo_screenwidth() + screen_height = popup.winfo_screenheight() + x = (screen_width // 2) - (width // 2) + y = (screen_height // 2) - (height // 2) + popup.geometry(f"{width}x{height}+{x}+{y}") + + # Configure the grid to be expandable + popup.columnconfigure(0, weight=1) + popup.columnconfigure(1, weight=1) + popup.rowconfigure(0, weight=1) + popup.rowconfigure(1, weight=1) + + # First row, two sections + frame1 = ttk.Frame(popup, borderwidth=1, relief="solid") + frame1.grid(row=0, column=0, padx=10, pady=10, sticky="nsew") + label1 = ttk.Label(frame1, text="If IMU is connected to the laptop please click the Connect button") + label1.place(relx=0.5, rely=0.9, anchor='center') + label2 = ttk.Label(frame1,text="Port: None ") + label2.place(relx=0.2, rely=0.8, anchor='center') + + frame2 = ttk.Frame(popup, borderwidth=1, relief="solid") + frame2.grid(row=0, column=1, padx=10, pady=10, sticky="nsew") + label2 = ttk.Label(frame2, text="Section 2") + label2.place(relx=0.5, rely=0.5, anchor='center') + + # Second row, two sections + frame3 = ttk.Frame(popup, borderwidth=1, relief="solid") + frame3.grid(row=1, column=0, padx=10, pady=10, sticky="nsew") + label3 = ttk.Label(frame3, text="If EMG is connected to the laptop please click the Connect button") + label3.place(relx=0.5, rely=0.9, anchor='center') + label4 = ttk.Label(frame3, text="Port: None ") + label4.place(relx=0.2, rely=0.8, anchor='center') + + frame4 = ttk.Frame(popup, borderwidth=1, relief="solid") + frame4.grid(row=1, column=1, padx=10, pady=10, sticky="nsew") + label4 = ttk.Label(frame4, text="Section 4") + label4.place(relx=0.5, rely=0.5, anchor='center') + + # Add a button to frame1 to trigger adding widgets + add_button1 = ttk.Button(frame1, text="Connect", command=self.IMU_Connect) + add_button1.place(relx=0.5, rely=0.8, anchor='center') + + add_button2 = ttk.Button(frame3, text="Connect", command=self.EMG_Connect) + add_button2.place(relx=0.5, rely=0.8, anchor='center') + + popup.mainloop() + + def IMU_Connect(self): + try: + arduino = serial.Serial('COM4', 115200, timeout=1) + column_limit = 9 + # 执行åŽç»æ¥éª¤ + print("Connected to IMU") + # 例如,读å–ä¸€äº›æ•°æ® + # data = arduino.readline() + # print(data) + except serial.SerialException: + print("IMU is not connected") + + def EMG_Connect(self): + try: + arduino = serial.Serial('COM4', 115200, timeout=1) + column_limit = 9 + # 执行åŽç»æ¥éª¤ + print("Connected to EMG") + # 例如,读å–ä¸€äº›æ•°æ® + # data = arduino.readline() + # print(data) + except serial.SerialException: + print("EMG is not connected") + + + +if __name__ == "__main__": + windows = Interface() + windows.create_popup() + + + +