I'm starting a new widget from scratch and am having some issues.
I need the size to be variable so I'm using bar.CALCULATED for the width
and then have a calculate_length function to provide the relevant width.
However, it's just not resizing when the width changes. I think this just
comes down to a lack of understanding about how the different draw
functions work.
Here's a minimal example that's not working for me:
class WidgetBox(base._Widget):
orientations = base.ORIENTATION_HORIZONTAL
defaults = []
def __init__(self, **config):
base._Widget.__init__(self, bar.CALCULATED, **config)
self.add_defaults(WidgetBox.defaults)
self.box_is_open = False
self.add_callbacks({'Button1': self.open_box})
def _configure(self, qtile, bar):
base._Widget._configure(self, qtile, bar)
self.layout = self.drawer.textlayout(
"*",
"ffffff",
"sans",
20,
None,
markup=True,
)
def calculate_length(self):
if not self.box_is_open:
return 50
else:
return 100
def draw(self):
self.drawer.clear(self.background or self.bar.background)
self.layout.draw(0,
int(self.bar.height / 2.0 -
self.layout.height / 2.0) + 1)
self.drawer.draw(offsetx=self.offsetx, width=self.width)
def open_box(self):
logger.info("Opening widget box...")
self.box_is_open = not self.box_is_open
logger.info("Width: {}".format(self.width))
self.draw()
self.bar.draw()
I can see that the width is changed by looking at the logs but the widget
itself doesn't change size. What have I missed?
Also, is there no way to do code formatting on google groups? monospace
font?
--
You received this message because you are subscribed to the Google Groups
"qtile-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/qtile-dev/f89df5dd-9b7d-4be0-97a8-903dcce61493n%40googlegroups.com.