[Urwid] mouse_event to keypress

Angel Kolev meneldor at gmail.com
Fri Feb 15 11:52:49 EST 2013


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.

On Fri, Feb 15, 2013 at 6:35 PM, Ian Ward <ian at excess.org> wrote:

> On Fri, Feb 15, 2013 at 11:25 AM, Angel Kolev <meneldor at gmail.com> wrote:
> > Well, the problem is that i cant be sure in what container the BaseInput
> > will be placed. I tried to call the keypress method of ListBox which is
> on
> > top of the BaseInput using:
> >  some_list_box_object.keypress(size,"down")
> > but it threw an error about sizing.
> > It made something similar for Text widgets stored in ListBox:
> >>
> >>         if button == 5:
> >>             if len(self.body)-1 > self.focus_position:
> >>                 self.set_focus(self.focus_position+1,
> coming_from="above")
> >>         elif button == 4 :
> >>             if self.focus_position > 0:
> >>                 self.set_focus(self.focus_position-1,
> coming_from="below")
> >
> >
> > So it scrolls trough a list of Text lines perfectly but i cant do it with
> > Edit's
>
> Would you post a complete runnable example of what you're trying to do?
>
> _______________________________________________
> Urwid mailing list
> Urwid at lists.excess.org
> http://lists.excess.org/mailman/listinfo/urwid
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.excess.org/pipermail/urwid/attachments/20130215/da181c20/attachment-0001.htm 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: widget.png
Type: image/png
Size: 13515 bytes
Desc: not available
Url : http://lists.excess.org/pipermail/urwid/attachments/20130215/da181c20/attachment-0001.png 


More information about the Urwid mailing list