Attachment 'ButtonWindow_AgwButtonPanel_Mod.py'
Download 1 """
2 ButtonWindow_AgwButtonPanel_Mod.py
3
4 Demonstration of a typical use of the ButtonPanel.
5
6 Uses a modified version of wx.lib.agw.ButtonPanelthat automatically
7 left-justifies the buttonbar when a buttonbar label is used.
8
9 Ray Pasco 2012-05-27
10 pascor(at)verizon(dot)net
11
12 """
13
14 import sys
15
16 import wx
17 import AgwButtonPanel as abp
18
19 #------------------------------------------------------------------------------
20 ###############################################################################
21 #------------------------------------------------------------------------------
22
23 class AppFrame( wx.Frame ) :
24
25 def __init__( self, parent=None, id=-1, title='ButtonWindow_AgwButtonPanel_Mod',
26 pos=(400, 0), size=(400, 200) ) :
27
28 wx.Frame.__init__( self, parent, id, title, pos, size )
29 self.Bind( wx.EVT_CLOSE, self.OnClose )
30
31 mainPanel = wx.Panel( self, -1 )
32
33 #-----
34
35 vSizer = wx.BoxSizer( wx.VERTICAL )
36 mainPanel.SetSizer( vSizer )
37
38 alignment = abp.BP_ALIGN_LEFT
39 self.agwStyle = abp.BP_USE_GRADIENT
40
41 title = 'AgwButtonPanel'
42 self.btnPnl = abp.ButtonPanel( mainPanel, -1, title,
43 agwStyle=self.agwStyle, alignment=alignment)
44
45 self.btnPnl.SetStyle( self.agwStyle )
46
47 bpArt = self.btnPnl.GetBPArt()
48 bpArt.SetColour( abp.BP_GRADIENT_COLOUR_TO, wx.Colour( 235, 245, 245 ) ) # Top of bar
49 bpArt.SetColour( abp.BP_GRADIENT_COLOUR_FROM, wx.Colour( 175, 175, 220 ) ) # Bottom
50 bpArt.SetColour( abp.BP_SEPARATOR_COLOUR, wx.BLACK )
51 bpArt.SetColour( abp.BP_TEXT_COLOUR, (50, 50, 150) )
52 bpArt.SetMetric( abp.BP_BORDER_SIZE, 0) # Change to a 0 pixel border, Default is 1 pixel.
53
54 #-----
55
56 self.graBtnID = wx.NewId()
57 self.grabBtn = abp.ButtonInfo( self.btnPnl, self.graBtnID, GetBitmap_Camera_PNG() )
58 self.btnPnl.AddButton( self.grabBtn )
59 self.Bind( wx.EVT_BUTTON, self.OnButton, self.grabBtn )
60
61 self.doSoundBtnID = wx.NewId()
62 self.doSoundBtn = abp.ButtonInfo( self.btnPnl, self.doSoundBtnID, GetBitmap_DoSound_PNG() )
63 self.btnPnl.AddButton( self.doSoundBtn )
64 self.Bind( wx.EVT_BUTTON, self.OnButton, self.doSoundBtn )
65
66 self.saveFileBtnID = wx.NewId()
67 self.saveFileBtn = abp.ButtonInfo( self.btnPnl, self.saveFileBtnID, GetBitmap_SaveFile_PNG() )
68 self.btnPnl.AddButton( self.saveFileBtn )
69 self.Bind( wx.EVT_BUTTON, self.OnButton, self.saveFileBtn )
70
71 self.btnPnl.AddSeparator()
72
73 self.exitBtnID = wx.NewId()
74 self.exitBtn = abp.ButtonInfo( self.btnPnl, self.exitBtnID, GetBitmap_Exit_PNG() )
75 self.btnPnl.AddButton( self.exitBtn )
76 self.Bind( wx.EVT_BUTTON, self.OnButton, self.exitBtn)
77
78 vSizer.Add( self.btnPnl, 0, wx.EXPAND )
79
80
81 self.imgWin = wx.TextCtrl( mainPanel, -1, '', style=wx.TE_MULTILINE )
82 vSizer.Add( self.imgWin, 1, wx.EXPAND|wx.ALL,2 )
83
84 self.btnPnl.DoLayout() # The control's internal method
85 vSizer.Layout()
86
87 #end __init__
88
89 #----------------------------------
90
91 def OnButton( self, event ) :
92
93 eventID = event.GetId()
94
95 if eventID == self.graBtnID :
96
97 print '---- Grab Button Clicked'
98
99 elif eventID == self.doSoundBtnID :
100
101 print '---- DoSound Button Clicked'
102
103 elif eventID == self.saveFileBtnID :
104
105 print '---- SaveFile Button Clicked'
106
107 elif eventID == self.exitBtnID :
108
109 print '---- Exit Button Clicked'
110 self.Close()
111
112 else :
113
114 print '#### AppFrame::OnButton: UNKNOWN Event'
115 sys.exit(1)
116
117 #end if
118
119 #end def
120
121 #----------------------------------
122
123 def OnClose( self, event ) :
124
125 print '---- AppFrame::OnClose()'
126 self.Destroy()
127
128 #end def
129
130 #end class
131
132 #------------------------------------------------------------------------------
133
134 # This file was generated by Image2PyFile.py by Ray Pasco
135
136 from wx.lib.embeddedimage import PyEmbeddedImage
137
138 #---------------------------------------------------------------------
139
140 DoSound_PNG = PyEmbeddedImage(
141 'iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAABHNCSVQICAgIfAhkiAAAAKRJ'
142 'REFUWIXtl+EOgCAIhEN7/zdW+lVzDe2AnFvBz3Zyn1RXEqW8ray01D0A3gLgWngZgMfcDdAz'
143 '51oYBTMDIAaIxgSgGfuTVg1gueejNSoA1JxSJrQnSVFs2aVkeu8jaaYGETKJbyRhAARAAHhq'
144 'ly72AkSbkK2+11M1AU3GT/sfQCCQb4AZAIVAteaHEIGANN6T0TluzVTacr+GVuNrfZwNfw9w'
145 'AIOuTDsLmcpGAAAAAElFTkSuQmCC'
146 )
147
148 GetBitmap_DoSound_PNG = DoSound_PNG.GetBitmap
149
150 #---------------------------------------------------------------------
151
152 Exit_PNG = PyEmbeddedImage(
153 'iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAABHNCSVQICAgIfAhkiAAABatJ'
154 'REFUWIXFl3+IXFcVxz/n3Pvmvc7u7GR2M901W6W0K9JutmNMEwJW0xakSAVFVPxPgoIRsf6n'
155 'aCP+KME/xD8jSguR1KZ/SUURSm2lLU1KGpI6S2sK2exuadwf7uzMJk1mZufHu/5xX2Z26ySZ'
156 'TREPHO57j/vu+Z7f58L/maTfjYW9+64G1oJzOOeIcTgHLnkHEBFUlbjdph23e0oTEXCCOGrT'
157 'Z97YbvsFMJrfnn7m6FOUVkosLi+ytlahXC6zslKiVFphdXWVkeHt7N69m7/+5XlOvnkKG2r3'
158 'AAdihdRtBuMiXNOmAfoGULhviuHhYay1pMKAkZHt7NhRpVqtsrZW4e23/0ljvUEYhojAwsIs'
159 'Q6NhYmIhbjmCtJLLR9jmGHHLVLcEIAgCRBUbBIRRROzAGEsYhkRRSLPZplark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5c0gHwYKVy0+H05VzOYYyPpET4kWKR'
174 '/L69fPTQIaIHPo3OvsulpVXWyrWOlps9qahujoEt9QKcg3odgCfPneOu/Z8h95NDZCZ34uYX'
175 'WKlUeP3Ma0zP/ANj/NHGmE5jEpHOjHhLAFyrhQC/Kxb52EMPMnnkCK2hQd6bnePC9HneXZrh'
176 'ndVTlFr/IkgHiQXU9wRNSrDGmy4DW5sJgWPFInd/5ct84tDPuTRwO8vnzvPqmecozp2i0Whw'
177 'hRIStgnsAFb8ICsqqAhiYuTDuODpYpHbH/48Iwce4w3qnD72C96//D6zl6Ypt95jMJ1lMBjE'
178 'mgBV6VxErpldRBAnqOumQd8AZtoxuT27iL/3dV69eoETTz5DSeYwxhAOhXxEx8GAivoo72jq'
179 'usO5JjXgVlxw5uFH+MI3HuV8s8WJ2d/SzFUZ1CC5jjlUWpAM4YnCHeoY3QDiQMOO6L4BnG03'
180 'SS38qd/tN6RaWSFma1ez2vJi9ZU/KHHcxDmHSJob322v3zdcLEhMrW/E/0v6D2nb6JESJEFI'
181 'AAAAAElFTkSuQmCC'
182 )
183
184 GetBitmap_Exit_PNG = Exit_PNG.GetBitmap
185
186 #---------------------------------------------------------------------
187
188 SaveFile_PNG = PyEmbeddedImage(
189 'iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAABHNCSVQICAgIfAhkiAAAAX9J'
190 'REFUWIXtlkuO4zAMRIukFA8w6MUcKdtcIdfKFXKEnKo3+cD6mLLVi4YFA1EmCcY93rhWAkW4'
191 'HgoUTGBh0eScx8N+v5/V5Hg8PvSuAvwnEQCY2k3O87MQUbXOszu9qRVgBVgBVoAVYAVY/He8'
192 'eAKLA1QXkqlOpxOA74WCmcHMGIYBfd/f9RIRiAjGGBhjsN1u/x2g6zpsNhvsdrs7sK7rAAAi'
193 'AmstQghPDd8GaJoG1tq7ekoJzIyUEoDvNa7v+5LAoxXsbYAQQjGZqm3bYigi1Z5ZAC6XC0Sk'
194 'CjbVOB/MDCKCqs4DMA5fTSKCGCOMMcg5I8ZY6q8m8hTAOQdj7ttUFd57iAiGYYD3HtZaqOpb'
195 'a/1TgJxz9YOqClUFM6Nt2/IEh2EAM1cHt6Yx24cjS0RwzuF6vRaYnHMZwhACiAg5ZzjnoKq4'
196 '3W44n88vAYwJNNPi748/EDG4nj/Je59TSjgcDmBmxBghIiX6lFJ5kiPc3+ZmogZAfInyh/Rr'
197 'SfOiL48IuLcCZcmhAAAAAElFTkSuQmCC'
198 )
199
200 GetBitmap_SaveFile_PNG = SaveFile_PNG.GetBitmap
201
202 #---------------------------------------------------------------------
203
204 Camera_PNG = PyEmbeddedImage(
205 'iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAABHNCSVQICAgIfAhkiAAAAhhJ'
206 'REFUWIXNV0GK4zAQLGXyANs/SPyCZZ8RGJz7QIgv+YKfkIshV18yDOw9ZiHPWOYFwT8wesBk'
207 'NIelHVluxS0zYbdAEKR2dam7pVaUmj2Bw+f1wwCAUopdl8IYAwCYPc1ZormE5PfpNMn583o9'
208 'aiMSAAA/fmZBzt//1CK7WRDrA/DPBYhTIA1pKNR/fwqIwIUrzGc3htEIEJIkEZO2bTuY80Vg'
209 'Rs7cISH9DgSdgrZtOyG2IHsuVKgyVvLSNPUaXi4XAOOpkAiw0zEowkNZDj7Y5Hkn8O14vEuu'
210 'lBotSDvFcyJ2nRHIYZqmOJTlYN1FVVU9EXbE2OKkH4eyZHdvr485B4CiKDoRSqluA/v9HkmS'
211 '9AYgvAnfjkeRc1cEx0MgPrVcLg3tfJPn+PX62vtolWWoqgpFUQxIOEiEEscmz28RoA9fttue'
212 '8bmuOxHAeI933w6coE2edyLEzWi324nsbIGSh4yK49jEcewtQG7Hkv5AkfOJGNQAFyqqh1V2'
213 'ew1xxwu4HTESca5rXI3x8tJa0FXsOrevXpoL7YrBLyLbOcEV8VABrvN7cw8T8J2YJIAL9ZTw'
214 'TxLA5Zuri4cIoCNmi3Cdhz5ixTehLcIYw+52ygu6i4DbhAirLMO5rnGub/8LqNW6g0CX0PN6'
215 '7eXtuLTWJoqingNOBBFLILF/2W7RNM3fFGitEUWR11hrDQB3bTj7xWLhtWmaBgDwBacoI7H6'
216 '78+zAAAAAElFTkSuQmCC'
217 )
218
219 GetBitmap_Camera_PNG = Camera_PNG.GetBitmap
220
221 #------------------------------------------------------------------------------
222
223 if __name__ == '__main__' :
224
225 app = wx.App( redirect=False )
226 appFrame = AppFrame()
227 appFrame.Show()
228 app.MainLoop()
229
230 #end if
Attached Files
To refer to attachments on a page, use attachment:filename, as shown below in the list of files. Do NOT use the URL of the [get] link, since this is subject to change and can break easily.You are not allowed to attach a file to this page.