import tkinter as tk import tk_tools import time from .Plot import Plot from .globals import * class Page_1(tk.Frame): def __init__(self, parent, controller): tk.Frame.__init__(self, parent) self.t = 0 self.controller = controller # graph self.serialPlot = Plot(nPoints=100, xaxis=(0, 100), yaxis=(0, 5), nGraphs=2, ytitle="Windgeschwindigkeit m/s", xtitle="Messpunkte [1/3-Sekunde]", title="Geschwindigkeitsverlauf", line_colors=["#2222ff", "#22ff22", "#ff2222"]) canvas = self.serialPlot.create_canvas(self) canvas.pack(side=tk.LEFT, fill=tk.BOTH, expand=True) # right menu left = tk.Frame(self, borderwidth=2, relief="solid") container = tk.Frame(left, borderwidth=2, relief="solid") label1 = tk.Label(container, text="I could be a canvas, but I'm a label right now") self.label4 = tk.Label(self,font=("Arial","30"),fg="red") self.label4.pack() self.label4.config(text=str(self.t)) SendButton = tk.Button(left, text='Quit', command=quit) label2 = tk.Label(left, text="I could be a button") label3 = tk.Label(left, text="So could I") left.pack(side="left", expand=True, fill="both") container.pack(expand=True, fill="both", padx=7, pady=5) SendButton.pack() label1.pack() label2.pack() label3.pack() controller.pid.SetPoint = 0.4 # m/s def update(self, visible): self.serialPlot.update([self.controller.getLastValue("adc_0"), (time.time()/0.3) % 1 * 5], visible=visible) if visible: self.label4.config(text="{:5.3f} V".format(self.controller.getLastValue("adc_0")))