In GTK2, I enjoyed building a gui in the interpreter (ipython or plain python) "on the fly" and seeing the changes in real time like this:
在GTK2中,我喜欢在“动态”中在解释器(ipython或plain python)中构建一个gui并实时看到这些变化:
>>> import gtk
>>> win = gtk.Window()
>>> win.connect('delete-event', gtk.main_quit)
10L
>>> win.show_all()
Which will result in showing a window to which I could add objects.
这将导致显示一个我可以添加对象的窗口。
I'm changing to Gtk3 in part because it is the future and in part because I sometimes use Glade which now is only Gtk3. In doing the same with GTK3 DOESN'T show the window:
我正在改为Gtk3部分是因为它是未来,部分是因为我有时使用Glade,现在只有Gtk3。在使用GTK3时也不会显示窗口:
>>> from gi.repository import Gtk
>>> win = Gtk.Window()
>>> win.connect('delete-event', Gtk.main_quit)
13L
>>> win.show_all()
Alas, no window after that last line. It won't show until:
唉,在最后一行之后没有窗口。它将在以下情况下显示:
>>> Gtk.main()
I even tried:
我甚至尝试过:
>>> win.show_now()
Which did nothing.
哪个什么都没做。
Any ideas how to build in real time in GTK3?
有关如何在GTK3中实时构建的想法吗?
Thanks,
谢谢,
Narnie
Narnie
1 个解决方案
#1
0
I tried to process pending events with the following one-liner:
我尝试使用以下单行处理待处理事件:
>>> while Gtk.events_pending(): Gtk.main_iteration()
and it looks to have the same behaviour. It's not so convenient, but you can still do some work in the interpreter.
它看起来有相同的行为。它不是那么方便,但你仍然可以在翻译中做一些工作。
Alternatively, if you're developing a Gtk application, pdb.set_trace
will still work and let you debug callbacks if that's what you're looking for.
或者,如果您正在开发Gtk应用程序,pdb.set_trace仍然可以工作,如果您正在寻找的话,可以调试回调。
#1
0
I tried to process pending events with the following one-liner:
我尝试使用以下单行处理待处理事件:
>>> while Gtk.events_pending(): Gtk.main_iteration()
and it looks to have the same behaviour. It's not so convenient, but you can still do some work in the interpreter.
它看起来有相同的行为。它不是那么方便,但你仍然可以在翻译中做一些工作。
Alternatively, if you're developing a Gtk application, pdb.set_trace
will still work and let you debug callbacks if that's what you're looking for.
或者,如果您正在开发Gtk应用程序,pdb.set_trace仍然可以工作,如果您正在寻找的话,可以调试回调。