1classWindow:2def__init__(3 self,4 title:str,5 layout:list[list[Element]],# set elements layout6 size: Union[tuple[str,int],None]=None,# window size7 resizable:bool=False,8 font: Union[FontType,None]=None,9 modal:bool=False,# modal window10 keep_on_top:bool=False,# keep on top11 no_titlebar:bool=False,# hide titlebar12 grab_anywhere:bool=False,# can move window by dragging anywhere13 alpha_channel:float=1.0,# window alpha channel14 enable_key_events:bool=False,# enable keyboard events15 return_keyboard_events:bool=False,# enable keyboard events (for compatibility)16 location: Union[tuple[int,int],None]=None,# window location17 center_window:bool=True,# move window to center18 row_padding:int=2,# row padding19 padding_x:int=8,# x padding around the window20 padding_y:int=8,# y padding around the window21 icon: Union[str,None]=None,# window icon, specify filename (Experimental)22 show_scrollbar:bool=False,# show scrollbar (Experimental)23**kw,24)->None:25# 省略26 self.window.protocol("WM_DELETE_WINDOW",lambda: self._close_handler())27# 省略2829def_close_handler(self):30"""Handle a window close event."""31 self.flag_alive =False32if self.timeout_id isnotNone:33 self.window.after_cancel(self.timeout_id)34 self._event_handler(WINDOW_CLOSED,None)3536defclose(self)->None:37"""Close the window."""38# The phenomenon where a closed window remains visible is occurring, so forcibly making it transparent.39try:40 self.set_alpha_channel(0.0)# force hide41except Exception as _:42pass43try:44 self.hide()45except Exception as _:46pass47# already closed?48ifnot self.flag_alive:49return50# close window51try:52 self.flag_alive =False53 _window_pop(self)54 self.window.destroy()# close window55 win_count = _window_count()56if win_count ==0:57 self.window.quit()# quit app58except Exception as e:59print(f"Window.close.failed: {e}",file=sys.stderr)60pass61
ざっと見たところ、ウィンドウクローズイベントで flag_alive を False にして、その場合には close メソッドの中で一部処理を省いているようです。
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2024/09/17 00:54