[Urwid] Filler.mouse_event() --> TypeError
Rebecca Breu
rebecca at rbreu.de
Fri Jun 23 07:50:04 EDT 2006
Hi!
I just started working with urwid's mouse support. I created this short
program:
-------------
#! /usr/bin/env python
import urwid.curses_display;
import urwid;
def run():
ui.set_mouse_tracking();
dim = ui.get_cols_rows();
widget = urwid.Filler(urwid.Edit("Write something:"));
keys = True;
while True:
if keys:
ui.draw_screen(dim, widget.render(dim, True));
keys = ui.get_input();
if "window resize" in keys:
dim = ui.get_cols_rows();
for k in keys:
if urwid.is_mouse_event(k):
event, button, col, row = k
widget.mouse_event(dim, event, button, col, row, focus=True)
else:
widget.keypress(dim, k);
ui = urwid.curses_display.Screen();
ui.run_wrapper(run);
-----------
As soon as I use a mouse button, I get this:
-----------
Traceback (most recent call last):
File "./urwid_test2.py", line 30, in ?
ui.run_wrapper(run);
File "/home/rbreu/zeugs/urwid-0.9.4/urwid/curses_display.py", line 177, in
run_wrapper
return fn()
File "./urwid_test2.py", line 25, in run
widget.mouse_event(dim, event, button, col, row, focus=True)
File "/home/rbreu/zeugs/urwid-0.9.4/urwid/widget.py", line 1234, in
mouse_event
event, button, col, row-top)
TypeError: mouse_event() takes exactly 7 arguments (6 given)
-----------
The focus parameter is missing in line 1234 (Odd number ;-). Just changing
lines 1233 and 1234 in wiget.py to
return self.body.mouse_event((maxcol,),
event, button, col, row-top, focus)
seems to fix the problem...
Have a nice weekend,
Rebecca
More information about the Urwid
mailing list