我需要帮助,我试图编写一个脚本,当我按Enter键时它将导航到下一帧。我是python编码的新手,仅涉足了3-4个小时。到目前为止,我有以下几点。
from tkinter import *
class App(tk.Frame):
def __init__(self, parent, *args, **kwargs):
tk.Frame.__init__(self, parent)
self.parent = parent
self.initUI()
def initUI(self):
self.parent.title("Fullscreen Application")
self.pack(fill="both", expand=True, side="top")
self.parent.wm_state("zoomed")
self.parent.bind("<F11>", self.fullscreen_toggle)
self.fullscreen_toggle()
self.label = tk.Label(self, text="Program Screen", font=("default",60), fg="black")
self.label.pack(side="top", fill="both", expand=True)
def fullscreen_toggle(self, event="none"):
self.parent.focus_set()
self.parent.overrideredirect(True)
self.parent.overrideredirect(False) #added for a toggle effect, not fully sure why it's like this.
self.parent.attributes("-fullscreen", True)
self.parent.wm_attributes("-topmost", 1)
def fullscreen_next(self, event="none"):
self.parent.overrideredirect(False)
self.parent.attributes("-fullscreen", False)
self.parent.wm_attributes("-topmost", 0)
self.button = Button(self, text="Next", command=self.func)
self.button.pack(side='left')
master.bind('Return', self.func)
def func(self, _event=None):
self.parent.bind("<Return>", self.fullscreen_next)
self.centerWindow()