Need to add httpd support to this wxPython code
I need to add httpd support to this sample wxpython code.
It parses the url and display different images.
What's the easiest way to do this?
import wx
a = wx.PySimpleApp()
wximg = wx.Image('w.png',wx.BITMAP_TYPE开发者_JAVA技巧_PNG)
wxbmp=wximg.ConvertToBitmap()
f = wx.Frame(None, -1, "Show JPEG demo")
f.SetSize( wxbmp.GetSize() )
wx.StaticBitmap(f,-1,wxbmp,(0,0))
f.Show(True)
def callback(evt,a=a,f=f):
# Closes the window upon any keypress
f.Close()
a.ExitMainLoop()
wx.EVT_CHAR(f,callback)
a.MainLoop()
Problem solved.
Need to add
from BaseHTTPServer import BaseHTTPRequestHandler, HTTPServer
....
class w_HttpThread(threading.Thread):
def __init__(self, win):
...
On particular URL, do wx.PostEvent to the wx windows.
wxWindows code will update the window with new image.
It works too. Love python!
精彩评论