Matthew Mosesohn
2013-08-13 13:21:21 UTC
Hi Urwidians,
I wrapped Edit class like so:
class EditWithTip(urwid.Edit):
def __init__(self, label, default_value=None, tooltip=None,
toolbar=None):
urwid.Edit.__init__(self, caption=label, edit_text=default_value)
self.tip = tooltip
self.toolbar = toolbar
def keypress(self, size, key):
key = super(EditWithTip, self).keypress(size, key)
self.toolbar.set_text(self.tip)
return key
def mouse_event(self, size, event, button, x, y, focus):
self.toolbar.set_text(self.tip)
(maxcol,) = size
if button==1:
return self.move_cursor_to_coords( (maxcol,), x, y )
mouse_event works as expected. When I click each Edit field, I get the
tooltip (footer of my frame) set to the proper text. Iit doesn't have the
intended consequence I was hoping for with keypress. As I navigate through
my Edit elements (in a ListBox), I get the intended set_text called after I
press a key once the element is active. I was wondering what function I
could implement to run this function when my element is selected via
keyboard.
Best Regards,
Matthew Mosesohn
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.excess.org/pipermail/urwid/attachments/20130813/79e39a2b/attachment.htm
I wrapped Edit class like so:
class EditWithTip(urwid.Edit):
def __init__(self, label, default_value=None, tooltip=None,
toolbar=None):
urwid.Edit.__init__(self, caption=label, edit_text=default_value)
self.tip = tooltip
self.toolbar = toolbar
def keypress(self, size, key):
key = super(EditWithTip, self).keypress(size, key)
self.toolbar.set_text(self.tip)
return key
def mouse_event(self, size, event, button, x, y, focus):
self.toolbar.set_text(self.tip)
(maxcol,) = size
if button==1:
return self.move_cursor_to_coords( (maxcol,), x, y )
mouse_event works as expected. When I click each Edit field, I get the
tooltip (footer of my frame) set to the proper text. Iit doesn't have the
intended consequence I was hoping for with keypress. As I navigate through
my Edit elements (in a ListBox), I get the intended set_text called after I
press a key once the element is active. I was wondering what function I
could implement to run this function when my element is selected via
keyboard.
Best Regards,
Matthew Mosesohn
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.excess.org/pipermail/urwid/attachments/20130813/79e39a2b/attachment.htm