precalculate foreground color and font size for performance
This commit is contained in:
parent
e9df0f0fc7
commit
462d3161e4
22
Window.py
22
Window.py
@ -8,6 +8,9 @@ class Window(object):
|
|||||||
self.conf = conf
|
self.conf = conf
|
||||||
self.count = 0
|
self.count = 0
|
||||||
self.connection = None
|
self.connection = None
|
||||||
|
self.fgcolor = ''.join(map(lambda x: '%02x' % int(0xFF * x),
|
||||||
|
self.conf['fgcolor']))
|
||||||
|
self.font_sz = 1024 * self.conf['font_size']
|
||||||
|
|
||||||
if not 'width' in self.conf:
|
if not 'width' in self.conf:
|
||||||
self.conf['width'] = 32
|
self.conf['width'] = 32
|
||||||
@ -36,16 +39,16 @@ class Window(object):
|
|||||||
|
|
||||||
self.label = gtk.Label('-')
|
self.label = gtk.Label('-')
|
||||||
|
|
||||||
v = gtk.Viewport()
|
self.viewport = gtk.Viewport()
|
||||||
v.set_shadow_type(gtk.SHADOW_OUT)
|
self.viewport.set_shadow_type(gtk.SHADOW_OUT)
|
||||||
v.add(self.label)
|
self.viewport.add(self.label)
|
||||||
v.connect('button-release-event', self.button_release)
|
self.viewport.connect('button-release-event', self.button_release)
|
||||||
v.set_events(gtk.gdk.BUTTON_RELEASE_MASK)
|
self.viewport.set_events(gtk.gdk.BUTTON_RELEASE_MASK)
|
||||||
v.modify_bg(gtk.STATE_NORMAL,
|
self.viewport.modify_bg(gtk.STATE_NORMAL,
|
||||||
gtk.gdk.Color(*map(lambda x: int(65535 * x),
|
gtk.gdk.Color(*map(lambda x: int(65535 * x),
|
||||||
self.conf['bgcolor'])))
|
self.conf['bgcolor'])))
|
||||||
|
|
||||||
self.window.add(v)
|
self.window.add(self.viewport)
|
||||||
|
|
||||||
self.connect()
|
self.connect()
|
||||||
|
|
||||||
@ -95,13 +98,10 @@ class Window(object):
|
|||||||
if self.connection is None:
|
if self.connection is None:
|
||||||
self.label.set_text('-')
|
self.label.set_text('-')
|
||||||
else:
|
else:
|
||||||
fgcolor = ''.join(map(lambda x: '%02x' % int(0xFF * x),
|
|
||||||
self.conf['fgcolor']))
|
|
||||||
sz = 1024 * self.conf['font_size']
|
|
||||||
self.label.set_markup(
|
self.label.set_markup(
|
||||||
('<span font_weight="bold" foreground="#%s" '
|
('<span font_weight="bold" foreground="#%s" '
|
||||||
'font_size="%d">%d</span>'
|
'font_size="%d">%d</span>'
|
||||||
% (fgcolor, sz, self.count)))
|
% (self.fgcolor, self.font_sz, self.count)))
|
||||||
|
|
||||||
def destroy_event(self):
|
def destroy_event(self):
|
||||||
self.disconnect()
|
self.disconnect()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user