My collection of plugins for the Qtile window manager.
git clone https://mcol.xyz/code/qtools
Log | Files | Refs | README

commit cab6f53f30fded6d7f0f979750ab0aa6d0f5f2a3
parent 1b3a7dc85db0c7cad7044da968b26f1e10e97950
Author: mcol <mcol@posteo.net>
Date:   Sun, 26 Jan 2020 21:54:26 +0000

allow for drawing images on popup windows

Diffstat:
Mqtools/__init__.py | 31++++++++++++++++++++++++++++---
1 file changed, 28 insertions(+), 3 deletions(-)

diff --git a/qtools/__init__.py b/qtools/__init__.py @@ -94,6 +94,7 @@ class Popup(configurable.Configurable): ('horizontal_padding', None, 'Padding at sides of text.'), ('vertical_padding', None, 'Padding at top and bottom of text.'), ('text_alignment', 'left', 'Text alignment: left, center or right.'), + ('wrap', True, 'Whether to wrap text.'), ] def __init__(self, qtile, x=50, y=50, width=256, height=64, **config): @@ -114,7 +115,7 @@ class Popup(configurable.Configurable): font_family=self.font, font_size=self.fontsize, font_shadow=self.fontshadow, - wrap=True, + wrap=self.wrap, markup=True, ) self.layout.layout.set_alignment(ALIGNMENTS[self.text_alignment]) @@ -133,8 +134,6 @@ class Popup(configurable.Configurable): self.x = self.win.x self.y = self.win.y - self.width = self.win.width - self.height = self.win.height if not self.border_width: self.border = None @@ -149,6 +148,24 @@ class Popup(configurable.Configurable): self.hide() @property + def width(self): + return self.win.width + + @width.setter + def width(self, value): + self.win.width = value + self.drawer.width = value + + @property + def height(self): + return self.win.height + + @height.setter + def height(self, value): + self.win.height = value + self.drawer.height = value + + @property def text(self): return self.layout.text @@ -191,6 +208,14 @@ class Popup(configurable.Configurable): self.win.unhide() self.win.window.configure(stackmode=StackMode.Above) + def draw_image(self, image, x, y): + """ + Paint an image onto the window at point x, y. The image should be a surface e.g. + loaded from libqtile.images.Img.load_path. + """ + self.drawer.ctx.set_source_surface(image, x, y) + self.drawer.ctx.paint() + def hide(self): self.win.hide()