我正在寻找一个功能性示例,以演示如何使 Gtk+3 窗口全屏。
好的,我通过阅读窗口状态标志文档解决了问题:
win.connect("key-press-event", self.on_win_key_press_event)
win.connect("window-state-event", self.on_window_state_event)
#...
def fullscreen_mode(self):
if self.__is_fullscreen:
self.win.unfullscreen()
else:
self.win.fullscreen()
def on_win_key_press_event(self, widget, ev):
key = Gdk.keyval_name(ev.keyval)
if key == "f":
self.fullscreen_mode()
def on_window_state_event(self, widget, ev):
self.__is_fullscreen = bool(ev.new_window_state & Gdk.WindowState.FULLSCREEN)