]>
git.saurik.com Git - wxWidgets.git/blob - wxPython/demo/DragScroller.py
2 import wx
.lib
.dragscroller
4 #-------------------------------------------------------------------------------
6 def runTest(frame
, nb
, log
):
7 win
= DragScrollerExample(nb
, -1)
10 class DragScrollerExample(wx
.ScrolledWindow
):
11 def __init__(self
, parent
, id=-1):
12 wx
.ScrolledWindow
.__init
__(self
, parent
, id)
13 self
.Bind(wx
.EVT_PAINT
, self
.OnPaint
)
14 self
.Bind(wx
.EVT_RIGHT_DOWN
, self
.OnRightDown
)
15 self
.Bind(wx
.EVT_RIGHT_UP
, self
.OnRightUp
)
17 self
.SetScrollbars(1, 1, 2000, 2000, 0, 0)
19 self
.scroller
= wx
.lib
.dragscroller
.DragScroller(self
)
21 def OnPaint(self
, event
):
25 pen
= wx
.Pen(wx
.BLACK
, 5)
30 dc
.DrawCircle(x
*400+20, y
*400+20, 200)
32 dc
.DrawText('Right click and drag in the direction you want to scroll.',
34 dc
.DrawText('The distance from the start of the drag determines the speed.',
37 def OnRightDown(self
, event
):
38 self
.scroller
.Start(event
.GetPosition())
40 def OnRightUp(self
, event
):
44 #-------------------------------------------------------------------------------
46 overview
= """<html><body>
49 A helper class that adds scrolling to a wx.ScrolledWindow in the direction
54 if __name__
== '__main__':
57 run
.main(['', os
.path
.basename(sys
.argv
[0])])