내가 작성한 코드와 인터페이스하기 위해 작은 GUI를 설계하고 있습니다.Gtk.main() Gtk3 인터페이스에서 차단
내 문제는 Gtk.main()
명령이 차단되어있는 것 같고, 내 버튼이 파괴 버튼을 클릭해도 닫히더라도 내 터미널은 여전히 정지 상태입니다.
신호와도 상호 작용하지 않습니다.
#!/usr/bin/env python
from gi.repository import Gtk, Gdk, GObject
GObject.threads_init()
class Ivolution():
def __init__(self):
print "in"
self.builder = Gtk.Builder()
self.builder.add_from_file("data/ui/IvolutionWindow.glade")
#builder.connect_signals({ "on_window_destroy" : gtk.main_quit })
self.window = self.builder.get_object("ivolution_window")
print "in fin"
def on_stopbutton_clicked(self, widget):
"""
Asks the Facemovie thread to terminate
"""
print "Stop"
def on_ivolutionwindow_destroy(self, widget, data=None):
"""Called when the IvolutionWindow is closed."""
# Clean up code for saving application state should be added here.
print "Exiting"
Gtk.main_quit()
print "Exited"
if __name__ == "__main__":
app = Ivolution()
print "deb"
app.window.show()
Gdk.threads_init()
Gdk.threads_enter()
print "but"
Gtk.main()
print "end"
Gdk.thread_leave()
print "ding"
나는 모든 비 본질적인 부분을 제거 :
여기 내 샘플입니다.
Gobject 및 gdk.threads는 인터넷을 통해 다양한 소스 코드를 조사한 테스트입니다.
나는 그것들을 성공적으로 조합 할 수 없었다. 나는 정지 버튼을 눌러 창을 닫습니다
in
(Ivolution.py:4635): Gtk-CRITICAL **: gtk_radio_button_set_group: assertion `!g_slist_find (group, radio_button)' failed
(Ivolution.py:4635): Gtk-CRITICAL **: gtk_radio_button_set_group: assertion `!g_slist_find (group, radio_button)' failed
in fin
deb
but
비록 : 나는 콘솔로 프로그램을 실행하면
, 여기에 내가 무엇을 얻을 수 있습니다.
일단 내 창을 닫으면 콘솔이 그대로 유지되고 ctrl + c조차도 응용 프로그램을 중지하지 않습니다.
나는 뭔가를 놓친 것이 틀림 없다. 그러나 완전한 GUI 인 noob으로 나는 무엇을 보지 못한다. This sample code은 정말 내 주변에있는 것처럼 보입니다. 어떤 생각?