diff options
author | Mattias Andrée <maandree@operamail.com> | 2014-03-02 15:29:24 +0100 |
---|---|---|
committer | Mattias Andrée <maandree@operamail.com> | 2014-03-02 15:30:11 +0100 |
commit | 6cadf2da966da7ad5f7b613e14b0cb30239f0b82 (patch) | |
tree | bda35326dfcbc4847d78e696e1f33450664971ab /src/__main__.py | |
parent | add xdisplay (diff) | |
download | xpybar-6cadf2da966da7ad5f7b613e14b0cb30239f0b82.tar.gz xpybar-6cadf2da966da7ad5f7b613e14b0cb30239f0b82.tar.bz2 xpybar-6cadf2da966da7ad5f7b613e14b0cb30239f0b82.tar.xz |
m + fix threading weirdness + add clock example
Signed-off-by: Mattias Andrée <maandree@operamail.com>
Diffstat (limited to '')
-rwxr-xr-x | src/__main__.py | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/src/__main__.py b/src/__main__.py index f381294..62dc7d0 100755 --- a/src/__main__.py +++ b/src/__main__.py @@ -91,6 +91,7 @@ class Bar: @variable font The default font @variable font_metrics The default font's metrics @variable font_height:int The height of the default font + @variable font_width:int The width of an 'X' with the default font @variable palette A 16-array of standard colours ''' @@ -117,6 +118,7 @@ class Bar: self.background = self.create_colour(*background) self.foreground = self.create_colour(*foreground) (self.font, self.font_metrics, self.font_height) = self.create_font(font) + self.font_width = self.text_width('X') self.palette = [0x000000, 0xCD656C, 0x32A679, 0xCCAD47, 0x2495BE, 0xA46EB0, 0x00A09F, 0xD8D8D8] self.palette += [0x555555, 0xEB5E6A, 0x0EC287, 0xF2CA38, 0x00ACE0, 0xC473D1, 0x00C3C7, 0xEEEEEE] self.palette = [((p >> 16) & 255, (p >> 8) & 255, p & 255) for p in self.palette] @@ -155,14 +157,14 @@ class Bar: ''' special = '─│┌┐└┘├┤┬┴┼╱╲╳←↓→↑\0' buf = '' - w = self.text_width('X') - 1 + w = self.font_width - 1 h = self.font_height + descent - 1 y_ = y - self.font_height for c in text + '\0': if c in special: if not buf == '': draw_text(self.window, self.gc, x, y, buf) - x += self.text_width(buf) + x += self.font_width * len(buf) buf = '' if not c == '\0': segs = [] @@ -261,7 +263,7 @@ class Bar: if not buf == '': self.change_colour(bc) h = self.font_height + ascent - w = self.text_width(buf) + w = self.font_width * len(buf) self.window.fill_rectangle(self.gc, x, y - h, w, line_height) self.gc.change(foreground = fc, background = bc) self.draw_text(x, y + ascent, descent, buf) |