I again and again sorry to bother you with the same problem..
I'm always trying to avoid the multiple instance of the same application and also passing to the previous instance a parameter (the
file to be opened).
I've tried using a XMLRPC server (but also with a simple socketserver) in the first instance. The problem was that I need to place
this server in a different thread (using thread.start_new_thread) otherwise the app did not continue to work..
In this way the app work correctly and correctly receive the param from the other instances and correctly open the files.. But after
open the file it crashes tell me that it cannot make operations (the STC operations i made with the opened files) because it's not
the main thread (wxThread.IsMain).
I again and again sorry to bother you with the same problem..
I'm always trying to avoid the multiple instance of the same application and also passing to the previous instance a parameter (the
file to be opened).
I've tried using a XMLRPC server (but also with a simple socketserver) in the first instance. The problem was that I need to place
this server in a different thread (using thread.start_new_thread) otherwise the app did not continue to work..
In this way the app work correctly and correctly receive the param from the other instances and correctly open the files.. But after
open the file it crashes tell me that it cannot make operations (the STC operations i made with the opened files) because it's not
the main thread (wxThread.IsMain).
Was completely wrong my approach to the problem?
Not completely. When you get the message on your socket thread, you need to pass the filename (or whatever) to your gui thread for processing as you should not do any gui operation directly in the other threads. An easy way to do it would be to use wxCallAfter to cause a method of your app or main frame to be invoked later (normally ASAP) in the context of the gui thread. For example:
wxCallAfter(mainFrame.OpenFile, filename)
···
--
Robin Dunn
Software Craftsman http://wxPython.org Java give you jitters? Relax with wxPython!
::Not completely. When you get the message on your socket
::thread, you need to pass the filename (or whatever) to your
::gui thread for processing as you should not do any gui
::operation directly in the other threads. An easy way to do
::it would be to use wxCallAfter to cause a method of your app
::or main frame to be invoked later (normally ASAP) in the
::context of the gui thread. For example:
::
:: wxCallAfter(mainFrame.OpenFile, filename)
But do you think this is a correct solution? Or i'm using a bad way to solve my problem?
::Not completely. When you get the message on your socket ::thread, you need to pass the filename (or whatever) to your ::gui thread for processing as you should not do any gui ::operation directly in the other threads. An easy way to do ::it would be to use wxCallAfter to cause a method of your app ::or main frame to be invoked later (normally ASAP) in the ::context of the gui thread. For example:
::
:: wxCallAfter(mainFrame.OpenFile, filename)
But do you think this is a correct solution? Or i'm using a bad way to solve my problem?
Correctness is very subjective, but there is nothing technicaly wrong with using wxCallAfter to pass data from the worker thread to the gui therad.
···
--
Robin Dunn
Software Craftsman http://wxPython.org Java give you jitters? Relax with wxPython!