Threading and wx.....

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • SamG

    Threading and wx.....

    Hi,

    Im trying my hand at threading with wx applications. I have written
    the following code...

    import wx
    from threading import Thread, Lock

    class createWindow(Th read):
    def __init__(self):
    Thread.__init__ (self)
    self.lock = Lock()
    self.app=None

    def run(self):
    #self.lock.acqu ire()
    self.app = wx.PySimpleApp( )
    frame = wx.Frame(None, title="Hello wx")
    frame.Show()
    #self.lock.rele ase()
    self.app.MainLo op()


    if __name__=='__ma in__':
    c = createWindow()
    c.start()
    c.join()

    Now when i run this program i get a window but the application just
    does not respond. Is there something that im missing here. Pls let me
    know. Thanks in advance.
  • SamG

    #2
    Re: Threading and wx.....

    On Aug 8, 12:01 pm, SamG <mad.vi...@gmai l.comwrote:
    Hi,
    >
    Im trying my hand at threading with wx applications. I have written
    the following code...
    >
    import wx
    from threading import Thread, Lock
    >
    class createWindow(Th read):
    def __init__(self):
    Thread.__init__ (self)
    self.lock = Lock()
    self.app=None
    >
    def run(self):
    #self.lock.acqu ire()
    self.app = wx.PySimpleApp( )
    frame = wx.Frame(None, title="Hello wx")
    frame.Show()
    #self.lock.rele ase()
    self.app.MainLo op()
    >
    if __name__=='__ma in__':
    c = createWindow()
    c.start()
    c.join()
    >
    Now when i run this program i get a window but the application just
    does not respond. Is there something that im missing here. Pls let me
    know. Thanks in advance.
    Oops! Murphy's law works again! And the above code is working fine.

    Comment

    • Mike Driscoll

      #3
      Re: Threading and wx.....

      On Aug 8, 2:19 am, SamG <mad.vi...@gmai l.comwrote:
      On Aug 8, 12:01 pm, SamG <mad.vi...@gmai l.comwrote:
      >
      >
      >
      Hi,
      >
      Im trying my hand at threading with wx applications. I have written
      the following code...
      >
      import wx
      from threading import Thread, Lock
      >
      class createWindow(Th read):
          def __init__(self):
              Thread.__init__ (self)
              self.lock = Lock()
              self.app=None
      >
          def run(self):
              #self.lock.acqu ire()
              self.app = wx.PySimpleApp( )
              frame = wx.Frame(None, title="Hello wx")
              frame.Show()
              #self.lock.rele ase()
              self.app.MainLo op()
      >
      if __name__=='__ma in__':
          c = createWindow()
          c.start()
          c.join()
      >
      Now when i run this program i get a window but the application just
      does not respond. Is there something that im missing here. Pls let me
      know. Thanks in advance.
      >
      Oops! Murphy's law works again! And the above code is working fine.
      You'll probably also find the following wiki article helpful:


      And there's at least one demo in the wxPython Demo that's a good
      example of threading.

      Mike

      Comment

      Working...