]> git.saurik.com Git - wxWidgets.git/blame - wxPython/demo/DragScroller.py
Added wx.lib.expando, a multi-line textctrl that exands as more lines
[wxWidgets.git] / wxPython / demo / DragScroller.py
CommitLineData
f77c79d0
RD
1import wx
2import wx.lib.dragscroller
3
4#-------------------------------------------------------------------------------
5
6def runTest(frame, nb, log):
7 win = DragScrollerExample(nb, -1)
8 return win
9
10class 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)
16
17 self.SetScrollbars(1, 1, 2000, 2000, 0, 0)
18
19 self.scroller = wx.lib.dragscroller.DragScroller(self)
20
21 def OnPaint(self, event):
22 dc = wx.PaintDC(self)
23 self.DoPrepareDC(dc)
24
25 pen = wx.Pen(wx.BLACK, 5)
26 dc.SetPen(pen)
27
28 for y in range(10):
29 for x in range(10):
30 dc.DrawCircle(x*400+20, y*400+20, 200)
31
32 dc.DrawText('Right click and drag in the direction you want to scroll.',
33 20, 20)
34 dc.DrawText('The distance from the start of the drag determines the speed.',
35 20, 50)
36
37 def OnRightDown(self, event):
38 self.scroller.Start(event.GetPosition())
39
40 def OnRightUp(self, event):
41 self.scroller.Stop()
42
43
44#-------------------------------------------------------------------------------
45
46overview = """<html><body>
47<h2>DragScroller</h2>
48<p>
49A helper class that adds scrolling to a wx.ScrolledWindow in the direction
50of the drag.
51</body></html>
52"""
53
54if __name__ == '__main__':
55 import sys,os
56 import run
57 run.main(['', os.path.basename(sys.argv[0])])