diff options
author | Mattias Andrée <maandree@operamail.com> | 2014-02-27 06:48:13 +0100 |
---|---|---|
committer | Mattias Andrée <maandree@operamail.com> | 2014-02-27 06:48:13 +0100 |
commit | 03fa5fe2e22c5733ed7cb81fbecf604e2f189908 (patch) | |
tree | e5f8890351c12aa08e35432991ecf6d1392f5d71 /src/x.py | |
parent | struct + doc (diff) | |
download | xpybar-03fa5fe2e22c5733ed7cb81fbecf604e2f189908.tar.gz xpybar-03fa5fe2e22c5733ed7cb81fbecf604e2f189908.tar.bz2 xpybar-03fa5fe2e22c5733ed7cb81fbecf604e2f189908.tar.xz |
separate function for string drawing
Signed-off-by: Mattias Andrée <maandree@operamail.com>
Diffstat (limited to 'src/x.py')
-rw-r--r-- | src/x.py | 20 |
1 files changed, 20 insertions, 0 deletions
@@ -139,6 +139,26 @@ def create_panel(width, height, left, ypos, panel_height, at_top): return window +def draw_text(window, gc, x, y, text): + ''' + Draw a text on a window + + @param window The window + @param gc The window's graphics context + @param x:int The left position of the text + @param y:int The Y position of the bottom of the text + @param text:str The text to draw + ''' + text_ = text.encode('utf-16')[2:] + text = [] + for i in range(len(text_)): + if (i & 1) == 0: + text.append(text_[i]) + else: + text[-1] |= text_[i] << 8 + window.image_text_16(gc, x, y, text) + + def close_x(): ''' Closes the connection to X, but flushes it first |