Hi
I am trying to get the mouse position on my Canvas
# -*- coding: cp1250 -*-
import wx
class Okno:
def __init__(self,parent):
self.okno=wx.MDIChildFrame(parent,title=u"Náhled situace",id=-1)
self.okno.Maximize()
self.okno.SetAutoLayout(True)
self.okno.SetBackgroundColour("#FCFCFE")
self.sizer = wx.FlexGridSizer(2,2,0,0)
# Add canvas
self.platno = wx.ScrolledWindow(self.okno, id=wx.ID_ANY)
self.platno.EnableScrolling(True, True)
self.sirka = 10000
self.vyska = 10000
self.platno.SetScrollbars(20, 20, self.sirka/20, self.vyska/20)
self.sizer.Add(self.platno, 1, wx.EXPAND)
self.sizer.Add((0,0))
self.sizer.Add((0,0))
self.sizer.Add((0,0))
self.sizer.AddGrowableRow(0, 1)
self.sizer.AddGrowableCol(0, 1)
self.platno.Bind(wx.EVT_MOTION, self.Pohyb)
self.okno.SetSizer(self.sizer)
def Pohyb(self, akce):
print akce.GetPosition()#doesnt work correctly
if __name__ == "__main__":
okno = wx.App(0)
parent=wx.MDIParentFrame(None,size=wx.Size(500,500))
Okno(parent)
parent.Show()
okno.MainLoop()
if i move the mouse, i will see coordinates of mouse not in canvas but in window. I have to get canvas coordinates. Is there some way how to solve it?
Thanks!