Hi, this is my code:

# -*- coding: cp1250 -*-
import  wx
class Okno:
    def __init__(self,parent=None,id=wx.ID_ANY,title="Graf"):
        self.okno=wx.MDIChildFrame(parent,title="Graf",id=-1)
        self.okno.Maximize()
        self.okno.SetAutoLayout(True)
        self.okno.SetBackgroundColour("#FCFCFE")       
        self.sizer = wx.FlexGridSizer(2,2,0,0)
        self.canvas = wx.ScrolledWindow(self.okno, id=wx.ID_ANY)
        self.canvas.EnableScrolling(True, True)        
        self.canvas.SetScrollbars(20, 20, 1000/20, 1000/20)
        self.sizer.Add(self.canvas, 1, wx.EXPAND)
        self.sizer.AddGrowableRow(0, 1)
        self.sizer.AddGrowableCol(0, 1)  
        self.okno.SetSizer(self.sizer)
        self.canvas.Bind(wx.EVT_PAINT, self.OnPaint)        
    
    def OnPaint(self, event):
        pass
if __name__ == "__main__":
    okno = wx.App(0)
    parent=wx.MDIParentFrame(None,size=wx.Size(500,500))
    o=Okno(parent)
    parent.Show()
    okno.MainLoop()

As you can see, its scrolled canvas and i need to get current coordinates of part of canvas which i can see (sory my english). For exapmle: If i run my code, that left up corner is (0,0) and down right corner is (500,500).

Thanks!

This will give the mouse position within the whole scrolled canvas ...

"""
# -*- coding: cp1250 -*-
"""
# get coordinates of whole scrolled canvas
 
import  wx
 
class Okno:
    def __init__(self,parent=None,id=wx.ID_ANY,title="Graf"):
        self.okno=wx.MDIChildFrame(parent,title="Graf",id=-1)
        self.okno.Maximize()
        self.okno.SetAutoLayout(True)
        self.okno.SetBackgroundColour("#FCFCFE")       
        self.sizer = wx.FlexGridSizer(2,2,0,0)
        self.canvas = wx.ScrolledWindow(self.okno, id=wx.ID_ANY)
        self.canvas.EnableScrolling(True, True)        
        self.canvas.SetScrollbars(20, 20, 1000/20, 1000/20)
        self.sizer.Add(self.canvas, 1, wx.EXPAND)
        self.sizer.AddGrowableRow(0, 1)
        self.sizer.AddGrowableCol(0, 1)  
        self.okno.SetSizer(self.sizer)
        self.canvas.Bind(wx.EVT_PAINT, self.OnPaint)
 
        # hook left mouse button event
        self.canvas.Bind(wx.EVT_LEFT_DOWN, self.OnLeftDown)
 
    def OnPaint(self, event):
        pass
    
    def OnLeftDown(self, event):
        """left mouse button is pressed"""
        device_pt = event.GetPosition()  # tuple (x, y)
        # need to add current scrollbar value logic_pt to device_pt
        # if you want position relative to whole canvas
        logic_pt = self.canvas.CalcUnscrolledPosition(0, 0)
        #print device_pt, logic_pt
        adjusted_pt = (device_pt[0]+logic_pt[0], device_pt[1]+logic_pt[1])
        self.okno.SetTitle('LeftMouse = ' + str(adjusted_pt))
 
if __name__ == "__main__":
    okno = wx.App(0)
    parent=wx.MDIParentFrame(None,size=wx.Size(500,500))
    o=Okno(parent)
    parent.Show()
    okno.MainLoop()

Lol, solved... i am really noob. The solution is:

up_left_corner=self.canvas.CalcUnscrolledPosition(0, 0)
dow_right_corner=self.canvas.CalcUnscrolledPosition(width_canvas, height_canvas)
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.