On Fri, Mar 21, 2014 at 12:30 PM, Chris Barker <[email protected]>wrote:

> if you want to suggest a cleaner API for that, I could add it.
>

got it.

I made .Scale and .ViewPOrtCenter properties, so tehy can do the right
thing if you set them directly. So you can now do:

class TestFrame(wx.Frame):
    def __init__(self, *args, **kwargs):
        wx.Frame.__init__(self, *args, **kwargs)
        self.canvas =FloatCanvas.FloatCanvas(self, BackgroundColor = "DARK
SLATE BLUE")
        MainSizer = wx.BoxSizer(wx.VERTICAL)
        MainSizer.Add(self.canvas, 4, wx.EXPAND)
        self.SetSizer(MainSizer)
        img = wx.Image('mypng(309x34).png')
        A = self.canvas.AddScaledBitmap(img, (0,0), Height=img.GetHeight(),
Position = 'tl')
        A.Bind(FloatCanvas.EVT_FC_MOTION, self.OnMotion)

        self.canvas.Scale = 1.0
        self.canvas.ViewPortCenter  = (154, -17)

    def OnMotion(self, event):
        x, y = event.HitCoords[0] - event.BoundingBox[0,0],
event.BoundingBox[1,1] - event.HitCoords[1]
        print self.canvas.Scale, x, y

app = wx.App(0)
frame = TestFrame(None, title="Image hitcoords", size=(350,200))
frame.Show(True)
app.MainLoop()

now in SVN, along with this demo.

-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

[email protected]
_______________________________________________
FloatCanvas mailing list
[email protected]
http://mailman.paulmcnett.com/cgi-bin/mailman/listinfo/floatcanvas

Reply via email to