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
_______________________________________________
Urwid mailing list
[email protected]
http://lists.excess.org/mailman/listinfo/urwid

Reply via email to