I am having problems with the program I am writing, and I would appreciate some help or input. For some background, I use Python 2.7 and wxPython in order to make the webcam client streamed. The client receives images from the server in its stream and puts them in the queue. The GUI thread then receives these images from the queue and converts them into an object wxBitmap. This happens every 0.5 seconds and works great. I can save the object wxBitmapas a file so that I know that everything is working correctly.
The problem I am facing is that the object is wxBitmapdisplayed in my GUI. The only thing I can do to make the GUI is to show the gray rectangle where the webcam image should be.
Here is mine onPaint()that gets called when I want to refresh the screen:
def onPaint(self,e):
print "in onPaint"
dc = wx.PaintDC(self)
dc.BeginDrawing()
dc.DrawBitmap(self.imageBit,0,0,True)
dc.EndDrawing()
self.imageBit.SaveFile("bit.bmp", wx.BITMAP_TYPE_BMP)
Simply put, I do not understand why it does not work. from my research, I found that since I am on a Windows machine, I need functions BeginDrawing()and EndDrawing()therefore I added them. Still not working. No errors or exceptions.
Other issues that may help solve this problem:
- I am updating an object
wxFrame. Maybe it wxPaintDCshould work in a container of a different type? - ?
Actually, maybe my function __init__is the problem. Am I setting it right?
class viewWindow(wx.Frame):
imgSizer = (480,360)
def __init__(self, *args, **kw):
super(viewWindow,self).__init__(*args,**kw)
self.pnl = wx.Panel(self)
self.image = wx.EmptyImage(self.imgSizer[0],self.imgSizer[1])
self.imageBit = wx.BitmapFromImage(self.image)
self.timex = wx.Timer(self, wx.ID_OK)
self.timex.Start(500)
self.Bind(wx.EVT_TIMER, self.redraw, self.timex)
self.Bind(wx.EVT_PAINT, self.onPaint)
self.SetSize(self.imgSizer)
self.SetTitle('View Window')
self.Show()
, .
EDIT: , self.pnl = wx.Panel(self).
, , . ? . wxPython.