Is possible to do this:

from Tkinter import*
scy=Scrollbar()
scy.pack(side=RIGHT,fill=Y)
scx=Scrollbar(orient=HORIZONTAL)
scx.pack(side=BOTTOM,fill=X)
canvas=Canvas(xscrollcommand=scx.set,yscrollcommand=scy.set)
canvas.pack(fill=BOTH,side=LEFT,expand=1)
scx["command"]=canvas.xview
scy["command"]=canvas.yview
canvas["scrollregion"]=(-1000,-1000,1000,1000)
mainloop()

in wxPython??

Thanks for all post, i am new in wx:lol:

The wx.ScrolledWindow class manages scrolling for its client area, transforming the coordinates according to the scrollbar positions, and setting the scroll positions, thumb sizes and ranges according to the area in view.

There is also the wx.lib.scrolledpanel.ScrolledPanel() widget that expands on wx.ScrolledWindow.

Thanks, but Scrolled Window doesnt work:

import wx
class Canvas:
    def __init__(self,parent):
        self.okno=parent
        self.radic = wx.FlexGridSizer(3,2,0,0)
        self.canvas = wx.ScrolledWindow(self.okno, -1)
        self.radic.Add(self.canvas, 1, wx.EXPAND)
        self.radic.Add((0,0))
        self.radic.Add((0,0))
        self.radic.Add((0,0))
        self.radic.AddGrowableRow(0, 1)
        self.radic.AddGrowableCol(0, 1)
        self.canvas.SetCursor(wx.CROSS_CURSOR)
        self.canvas.Bind(wx.EVT_PAINT, self.OnPaint)
        self.okno.SetSizer(self.radic)
    def vykresli_graf(self,dc):
        dc.BeginDrawing()
        lines=[(-500,-500,50,50)]
        dc.DrawLineList(lines)
        dc.EndDrawing()
    def OnPaint(self, evt):
        dc = wx.PaintDC(self.canvas)
        self.vykresli_graf(dc)
if __name__ == "__main__":
    okno = wx.App(0)
    parent=wx.MDIParentFrame(None,size=wx.Size(500,500))
    child=wx.MDIChildFrame(parent,title="Graf",id=-1)
    Canvas(child)
    child.Maximize()
    parent.Show()
    okno.MainLoop()

there should be scrollbars now,because i cant see the line

I added some needed lines to your code, now it works. Somehow you have to refresh your drawing as you scroll:

import wx

class Canvas(wx.ScrolledWindow):
    def __init__(self,parent):
        self.okno=parent
        self.radic = wx.FlexGridSizer(3,2,0,0)
        self.canvas = wx.ScrolledWindow(self.okno, -1)
        
        # EnableScrolling(bool x_scrolling, bool y_scrolling)
        self.canvas.EnableScrolling(True, True)
        
        # SetScrollbars(int pixelsPerUnitX, int pixelsPerUnitY, int noUnitsX, 
        #      int noUnitsY, int xPos=0, int yPos=0, bool noRefresh=False)
        PAGE_WIDTH = 1000
        PAGE_HEIGHT = 1000 
        self.canvas.SetScrollbars(20, 20, PAGE_WIDTH/20, PAGE_HEIGHT/20)

        self.radic.Add(self.canvas, 1, wx.EXPAND)
        self.radic.Add((0,0))
        self.radic.Add((0,0))
        self.radic.Add((0,0))
        self.radic.AddGrowableRow(0, 1)
        self.radic.AddGrowableCol(0, 1)
        self.canvas.SetCursor(wx.CROSS_CURSOR)
        self.canvas.Bind(wx.EVT_PAINT, self.OnPaint)
        self.okno.SetSizer(self.radic)
        
    def vykresli_graf(self,dc):
        dc.BeginDrawing()
        lines=[(-500,-500,507,507)]
        dc.DrawLineList(lines)
        dc.EndDrawing()
        
    def OnPaint(self, evt):
        dc = wx.PaintDC(self.canvas)
        self.vykresli_graf(dc)
        
        
if __name__ == "__main__":
    okno = wx.App(0)
    parent=wx.MDIParentFrame(None,size=wx.Size(500,500))
    child=wx.MDIChildFrame(parent,title="Graf",id=-1)
    Canvas(child)
    child.Maximize()
    parent.Show()
    okno.MainLoop()

You have to add one important line!

def OnPaint(self, evt):
        dc = wx.PaintDC(self.canvas)
        # added this to keep drawing from messing up on srolling
        self.canvas.PrepareDC(dc)   
        self.vykresli_graf(dc)

Ye, thanks. This is i think my last question. I have code:

import wx
class Canvas:
    def __init__(self,parent):
        self.okno=parent
        self.okno.SetBackgroundColour("#FCFCFE")
        self.radic = wx.FlexGridSizer(2,2,0,0)
        self.canvas = wx.ScrolledWindow(self.okno, -1)
       
        self.canvas.EnableScrolling(True, True)
        
        
        self.P_WIDTH = 1000
        self.P_HEIGHT = 1000
        self.canvas.SetScrollbars(20, 20, self.P_WIDTH/20, self.P_HEIGHT/20)

        self.radic.Add(self.canvas, 1, wx.EXPAND)
        self.radic.Add((0,0))
        sizer=wx.BoxSizer(wx.VERTICAL)
        self.radic.Add(sizer, 1, wx.EXPAND)
        self.radic.Add((0,0))
        self.radic.AddGrowableRow(0, 1)
        self.radic.AddGrowableCol(0, 1)
        sizer2=wx.BoxSizer(wx.HORIZONTAL)
        sizer2.Add(wx.StaticText(self.okno,label="  f(y)=   "),0,wx.ALIGN_CENTER)
        self.vstup=wx.TextCtrl(self.okno)
        sizer2.Add(self.vstup,1,0,wx.ALL)
        sizer.Add(sizer2,0,wx.EXPAND)
        sizer3=wx.BoxSizer(wx.HORIZONTAL)
        button1=wx.Button(self.okno,label="Vykresli")
        sizer3.Add(button1,0,wx.ALIGN_RIGHT)
        sizer.Add(sizer3,0,wx.EXPAND)
        ##
        self.canvas.SetCursor(wx.CROSS_CURSOR)
        self.canvas.Bind(wx.EVT_PAINT, self.OnPaint)
        self.okno.SetSizer(self.radic)
        button1.Bind(wx.EVT_BUTTON,lambda e:self.vykresli())
        self.pocet=0
        self.dc=False
    def vykresli(self):
        
     
        self.canvas.PrepareDC(self.dc)
        self.dc.BeginDrawing()   
        self.dc.DrawLineList([(20,20,50,50)])
        self.dc.EndDrawing()
        
    def OnPaint(self, evt):
        print "on update"
        self.dc=wx.PaintDC(self.canvas)
        
           
        
            
if __name__ == "__main__":
    okno = wx.App(0)
    parent=wx.MDIParentFrame(None,size=wx.Size(500,500))
    child=wx.MDIChildFrame(parent,title="Graf",id=-1)
    Canvas(child)
    child.Maximize()
    parent.Show()
    okno.MainLoop()

why when i press "vykresli" the program will stop? When i press button, it should draw line and when i move scrollbar, the line should move...
Thanks for patience...

This question has already been answered. Start a new discussion instead.