Jul-04-2022, 05:00 PM
Python disagrees that pymongo is installed. Which version of Python are you using? What is your OS? How did you install pymongo?
Did you do all the GPIO setup at the start of the program? All of this stuff has to happen before you call mainloop()
Did you do all the GPIO setup at the start of the program? All of this stuff has to happen before you call mainloop()
GPIO.setmode(GPIO.BCM) GPIO.setup(Ent,GPIO.OUT) GPIO.setwarnings(False)window.show() is how you have a hidden window drawn to the screen, but it is for Qt, not tkinter. My mistake. Here's a working example of how I think the histo window should work.
import tkinter as tk import datetime class Histo(tk.Toplevel): """A window for viewing log messages""" def __init__(self): super().__init__() self.title('Historique') self.text = tk.Text(self, width=40, height=10) self.text.pack(padx=5, pady=5) def log(self, msg): """Append log message to text""" now = datetime.datetime.now() self.text.insert(tk.INSERT, f"{now} {msg}\n") class MainWindow(tk.Tk): def __init__(self): super().__init__() self.histo = Histo() self.histo.withdraw() button = tk.Button(self, text="Press Me", command=self.show_histo) button.pack(padx=20, pady=20) def show_histo(self): self.histo.log("Show histo") self.histo.deiconify() MainWindow().mainloop()Here I combined logging and drawing the window. Your app will do logging for on/off events and draw the panel when the afficher button is pressed.