#!/usr/bin/python import urllib from wxPython import wx from wxPython.wx import wxImageFromStream, wxBitmapFromImage, wxTimer from cStringIO import StringIO import wx url = 'http://www.welikesheep.com/archives/lucyliu.jpg' class MyImage(wx.Image): fp = urllib.urlopen(url) data = fp.read() fp.close() img = wx.ImageFromStream(StringIO(data)) img.Rescale (640,480) class MyFrame(wx.Frame): def __init__(self, parent, id, title): wx.Frame.__init__(self, parent, id, title, size = (640,480)) self.bitmap=wxBitmapFromImage(MyImage.img) wx.EVT_PAINT(self, self.OnPaint) self.Centre() def OnPaint(self, event): dc = wx.PaintDC(self) dc.DrawBitmap(self.bitmap, 10, 10) def refresh(self): self.bitmap=wxBitmapFromImage(MyImage.img) wx.EVT_PAINT(self, self.OnPaint) self.Centre() class MyApp(wx.App): def OnInit(self): frame = MyFrame(None, -1, 'CamView') frame.Show(True) self.SetTopWindow(frame) return True class MyTimer(wxTimer): def Notify(self): print 'tick' app = MyApp(0) t = MyTimer() t.Start(1000) app.MainLoop()