draw a line to cursor

AWESOME!! Got it, there is a world of difference in performance now!
Thank you very much Alex.

-Cole

Cole Harris
Enterasys Networks
Phone: 978-684-1652
Email: coharris@enterasys.com
www. http://www.enterasys.com

···

-----Original Message-----
From: Alex Tweedly [mailto:alex@tweedly.net]
Sent: Thursday, September 01, 2005 4:22 PM
To: wxPython-users@lists.wxwidgets.org
Subject: Re: [wxPython-users] draw a line to cursor

Harris, Cole wrote:

Alex,

Thanks for the help, I added your code but it is not working properly.
I can see that it somewhat erases the lines but many are still drawn
just opaquely. Does that make sense? I pretty much just added your
code.

Doesn't really make sense to me. It sounds like maybe you're not
undrawing it properly; you need to be sure that on each movement, if you

have a previously drawn line, that you "undraw" it with the old co-ords,

then draw (and remember) the new line to the new mouse coords.

Here's some sample code (unfortunately, in PythonCard rather than raw
wxPython - it would take me a while to convert it to raw wxPython, but
hopefully it is clear enough ...)

class MyBackground(model.Background):

    def on_initialize(self, event):
        self.rootX, self.rootY = None, None
        dc = wx.ClientDC(self.components.BitmapCanvas1)
        dc.SetPen(wx.Pen('black', 1, wx.DOT))
        dc.SetBrush(wx.TRANSPARENT_BRUSH)
        dc.SetLogicalFunction(wx.INVERT)
        self.dc = dc
        self.banding = False

    def on_BitmapCanvas1_mouseUp(self, event):
        print event.x, event.y
        self.rootX, self.rootY = event.x, event.y
        self.lastX, self.lastY = self.rootX, self.rootY
        self.banding = True
   
    def on_BitmapCanvas1_mouseMove(self, event):
        if self.banding:
            if self.lastX <> self.rootX or self.lastY <> self.rootY:
                # undraw last one
                self.dc.DrawLine(self.rootX, self.rootY, self.lastX,
self.lastY)
           
            self.lastX, self.lastY = event.x, event.y
            self.dc.DrawLine(self.rootX, self.rootY, self.lastX,
self.lastY)
       
--
Alex Tweedly http://www.tweedly.net

--
No virus found in this outgoing message.
Checked by AVG Anti-Virus.
Version: 7.0.344 / Virus Database: 267.10.18/86 - Release Date:
31/08/2005

---------------------------------------------------------------------
To unsubscribe, e-mail: wxPython-users-unsubscribe@lists.wxwidgets.org
For additional commands, e-mail: wxPython-users-help@lists.wxwidgets.org