Imported Frame Freeze issue

Sandeep Bhat wrote:

Here I am trying to code a LAN chat application.....The issue I am
facing is when I try to create an object of a wxPython Frame created
in another file. The frame is created but the buttons in it are not
properly created. So I end up getting a partial frame and the
application HANGS or freezes. The required frame has been created in
the ChatFrame file and when called in Version5 file it works well and
is successfully created but when called inside "clientCallReceiver"
creates the freeze issue.

This is because you are calling clientCallReceiver within a secondary
thread.

Message queues are associated with threads, not with windows. A window
belongs to the thread that created it, and all messages for a window get
sent to its owning thread. So, when you create your window in a
secondary thread, Windows sends the initial creation and window
management messages to that thread. However, you don't have a message
loop in that thread, so the messages are never consumed, and the window
creation hangs, unable to complete.

What you need to do is have a mechanism for sending messages back to the
main GUI thread to handle your GUI tasks. The Python Queue class works
for that, but wx.CallAfter is probably simpler. It transitions back to
the main thread. Any time you need to interact with a window, you'll
need to make sure you are in your main thread.

···

--
Tim Roberts, timr@probo.com
Providenza & Boekelheide, Inc.

sandyethadka wrote:

Could you tell me how FindWindowByName works? I couldn't find any example
implementing it....

Well, there wouldn't be an example of implementing it. It's part of
wxWidgets. It searches through all of the windows you have created in
this session and returns the first one that matches the given name.

The routine is not very useful, because usually you already know exactly
which windows you want. FindWindowByName does not search for windows in
other applications.

I need to identify and open an open frame to append messages to it.....I
could only find syntax and am having trouble understanding it.....Throws
unbound method error....I know that this error pops up when a method is
called using a wrong object....But I cannot call this method using a
wx.Window object as that is what am trying to obtain in the first place....

Is this is a frame within your own application? If so, then you should
just save a reference to it when you create it, in a place where you can
access it later. And what do you mean by "append messages to it"?

···

--
Tim Roberts, timr@probo.com
Providenza & Boekelheide, Inc.

Werner

···

On 4/21/2015 9:21, sandyethadka wrote:

Thanks a lot....It worked....

Could you tell me how FindWindowByName works? I couldn't find any example
implementing it....
I need to identify and open an open frame to append messages to it.....I
could only find syntax and am having trouble understanding it.....Throws
unbound method error....I know that this error pops up when a method is
called using a wrong object....But I cannot call this method using a
wx.Window object as that is what am trying to obtain in the first place....

Thanks a lot in advance.....