- Notifications
You must be signed in to change notification settings - Fork 21
Expand file tree
/
Copy pathScrolledBitmap.py
More file actions
Latest commit
executable file
·63 lines (40 loc) · 1.46 KB
/
Copy pathScrolledBitmap.py
File metadata and controls
executable file
·63 lines (40 loc) · 1.46 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#!/usr/bin/env python
"""
Putting an image in a Scrolled Window
And drawing something over it.
"""
importwx
# set an image file here
img_filename='Images/white_tank.jpg'
classMyCanvas(wx.ScrolledWindow):
def__init__(self, *args, **kwargs):
wx.ScrolledWindow.__init__(self, *args, **kwargs)
self.bmp=wx.Image(img_filename).ConvertToBitmap()
self.maxWidth, self.maxHeight=self.bmp.GetWidth(), self.bmp.GetHeight()
self.SetScrollbars(20, 20, self.maxWidth/20, self.maxHeight/20)
self.Bind(wx.EVT_PAINT, self.OnPaint)
# an arbitrary rect to draw -- in pixel coords of the image
self.rect= (200, 200, 300, 200) # x, y, width, height
defOnPaint(self, event):
dc=wx.PaintDC(self)
self.PrepareDC(dc)
dc.SetPen(wx.Pen(wx.RED, 2))
dc.SetBrush(wx.Brush((255, 255, 255, 85)))
dc.DrawBitmap(self.bmp, 0, 0)
dc.DrawRectangle(*self.rect)
classTestFrame(wx.Frame):
def__init__(self, *args, **kwargs):
wx.Frame.__init__(self, *args, **kwargs)
self.Bind(wx.EVT_CLOSE, self.OnCloseWindow)
self.Canvas=MyCanvas(self)
defOnCloseWindow(self, event):
self.Destroy()
classApp(wx.App):
defOnInit(self):
frame=TestFrame(None, title="Scroll Test", size=(800, 700))
self.SetTopWindow(frame)
frame.Show(True)
returnTrue
if__name__=="__main__":
app=App(False)
app.MainLoop()