From 64898723bbca20aa563207df09b504bd0184a969 Mon Sep 17 00:00:00 2001 From: shenjack <3695888@qq.com> Date: Wed, 19 Apr 2023 00:44:41 +0800 Subject: [PATCH] typing + window pointer set --- Difficult_Rocket/client/__init__.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/Difficult_Rocket/client/__init__.py b/Difficult_Rocket/client/__init__.py index c972a06..ef4888a 100644 --- a/Difficult_Rocket/client/__init__.py +++ b/Difficult_Rocket/client/__init__.py @@ -116,9 +116,11 @@ def pyglet_load_fonts_folder(folder) -> None: def _call_screen_after(func: Callable) -> Callable: @functools.wraps(func) - def warped(self, *args, **kwargs): + def warped(self: "ClientWindow", *args, **kwargs): result = func(self, *args, **kwargs) for a_screen in self.screen_list: + a_screen.window_pointer = self + # 提前帮子窗口设置好指针 if hasattr(a_screen, func.__name__): try: getattr(a_screen, func.__name__)(*args, **kwargs, window=self) @@ -132,8 +134,10 @@ def _call_screen_after(func: Callable) -> Callable: def _call_screen_before(func: Callable) -> Callable: @functools.wraps(func) - def warped(self, *args, **kwargs): + def warped(self: "ClientWindow", *args, **kwargs): for a_screen in self.screen_list: + a_screen.window_pointer = self + # 提前帮子窗口设置好指针 if hasattr(a_screen, func.__name__): try: getattr(a_screen, func.__name__)(*args, **kwargs, window=self) @@ -177,7 +181,7 @@ class ClientWindow(Window): # frame self.frame = pyglet.gui.Frame(self, order=20) self.M_frame = pyglet.gui.MovableFrame(self, modifier=key.LCTRL) - self.screen_list = [] + self.screen_list: List[BaseScreen] = [] # setup self.setup() # 命令显示 @@ -202,7 +206,6 @@ class ClientWindow(Window): def setup(self): self.load_fonts() - self.screen_list: List[BaseScreen] # TODO 读取配置文件,加载不同的屏幕,解耦 self.screen_list.append(DRDEBUGScreen(self)) self.screen_list.append(DRScreen(self))