forked from PythonCHB/wxPythonDemos
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGenStaticBitmap.py
More file actions
executable file
·60 lines (42 loc) · 1.62 KB
/
Copy pathGenStaticBitmap.py
File metadata and controls
executable file
·60 lines (42 loc) · 1.62 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
#!/usr/bin/env python
import wx
import wx.lib.statbmp
class cWindowBitmap(wx.lib.statbmp.GenStaticBitmap):
"""
A subclass of GenStaticBitmap, that adds some functionality
"""
def __init__(self, parent, bitmapfilename, ImageNumber, **kwargs):
self.bitmap = wx.Bitmap(bitmapfilename)
wx.lib.statbmp.GenStaticBitmap.__init__(self, parent, wx.ID_ANY, self.bitmap, **kwargs)
self.parent = parent
self.filename = bitmapfilename
self.ImageNumber = ImageNumber
self.Bind(wx.EVT_LEFT_DOWN,self.OnLeftDown)
self.Bind(wx.EVT_LEFT_UP,self.OnLeftUp)
def OnLeftDown(self, event):
print "In Left Down of:", self.filename
self.parent.OnBitmapClicked(self.ImageNumber)
def OnLeftUp(self, event):
print "In Left Up of:", self.filename
class MainFrame(wx.Frame):
def __init__(self, *args, **kwargs):
wx.Frame.__init__(self, *args, **kwargs)
Sizer = wx.BoxSizer(wx.VERTICAL)
#These represent "many" bitmaps.
for i in range(3):
pic = cWindowBitmap(self, "Images/smalltest.jpg", i)
Sizer.Add(pic, 0, wx.ALL, 10)
self.SetSizerAndFit(Sizer)
wx.EVT_CLOSE(self, self.OnCloseWindow)
def OnBitmapClicked(self, ImageNumber):
print "Image: %i was clicked"%ImageNumber
def OnCloseWindow(self, event):
self.Destroy()
class App(wx.App):
def OnInit(self):
frame = MainFrame(None, -1, "wxWindowBitmap Test", wx.DefaultPosition,(550,600))
self.SetTopWindow(frame)
frame.Show(True)
return True
app = App(0)
app.MainLoop()