OiO.lk Community platform!

Oio.lk is an excellent forum for developers, providing a wide range of resources, discussions, and support for those in the developer community. Join oio.lk today to connect with like-minded professionals, share insights, and stay updated on the latest trends and technologies in the development field.
  You need to log in or register to access the solved answers to this problem.
  • You have reached the maximum number of guest views allowed
  • Please register below to remove this limitation

Python use wx.CallAfter into HttpServer

  • Thread starter Thread starter semantic-dev
  • Start date Start date
S

semantic-dev

Guest
I am using python 2.7 and wxPython 2.8. I created a simple desktop application from which the user can start an HTTPServer created from the one builtin in python itself. Server is created in this way:

class Services(Thread): def init(self): Thread.init(self)

Code:
def run(self):        
    http_server = BaseHTTPServer.HTTPServer(('',  9020)), RESTRequestHandler)        
    http_server.serve_forever()

in another piece of code I am using wxPrinting facilities to send HTML to printer so I am trying to reuse the same code in a rest api by doing the following (I am simplyfing):

Code:
def save(handler):
    manager = Manager('Samuel')
    wx.CallAfter(manager.do_print) #do_print is a method already used in another part of UI code and it is working)

if I don't use wx.CallAfter I got the error "only the main thread can process Windows messages".

But in this way the code seems working only in older windows system like Windows XP meanwhile in Windows 10 nothing happens.

HTTPServer has been created starting from https://gist.github.com/tliron/8e9757180506f25e46d9

thanks for any help
<p>I am using python 2.7 and wxPython 2.8. I created a simple desktop application from which the user can start an HTTPServer created from the one builtin in python itself. Server is created in this way:</p>
<p>class Services(Thread):
def <strong>init</strong>(self):
Thread.<strong>init</strong>(self)</p>
<pre><code>def run(self):
http_server = BaseHTTPServer.HTTPServer(('', 9020)), RESTRequestHandler)
http_server.serve_forever()
</code></pre>
<p>in another piece of code I am using wxPrinting facilities to send HTML to printer so I am trying to reuse the same code in a rest api by doing the following (I am simplyfing):</p>
<pre><code>def save(handler):
manager = Manager('Samuel')
wx.CallAfter(manager.do_print) #do_print is a method already used in another part of UI code and it is working)
</code></pre>
<p>if I don't use wx.CallAfter I got the error "only the main thread can process Windows messages".</p>
<p>But in this way the code seems working only in older windows system like Windows XP meanwhile in Windows 10 nothing happens.</p>
<p>HTTPServer has been created starting from
<a href="https://gist.github.com/tliron/8e9757180506f25e46d9" rel="nofollow noreferrer">https://gist.github.com/tliron/8e9757180506f25e46d9</a></p>
<p>thanks for any help</p>
 

Online statistics

Members online
0
Guests online
5
Total visitors
5
Top