Skip to content

Commit

Permalink
Make widgets that reassign self.text with itself (e.g. Notify) not fo…
Browse files Browse the repository at this point in the history
…rmat twice
  • Loading branch information
ramnes committed Jul 22, 2019
1 parent 77b47b0 commit 5b7fa2c
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions libqtile/widget/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -304,13 +304,17 @@ def __init__(self, text=" ", width=bar.CALCULATED, **config):

@property
def text(self):
return self._text

@property
def formatted_text(self):
return self.fmt.format(self._text)

@text.setter
def text(self, value):
self._text = value
if self.layout:
self.layout.text = self.text
self.layout.text = self.formatted_text

@property
def foreground(self):
Expand Down Expand Up @@ -354,7 +358,7 @@ def _configure(self, qtile, bar):
if self.fontsize is None:
self.fontsize = self.bar.height - self.bar.height / 5
self.layout = self.drawer.textlayout(
self.text,
self.formatted_text,
self.foreground,
self.font,
self.fontsize,
Expand All @@ -363,7 +367,7 @@ def _configure(self, qtile, bar):
)

def calculate_length(self):
if self._text:
if self.text:
return min(
self.layout.width,
self.bar.width
Expand Down Expand Up @@ -399,7 +403,7 @@ def cmd_set_font(self, font=UNSPECIFIED, fontsize=UNSPECIFIED,
def info(self):
d = _Widget.info(self)
d['foreground'] = self.foreground
d['text'] = self.text
d['text'] = self.formatted_text
return d


Expand Down

0 comments on commit 5b7fa2c

Please sign in to comment.