How can I update the textctrl content in GUI?
Question: I am trying to write my first wxpython GUI program,in my program,I want to get
anothor software window's title,if the title change,clear the old title and
show the new title in GUI,I test in cmd,it can get the title in a loop,but I
don't konw how to set a event in GUI to update the title.

my code:

    
    
    def getinfos():
        tempWindowName=win32gui.GetWindowText (find_window())
        while True:
            titles=[]
            if (tempWindowName==win32gui.GetWindowText (find_window())):
                pass
            else:
                tempWindowName=win32gui.GetWindowText (find_window())               
                titles.append(tempWindowName)
    
                return title[0]
    
        time.sleep(1000)  
    

and the GUI code:

    
    
    import controller2
    import time
    
    ########################################################################
    class InfoPanel(wx.Panel):
    
        #----------------------------------------------------------------------
        def __init__(self, parent):
            """Constructor"""
            wx.Panel.__init__(self, parent)
    
            try:
                self.titleResults = controller2.getinfos()                            
            except:               
                self.titleResults = 'no data'
    
    
            mainSizer = wx.BoxSizer(wx.VERTICAL)
    
            self.titlecontent = wx.TextCtrl(self, -1, "", style=wx.TE_MULTILINE|wx.TE_RICH|wx.TE_LEFT|wx.TE_WORDWRAP|wx.NO_BORDER)                                                                                                                    
            self.titlecontent.SetBackgroundColour('white')
            self.settitle()
    
            mainSizer.Add(self.yejicontent, 2.5, wx.ALL|wx.EXPAND, 5)
    
            self.SetSizer(mainSizer)
    
    
        #----------------------------------------------------------------------
        def settitle(self):
    
    
            self.titlecontent.SetValue("%s"%self.titleResults)
    
    
    
    ########################################################################
    class InfoFrame(wx.Frame):
        """"""
    
        #----------------------------------------------------------------------
        def __init__(self):
            """Constructor"""
            wx.Frame.__init__(self, None, title="title",size=(500, 880))
            panel = InfoPanel(self)
            style= self.GetWindowStyle()
            self.SetWindowStyle(style|wx.STAY_ON_TOP)
    
    
    class MyApp(wx.App):
        def OnInit(self):
            self.infoFrame=InfoFrame()        
            self.SetTopWindow(self.infoFrame)
            self.infoFrame.Show(True)        
            return True
    
    #----------------------------------------------------------------------
    if __name__ == "__main__":
        app = MyApp(False)
        app.MainLoop()
    

Thanks for your time and appreciate for any advise.


Answer: You can send a [custom wx event](http://wiki.wxpython.org/CustomEventClasses)
or setup [pubsub](http://wiki.wxpython.org/WxLibPubSub).

