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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
|
from gettext import gettext as _
import gtk
class Broadcast():
"""Broadcast component for Classroom Kit Activity
"""
# Constants
_greenColor = '#00E500'
_redColor = '#FF0000'
# I18N
_START = _('Start')
_STOP = _('Stop')
# UI elements
_box = None
_button = None
_label = None
_toolbar = None
_boxAlign = None
def __init__(self, activity):
"""Constructor
"""
self._activity = activity
def loadUI(self):
"""Create and show UI
"""
# Box
self._box = gtk.VBox()
# Label
self._label = gtk.Label()
# Button
self._button = gtk.Button()
self._button.set_size_request(200, 100)
self._button.connect("clicked", self.buttonClicked)
# Add button to box
self._box.pack_start(self._button)
# Add label to box
self._box.pack_start(self._label, padding=20)
# Box Align (xalign, yalign, xscale, yscale)
self._boxAlign = gtk.Alignment(0.5, 0.5, 0, 0)
self._boxAlign.add(self._box)
# Set canvas with box alignment
self._activity.set_canvas(self._boxAlign)
def setButtonBG(self, color):
"""Change button bg color
"""
self._button.modify_bg(gtk.STATE_NORMAL, gtk.gdk.color_parse(color))
def setButtonLabel(self, txt):
"""Change button label
"""
self._button.set_label(txt)
def buttonClicked(self, widget, data=None):
"""Button clicked event handler
"""
pass
def setLabelTXT(self, txt):
"""Change label text
"""
self._label.set_label(txt)
def showStatus(self):
"""Show VNC status
"""
state = "off"
if state == "off":
self.setButtonBG(self._greenColor)
self.setButtonLabel(self._START)
self.setLabelTXT("")
else:
self.setButtonBG(self._redColor)
self.setButtonLabel(self._STOP)
self.setLabelTXT("")
|