[wxPython-users] Changes in ClientDC on OS-X

Christopher Barker Chris.Barker at noaa.gov
Mon Dec 10 16:26:18 PST 2007


Chris Mellon wrote:
> On Dec 10, 2007 2:34 PM, Christopher Barker <Chris.Barker at noaa.gov> wrote:
>> I've just noticed that some of my use of wx.ClientDC is now broken in OS=
-X.

> It's not well documented in wx, but this sort of drawing isn't well
> supported in OS X, and there's special mechanisms for doing it. These
> special mechanisms are implemented by the wxOverlay class. I don't
> know if it's documented except in the source yet.

Ouch, what a pain.

OK, so I've made a fairly small sample, and maybe someone can give me =

suggestions. Enclosed is a little demo -- It's a double buffered drawing =

window. Something get drawn to it, and the Paint handler does nothing =

but blit the buffer to the screen,

Some Mouse events are bound that allow you to draw a temporary line on =

the screen. The line starts where you left click, and if you drag, there =

is a line moving from the start point to the current mouse position. =

This method has worked fine on all platforms for years, and works on =

OS-X as of version 2.6.3.3. Nothing gets drawn with version 2.8.7.1. I"m =

not sure when it changed, but I think it was in the middle of a 2.8 version.

So how should I do this now???

Here is the code where the work is being done:

     def OnLeftDown(self, event):
         self.CaptureMouse()
         self.StartMove =3D event.GetPosition()
         self.PrevMove =3D None

     def OnLeftUp(self, event):
         if self.PrevMove is not None:
             self.DrawLine(event, New=3DFalse)
         self.StartMove =3D None
         self.PrevMove =3D None

     def OnMove(self, event):
         if event.Dragging() and event.LeftIsDown() and self.StartMove =

is not None:
             self.DrawLine(event)

     def DrawLine(self, event, New=3DTrue):
         dc =3D wx.ClientDC(self)
         dc.SetPen(wx.Pen('WHITE', 2, wx.SHORT_DASH))
         dc.SetBrush(wx.TRANSPARENT_BRUSH)
         dc.SetLogicalFunction(wx.XOR)
         if self.PrevMove is not None:
             print "Drawing Over old line:", self.StartMove, self.PrevMove
             dc.DrawLinePoint(self.StartMove, self.PrevMove)
         self.PrevMove =3D event.GetPosition()
         print "Drawing new line:", self.StartMove, self.PrevMove
         if New:
             dc.DrawLinePoint( self.StartMove, self.PrevMove )



-Chris

By the way, I have eggs for a couple 2.8 versions installed -- how do I =

specify which one to use?




-- =

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 at noaa.gov
-------------- next part --------------
A non-text attachment was scrubbed...
Name: ClientDCTest.py
Type: text/x-python
Size: 5414 bytes
Desc: not available
Url : http://lists.wxwidgets.org/pipermail/wxpython-users/attachments/20071=
210/afa7aac2/ClientDCTest.py


More information about the wxpython-users mailing list