-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcoloredit.py
More file actions
26 lines (18 loc) · 792 Bytes
/
coloredit.py
File metadata and controls
26 lines (18 loc) · 792 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import urwid
import urwid.widget as widget
class ColorEdit(widget.Edit):
"""A class that allows for colorized text."""
def __init__(self, caption="", edit_text="", multiline=False,
align='left', wrap='space', allow_tab=False,
edit_pos=None, layout=None):
widget.Edit.__init__(self, caption, edit_text, multiline, align,
wrap, allow_tab, edit_pos, layout)
self._colorize()
def keypress(self, size, key):
widget.Edit.keypress(self, size, key)
self._colorize()
def _colorize(self):
widget.Text.set_text(self, self.colorize())
def colorize(self):
"""Overrideable method that should return markup to be used as the text."""
return self.edit_text