comparison urwid_satext/sat_widgets.py @ 53:d34f2b0f68d3

urwid 1.0.0 update: fixed missing is_mouse_press
author Goffi <goffi@goffi.org>
date Sat, 08 Oct 2011 21:14:41 +0200
parents 9fc778aab7f5
children 22ab98a06492
comparison
equal deleted inserted replaced
52:c416f0e42844 53:d34f2b0f68d3
21 21
22 import urwid 22 import urwid
23 from logging import debug, info, warning, error 23 from logging import debug, info, warning, error
24 import encodings 24 import encodings
25 utf8decode = lambda s: encodings.codecs.utf_8_decode(s)[0] 25 utf8decode = lambda s: encodings.codecs.utf_8_decode(s)[0]
26
27 from urwid.util import is_mouse_press #XXX: is_mouse_press is not include in urwid in 1.0.0
28
26 29
27 class Password(urwid.Edit): 30 class Password(urwid.Edit):
28 """Edit box which doesn't show what is entered (show '*' or other char instead)""" 31 """Edit box which doesn't show what is entered (show '*' or other char instead)"""
29 32
30 def __init__(self, *args, **kwargs): 33 def __init__(self, *args, **kwargs):
229 self.setState(not self.__selected) 232 self.setState(not self.__selected)
230 else: 233 else:
231 return key 234 return key
232 235
233 def mouse_event(self, size, event, button, x, y, focus): 236 def mouse_event(self, size, event, button, x, y, focus):
234 if urwid.is_mouse_press(event) and button == 1: 237 if is_mouse_press(event) and button == 1:
235 self.setState(not self.__selected) 238 self.setState(not self.__selected)
236 return True 239 return True
237 240
238 return False 241 return False
239 242
863 866
864 867
865 def mouse_event(self, size, event, button, x, y, focus): 868 def mouse_event(self, size, event, button, x, y, focus):
866 (maxcol,)=size 869 (maxcol,)=size
867 870
868 if urwid.is_mouse_press(event) and button == 1: 871 if is_mouse_press(event) and button == 1:
869 _prev,_next,start_wid,end_wid,cols_left = self.__calculate_limits(size) 872 _prev,_next,start_wid,end_wid,cols_left = self.__calculate_limits(size)
870 if x==0 and _prev: 873 if x==0 and _prev:
871 self.keypress(size,'left') 874 self.keypress(size,'left')
872 return True 875 return True
873 if x==maxcol-1 and _next: 876 if x==maxcol-1 and _next: