1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 from elisa.core.utils import signal
18
19 import pgm
20 from pgm.graph.group import Group
21 from pgm.graph.image import Image
22 from pgm.graph.text import Text
23
41
117
118
119
120 -class ContextBar(Group):
121
122 - def __init__(self):
123 Group.__init__(self)
124
125 self._button_panel = ButtonPanel()
126 self._button_panel.visible = True
127 self.add(self._button_panel)
128
129 self._button_panel.z = 0.05
130
131 self.background = Image()
132 self.background.bg_color = (0, 0, 0, 0)
133 self.background.layout = pgm.IMAGE_FILLED
134 self.background.interp = pgm.IMAGE_NEAREST
135 self.background.visible = True
136 self.add(self.background)
137
138 self.icon = Image()
139 self.icon.bg_color = (0, 0, 0, 0)
140 self.icon.layout = pgm.IMAGE_SCALED
141 self.icon.size = (self.width*0.08, self.height*0.8)
142 self.icon.position = (0.0, (self.height-self.icon.height)/2.0, 0.0)
143 self.icon.visible = True
144 self.add(self.icon)
145
146 self._label = Text()
147 self._label.bg_color = (0, 0, 0, 0)
148 self._label.font_family = "Bitstream DejaVu"
149 self._label.weight = pgm.TEXT_WEIGHT_BOLD
150 self._label.font_height = 0.10
151 self._label.position = (self.icon.width, self.height*0.17, 0.0)
152 self._label.size = (self.width-self._label.x, self.height-self._label.y)
153 self._label.visible = True
154 self.add(self._label)
155
156 - def compute_layout(self):
157 self._button_panel.compute_layout()
158
159 - def label__set(self, label):
160 self._label.label = label
161
162 - def label__get(self):
164
166 return self._button_panel
167
168 if __name__ == "__main__":
170 if event.type == pgm.KEY_PRESS:
171
172 if event.keyval in (pgm.keysyms.q, pgm.keysyms.Escape):
173 pgm.main_quit()
174
177
178
179 factory = pgm.ViewportFactory('opengl')
180 gl = factory.create()
181 gl.title = 'Context bar widget'
182
183
184 canvas = pgm.Canvas()
185
186
187 gl.set_canvas(canvas)
188 gl.show()
189
190 context = ContextBar()
191 context.background.set_from_file("theme/context_bar_bg.png")
192 context.label = "Music"
193 context.icon.set_from_file("../poblenou_frontend/tango_theme/music.png")
194
195 context.canvas = canvas
196 context.position = (0.0, 0.0, 0.0)
197 context.width = canvas.width
198 context.height = 0.2
199 context.visible = True
200
201
202 gl.connect('key-press-event', on_key_press, context)
203 gl.connect('delete-event', on_delete)
204 pgm.main()
205