Python Gtk+3 Window.present 不适用于 GNOME Builder
Python Gtk+3 Window.present not work with GNOME Builder
环境:
- Ubuntu 侏儒 16.04.3
- GNOME Builder 3.26.3
GNOME Builder 生成的项目使用GtkTemplate 解释ui,但我改为使用Gtk.Builder 解释。修改后,不起作用。
而且我看不到任何错误消息。
class Application(Gtk.Application):
def __init__(self):
super().__init__(application_id='org.gnome.Ee',
flags = Gio.ApplicationFlags.FLAGS_NONE)
def do_startup(self):
print('do_startup')
Gtk.Application.do_startup(self)
builder = Gtk.Builder()
builder.add_from_resource("/org/gnome/Ee/window.ui")
print(builder)
self.builder = builder
def do_activate(self):
print("do_activate")
win = self.props.active_window
if not win:
win = self.builder.get_object("EeWindow")
print(win)
win.present() # not work, can not see the window
我已经上传演示代码到Github:https://github.com/Honghe/gnome_builder_demo
任何帮助将不胜感激!
应用程序不知道 window 所以它立即退出。您需要在创建 window.
的实例后调用 win.set_application(self)
环境:
- Ubuntu 侏儒 16.04.3
- GNOME Builder 3.26.3
GNOME Builder 生成的项目使用GtkTemplate 解释ui,但我改为使用Gtk.Builder 解释。修改后,不起作用。 而且我看不到任何错误消息。
class Application(Gtk.Application):
def __init__(self):
super().__init__(application_id='org.gnome.Ee',
flags = Gio.ApplicationFlags.FLAGS_NONE)
def do_startup(self):
print('do_startup')
Gtk.Application.do_startup(self)
builder = Gtk.Builder()
builder.add_from_resource("/org/gnome/Ee/window.ui")
print(builder)
self.builder = builder
def do_activate(self):
print("do_activate")
win = self.props.active_window
if not win:
win = self.builder.get_object("EeWindow")
print(win)
win.present() # not work, can not see the window
我已经上传演示代码到Github:https://github.com/Honghe/gnome_builder_demo
任何帮助将不胜感激!
应用程序不知道 window 所以它立即退出。您需要在创建 window.
的实例后调用win.set_application(self)