python - Threading wxPython GUI? -
python - Threading wxPython GUI? -
i've tried many combination of threading know.
(wxpython "frame1" created using wxformbuilder)
this seems should work crashes:
import wx import wx.richtext import time import threading class myframe1 ( wx.frame ): def __init__( self, parent ): wx.frame.__init__ ( self, parent, id = wx.id_any, title = wx.emptystring, pos = wx.defaultposition, size = wx.size( 500,300 ), style = wx.default_frame_style|wx.tab_traversal ) self.setsizehintssz( wx.defaultsize, wx.defaultsize ) bsizer3 = wx.boxsizer( wx.vertical ) self.m_statictext1 = wx.statictext( self, wx.id_any, u"this thingy", wx.defaultposition, wx.defaultsize, 0 ) self.m_statictext1.wrap( -1 ) bsizer3.add( self.m_statictext1, 0, wx.all|wx.align_center_horizontal, 5 ) self.m_richtext1 = wx.richtext.richtextctrl( self, wx.id_any, wx.emptystring, wx.defaultposition, wx.defaultsize, 0|wx.vscroll|wx.hscroll|wx.no_border|wx.wants_chars ) bsizer3.add( self.m_richtext1, 1, wx.expand |wx.all, 5 ) self.m_button2 = wx.button( self, wx.id_any, u"mybutton", wx.defaultposition, wx.defaultsize, 0 ) bsizer3.add( self.m_button2, 0, wx.all|wx.align_center_horizontal, 5 ) self.setsizer( bsizer3 ) self.layout() self.centre( wx.both ) def __del__( self ): pass class main(threading.thread): def __init__(self): threading.thread.__init__(self) def run(self): app = wx.app() frame = myframe1(none) frame.show() app.mainloop() if __name__ == "__main__": print "starting thread!" t = main() t.start() time.sleep(1) print "this should print while window open!"
crash dialog:
python quit unexpectedly while using libwx_osx_cocoau-3.0.0.1.0.dylib plug-in.
i've looked through numerous threads, read "non-blocking gui documentation". it's not clicking me.
osx requires gui remain in main thread.
python multithreading python-2.7 wxpython nonblocking
Comments
Post a Comment