Home > other >  Wxpython child thread in a new window
Wxpython child thread in a new window

Time:02-19

I opened the child in the home page for processing data, the idea is: the child to receive specific data, the main page pops up a frame, but always error, not in the child process can be executed correctly new window statement
 
Class MainFrame (wx. Frame) :
Def recv (self) :
While True:
Data=https://bbs.csdn.net/topics/server.recv (1024). The decode (' utf-8)
Print (' thread recv: '+ data)
Action=data [data. The find ('/-/-/') + 9: data. The find ('/-/-/') + 11]
If action=='03:
User=eval (data [data. The find ('/-/-/03 ') + 11:])
The self. The userlist. Set (user)
Elif action=='4' :
From_user=data [data. The find ('/-/-/04 ') + 11: data. The find ('/* * * * * *//')]
('/server. Sendall (-/-/05 '+ name_main +'/* * * * * *//'+ from_user). The encode (' utf-8))
Chatting. Append (from_user)
# two commented out of the following statements is executed will error
# self. Chat_frame=ChatFrame (from_user)
# self. Chat_frame. The Show ()
Elif action=='05:
Message_queues. Append (data)

Def __init__ (self) :
Wx. Frame. __init__ (self, None, 1, the self. The hello () + name_main, size=(300, 500), style=wx. DEFAULT_FRAME_STYLE)
Panel=wx. The panel (the parent=self)
Wx. MessageBox (name_main + ', '+' self. Hello ())
The self. The userlist=wx. ListBox (panel, 1, size=(100, 300), choices=user, style=wx. LB_SINGLE)
The self. The button=wx. Button (panel, 1, "Chat")
The self. The Bind (wx. EVT_BUTTON, self chat_click, self. The button)
Self. Text_1=wx. StaticText (panel, 1, 'online list of users')
Vbox1=wx. BoxSizer (wx. VERTICAL)
Vbox1. AddMany ([(self text_1, 0, wx. TOP | wx. CENTER, 25), (the self. The userlist, 0, wx. ALL | wx. CENTER, 25), (the self. The button, 0, wx. CENTER)])
A panel. The SetSizer (vbox1)
Threading. Thread (target=self recv, args=()). The start ()


Error message is as follows:
  • Related