我正在寻找一个功能性示例,演示如何全屏制作Gtk + 3 窗口。
答案 0 :(得分:5)
好的,我通过阅读the window state flags documentation来解决这个问题:
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)