Actually, I just found a better solution:
def render(self, size, focus=False):
if focus:
self.toolbar.set_text(self.tip)
canv = super(EditWithTip, self).render(size, focus)
Render gets called all the time for the object, but focus is only True if
it's in focus. It's good enough for my needs and I don't need to handle
ListBox indexes and check positions. I just want to be able to add
tooltip-enhanced Edits arbitrarily anywhere and not have to track it or
store tooltip strings separately.
On Tue, Aug 13, 2013 at 5:35 PM, Ian Ward <[email protected]> wrote:
> On Tue, Aug 13, 2013 at 9:21 AM, Matthew Mosesohn
> <[email protected]> wrote:
> > 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.
>
> If you only have tool-tips for widgets in your ListBox you could
> extend ListBox and have it update the tool-tips after each keypress or
> mouse_event that comes through.
>
> A fancier approach is to add an on idle handler to your main loop that
> checks the widget in focus with get_focus_path so that it can update
> the tool-tip from any widget just before the screen is actually
> rendered.
>
> _______________________________________________
> Urwid mailing list
> [email protected]
> http://lists.excess.org/mailman/listinfo/urwid
>
_______________________________________________
Urwid mailing list
[email protected]
http://lists.excess.org/mailman/listinfo/urwid