Marlin Rowley wrote:
class runMentalRayThread(threading.Thread):
...
self.renderBuffer.InitBuffer() <<<<<<<<<<< Function call
you cant call wx calls directly from the thread. this needs to be something like:
wx.CallAfter(self.renderBuffer.InitBuffer)
Though that's pretty coupled, I'd pass in a reference to the method you need called, instead of the Window.
I want to clear the window of all bitmaps at this point so I call the renderWindow.InitBuffer():
class RenderWindow(wx.Window):
def __init__(self,parent,ID,pos,size):
wx.Window.__init__(self,parent,ID,pos,size)# Our initial buffer must be set and background cleared. def InitBuffer(self):
print 'InitBuffer() called...'
size = self.GetClientSize()
self.buffer = wx.EmptyBitmap(size.width,size.height)
self.dc = wx.BufferedDC(None,self.buffer)
Here's your problem -- you've passed in None for the underlying DC, so you haven't connected to the Window at all. You need something like:
dc = wx.BufferedDC(wx.CientDC(self), self.buffer)
self.dc.SetBackground(wx.Brush(self.GetBackgroundColour()))
self.dc.Clear()
You could also put a self.Refresh(); self.Update() in here -- that will force a paint event. In that case, you're Paint handler needs to look something like:
def OnPaint(self, evt):
dc = wx.BufferedPaintDC(self, self.buffer)
Do read the DoubleBuffered page in teh Wiki.. Also look for "long running tasks"
I can access the device context that was created in the InitBuffer() function.
In general, you don't want to keep DCs around -- you keep the beffer around, then create an appropriate DC when you need to draw.
-Chris
···
--
Christopher Barker, Ph.D.
Oceanographer
Emergency Response Division
NOAA/NOS/OR&R (206) 526-6959 voice
7600 Sand Point Way NE (206) 526-6329 fax
Seattle, WA 98115 (206) 526-6317 main reception
Chris.Barker@noaa.gov