From ad9eb384d4296e184e062e8e9977f86e47b229b3 Mon Sep 17 00:00:00 2001 From: Musab Erdem Date: Wed, 22 May 2024 17:06:30 +0200 Subject: [PATCH] Erste Version erstellt. --- main.py | 87 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 87 insertions(+) diff --git a/main.py b/main.py index e69de29..7abfeae 100644 --- a/main.py +++ b/main.py @@ -0,0 +1,87 @@ +import tkinter as tk +from tkinter import messagebox +import matplotlib.pyplot as plt +from matplotlib.backends.backend_tkagg import FigureCanvasTkAgg +from matplotlib.figure import Figure + +class T2000ErdemGUI: + def __init__(self, root): + self.root = root + self.root.title("T2000 Erdem") + self.root.geometry("1024x600") + + # P- und I-Anteil Input Felder + tk.Label(self.root, text="P-Anteil:").place(x=10, y=10) + self.p_value = tk.DoubleVar() + tk.Entry(self.root, textvariable=self.p_value).place(x=100, y=10) + + tk.Label(self.root, text="I-Anteil:").place(x=10, y=50) + self.i_value = tk.DoubleVar() + tk.Entry(self.root, textvariable=self.i_value).place(x=100, y=50) + + # Eingabefelder für Koordinaten + tk.Label(self.root, text="Koordinaten der Drehmoment-Drehwinkel-Kennlinie:").place(x=10, y=90) + self.coordinates_text = tk.Text(self.root, height=5, width=20) + self.coordinates_text.place(x=20, y=110) + + # Eingabefeld für direkte Drehmomentvorgabe + tk.Label(self.root, text="Soll-Drehmoment in Nm:").place(x=10, y=220) + self.torque_value = tk.DoubleVar() + tk.Entry(self.root, textvariable=self.torque_value).place(x=170, y=220) + + # Anzeige für aktuellen Drehwinkel und Drehmoment + tk.Label(self.root, text="Aktueller Drehwinkel:").place(x=10, y=260) + self.current_angle = tk.Label(self.root, text="0" + "°") + self.current_angle.place(x=170, y=260) + + tk.Label(self.root, text="Aktuelles Drehmoment:").place(x=10, y=300) + self.current_torque = tk.Label(self.root, text="0" + " Nm") + self.current_torque.place(x=170, y=300) + + # Button zum Schließen der Anwendung + self.close_button = tk.Button(self.root, text="Beenden", command=self.close_application) + self.close_button.place(x=350, y=560) + + # Button zur Erstellung des Diagramms + self.plot_button = tk.Button(self.root, text="Eingaben übernehmen", command=self.create_diagram) + self.plot_button.place(x=10, y=560) + + # Diagramm + self.figure = Figure(figsize=(6,6), dpi=100) + self.plot = self.figure.add_subplot(111) + self.plot.set_xlim(0, 90) + self.plot.set_ylim(ymin=0) + self.plot.set_xlabel('Drehwinkel in Grad') + self.plot.set_ylabel('Drehmoment in Nm') + self.canvas = FigureCanvasTkAgg(self.figure, self.root) + self.canvas.get_tk_widget().place(x=424, y=0) + + def close_application(self): + if messagebox.askokcancel("Beenden", "Möchten Sie die Anwendung wirklich beenden?"): + self.root.quit() + + def create_diagram(self): + self.plot.clear() + self.plot.set_xlim(0, 90) + self.plot.set_xlabel('Drehwinkel in Grad') + self.plot.set_ylabel('Drehmoment in Nm') + + coordinates = self.coordinates_text.get("1.0", tk.END).strip().split("\n") + x_coords, y_coords = [], [] + for coord in coordinates: + x, y = map(float, coord.split(',')) + x_coords.append(x) + y_coords.append(y) + + self.plot.plot(x_coords, y_coords, marker='o', linestyle='-') + self.plot.set_ylim(bottom=0) + self.canvas.draw() + + def update_current_values(self, angle, torque): + self.current_angle.config(text=str(angle)) + self.current_torque.config(text=str(torque)) + +# Anwendung starten +root = tk.Tk() +app = T2000ErdemGUI(root) +root.mainloop()