[Urwid] mouse_event to keypress

Ian Ward ian at excess.org
Fri Feb 15 11:56:24 EST 2013

On Fri, Feb 15, 2013 at 11:52 AM, Angel Kolev <meneldor at gmail.com> wrote:
> It would be very hard to post the whole code because its separated in many
> files/libs.
> I created a plugin-based framework and made it to open unlimited pop-ups. I
> made a main class Window which is responsible for all widgets in it. Window
> has a method add_row() so i am building whatever mixed widget i want.
> Example code for the menu from above:
>             window = self.new_window(21, 55, text="Choose User and Pass for
> each host (%s)" % len(hosts))
>             for item in hosts:
>                 window.add_row([ BaseInput(' User: ',value=item[1][0]),
> BaseInput(' Pass: ',value=item[1][1]) ],border=item[0])
>             window.add_buttons([ "Done"])
>             return window
> The result from the code above is in the attached screenshot.
> So, i want to use the mouse scroll to scroll the rows instead of the
> keyboard, but i cant convert the mouse_event to keypress up/down.

I see.

Maybe you want to convert all unhandled mouse wheel events into
up/down keystrokes?  That can be done in an unhandled_input callback
on your MainLoop that checks for the mouse event and calls
main_loop.process_input(['up']) or ...(['down'])


More information about the Urwid mailing list