summaryrefslogtreecommitdiff
path: root/urwid/wimp.py
diff options
context:
space:
mode:
Diffstat (limited to 'urwid/wimp.py')
-rwxr-xr-xurwid/wimp.py21
1 files changed, 12 insertions, 9 deletions
diff --git a/urwid/wimp.py b/urwid/wimp.py
index 62a0819..3dfbf39 100755
--- a/urwid/wimp.py
+++ b/urwid/wimp.py
@@ -34,8 +34,9 @@ from urwid.decoration import WidgetDecoration
from urwid.command_map import ACTIVATE
class SelectableIcon(Text):
+ ignore_focus = False
_selectable = True
- def __init__(self, text, cursor_position=1):
+ def __init__(self, text, cursor_position=0):
"""
:param text: markup for this widget; see :class:`Text` for
description of text markup
@@ -58,7 +59,7 @@ class SelectableIcon(Text):
>>> si
<SelectableIcon selectable flow widget '[!]'>
>>> si.render((4,), focus=True).cursor
- (1, 0)
+ (0, 0)
>>> si = SelectableIcon("((*))", 2)
>>> si.render((8,), focus=True).cursor
(2, 0)
@@ -103,9 +104,9 @@ class CheckBox(WidgetWrap):
return frozenset([FLOW])
states = {
- True: SelectableIcon("[X]"),
- False: SelectableIcon("[ ]"),
- 'mixed': SelectableIcon("[#]") }
+ True: SelectableIcon("[X]", 1),
+ False: SelectableIcon("[ ]", 1),
+ 'mixed': SelectableIcon("[#]", 1) }
reserve_columns = 4
# allow users of this class to listen for change events
@@ -114,7 +115,7 @@ class CheckBox(WidgetWrap):
signals = ["change", 'postchange']
def __init__(self, label, state=False, has_mixed=False,
- on_state_change=None, user_data=None):
+ on_state_change=None, user_data=None, checked_symbol=None):
"""
:param label: markup for check box label
:param state: False, True or "mixed"
@@ -148,6 +149,8 @@ class CheckBox(WidgetWrap):
self._label = Text("")
self.has_mixed = has_mixed
self._state = None
+ if checked_symbol:
+ self.states[True] = SelectableIcon(u"[%s]" % checked_symbol, 1)
# The old way of listening for a change was to pass the callback
# in to the constructor. Just convert it to the new way:
if on_state_change:
@@ -322,9 +325,9 @@ class CheckBox(WidgetWrap):
class RadioButton(CheckBox):
states = {
- True: SelectableIcon("(X)"),
- False: SelectableIcon("( )"),
- 'mixed': SelectableIcon("(#)") }
+ True: SelectableIcon("(X)", 1),
+ False: SelectableIcon("( )", 1),
+ 'mixed': SelectableIcon("(#)", 1) }
reserve_columns = 4
def __init__(self, group, label, state="first True",