python - wxPython app No error but still freezes -



python - wxPython app No error but still freezes -

i don't errors code after nail spam button freezes , nil happens. see wrong code?

import skype4py, wx, time t skype = skype4py.skype() skype.attach() name = "" chat = "" message = "" class skyped(wx.frame): def __init__(self,parent,id): wx.frame.__init__(self,parent,id,"skype chat spammer",size=(300,200)) panel=wx.panel(self) start=wx.button(panel,label="spam!",pos=(140,100),size=(50,20)) stop=wx.button(panel,label="stop!", pos=(200,100),size=(50,20)) self.bind(wx.evt_button, self.spam, start) self.bind(wx.evt_close, self.closewindow) entered=wx.textentrydialog(none, "user spam?", "user", "username here") if entered.showmodal()==wx.id_ok: name=entered.getvalue() entered1=wx.textentrydialog(none, "message?", "message", "message here") if entered1.showmodal()==wx.id_ok: message=entered1.getvalue() def spam(self,event): global chat global name global message chat = skype.createchatwith(name) while 1: chat.sendmessage(message) def closewindow(self,event): self.destroy() if __name__=="__main__": app=wx.pysimpleapp() frame=skyped(parent=none,id=-1) frame.show() app.mainloop()

building off of kotlinski's answer, yes freezing because doing endless loop in main thread of application. app can no longer process gui-related interaction or events.

while don't know much wx, theory same pyqt. should never block main thread of app long running or heavy lifting operations. should run in separate threads , communicating signals:

http://wiki.wxpython.org/longrunningtasks

your main thread should clear handle user interaction widgets.

python wxpython freeze

Comments

Popular posts from this blog

delphi - blogger via idHTTP : error 400 bad request -

c++ - compiler errors when initializing EXPECT_CALL with function which has program_options::variables_map as parameter -

How do I check if an insert was successful with MySQLdb in Python? -