Skip to content

Commit

Permalink
Implement an fmt option for all textboxes
Browse files Browse the repository at this point in the history
  • Loading branch information
ramnes authored and flacjacket committed Jul 10, 2019
1 parent f502dad commit b4eeba0
Showing 1 changed file with 2 additions and 11 deletions.
13 changes: 2 additions & 11 deletions libqtile/widget/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,7 @@ class _TextBox(_Widget):
"font shadow color, default is None(no shadow)"
),
("markup", False, "Whether or not to use pango markup"),
("fmt", "{}", "How to format the text")
] # type: List[Tuple[str, Any, str]]

def __init__(self, text=" ", width=bar.CALCULATED, **config):
Expand All @@ -301,17 +302,6 @@ def __init__(self, text=" ", width=bar.CALCULATED, **config):
self.text = text
self.add_defaults(_TextBox.defaults)

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

@text.setter
def text(self, value):
assert value is None or isinstance(value, str)
self._text = value
if self.layout:
self.layout.text = value

@property
def foreground(self):
return self._foreground
Expand Down Expand Up @@ -376,6 +366,7 @@ def draw(self):
if self.offsetx is None:
return
self.drawer.clear(self.background or self.bar.background)
self.layout.text = self.fmt.format(self.text)
self.layout.draw(
self.actual_padding or 0,
int(self.bar.height / 2.0 - self.layout.height / 2.0) + 1
Expand Down

0 comments on commit b4eeba0

Please sign in to comment.