wxPython having trouble with frame objects

Soumen banerjee soumen08 at gmail.com
Fri May 1 01:12:43 EDT 2009


Hello,
Im not adding any GUI elements from the changer thread. Im just
attempting to change the value of a preexisting widget made in thread
one. The point is that i need to display text generated in thread 2 in
a GUI generated in thread 1.
As far as inter thread synchronization is concerned, i see your point.
So i took this approach

import wx,gui,threading
fix=0
i=1
class guithread(threading.Thread):
    def run(self):
        global fix
        app = wx.PySimpleApp(0)
        wx.InitAllImageHandlers()
        guithread.frame_1 = gui.MyFrame(None, -1, "")
        app.SetTopWindow(guithread.frame_1)
        guithread.frame_1.Show()
        print "setting fix"
        fix=1
        app.MainLoop()
gui1=guithread()
gui1.start()
class changer(threading.Thread):
    def run(self):
        print fix
        gui1.frame_1.text_ctrl_1.SetValue("hello")
print fix
while i:
    if fix == 1:
        print "starting changer"
        chang=changer()
        chang.start()
        i=0
This works, but is there anything simpler?
Regards
Soumen



More information about the Python-list mailing list