Es tut dir leid?
Das ist das kleinste Problem.
Ich hab es jetzt dank euch zum Laufen gekriegt, die ist ja wohl supper
Ich habe dies nun in mein Programm eingebaut:
Code: Alles auswählen
class timer(tk.Frame):
def __init__(self, master=None):
tk.Frame.__init__(self, master)
self.last_action_time = 0
self.last_action_time_poll_interval = 1000 # 1000 ms min. Zeit zwischen zwei Aufrufen
self.last_action_delay = 5 # 300 s, bevor die Methode self.handle_action aufgerufen wird
self._last_action_time_checker()
self.say_hi()
def say_hi(self):
self.last_action_time = time.time()
def _last_action_time_checker(self):
if self.last_action_time:
if (time.time() - self.last_action_time) > self.last_action_delay:
self.last_action_time = 0 # Sicherstellen, dass die Aktion nur einmal pro Ablauf ausgeführt wird
self.handle_action()
self.after(self.last_action_time_poll_interval, self._last_action_time_checker)
print(time.time())
#print(self.last_action_time)
def handle_action(self):
#print("12")
Bildschirmschoner()
def any_callback(self, event=None):
self.last_action_time = time.time() # setzt den Counter auf die aktuelle Zeit hoch -> Differenz = 0
print("2")
Es Funktioniert auch
Nach genau 5 Sekunden (Testzeit da ich nicht immer 5min Warten möchte
)
soll ein neues Fenster aufgehen:
Code: Alles auswählen
class Bildschirmschoner(object):
def __init__(self):
self.root = tkinter.Tk()
self.root.title("Example")
app=FullScreenApp(self.root)
self.text = tkinter.Text()
self.text.pack(fill=tkinter.BOTH, expand=tkinter.YES)
for event_name in event_map.values():
self.root.bind("<%s>" % event_name, self._update_status)
def _update_status(self, event):
txt = event_map[int(event.type)]
msg = "%s [ %sx%s ]\n" % (txt, event.x, event.y)
self.text.insert(tkinter.INSERT, msg)
self.text.see(tkinter.INSERT)
print("status")
self.root.destroy()
def mainloop(self):
self.root.mainloop()
(Hier sollen die Berührungen erkannt werden)--> Funktioniert auch.
Jedoch im Vollbildmodus erscheint es nicht im Vordergrund, sondern das alte Fenster bleibt im Vordergrund:
Code: Alles auswählen
class MainFrame():
def __init__(self):
self.root = tk.Tk()
self.state=False
app=FullScreenApp(self.root)
app=timer(self.root)
##start_class_button = tk.Button(self.root, text="Öffnen", command=self.do_start_class, width=20)
##Kalender öffnen
self.kalender=PhotoImage(file='/home/pi/Desktop/praesentation/kalender.gif')
self.kalender_menu_button = tk.Button(self.root, image=self.kalender, command=self.kalender_modus)
##Präsentation öffnen
self.praesentation=PhotoImage(file='/home/pi/Desktop/praesentation/praesentations_modus.gif')
self.praesentations_modus_button = tk.Button(self.root, image=self.praesentation, command=self.praesentation_modus)
##Präsentation öffnen
self.radio=PhotoImage(file='/home/pi/Desktop/praesentation/radios.gif')
self.radio_button = tk.Button(self.root, image=self.radio, command=self.radio_modus)
##Beenden
exit_button = tk.Button(self.root, text="beenden", command=self.do_exit, width=20)
##start_class_button.pack()
self.kalender_menu_button.pack()
self.praesentations_modus_button.pack()
self.radio_button.pack()
exit_button.pack()
self.root.mainloop()
def do_exit(self):
self.root.quit()
self.root.destroy()
def kalender_modus(self):
if self.state==False:
print ("starte Subfenster...")
self.buttons = Kalender(tk.Toplevel())
self.state=True
else:
print ("schließe Subfenster...")
self.state=False
def radio_modus(self):
if self.state==False:
print ("starte Subfenster...")
self.buttons = Radio(tk.Toplevel())
self.state=True
else:
print ("schließe Subfenster...")
self.state=False
def praesentation_modus(self):
if self.state==False:
print ("starte Subfenster...")
self.buttons = Bilder(tk.Toplevel())
self.state=True
else:
print ("schließe Subfenster...")
self.state=False
myframe = MainFrame()