comparison urwid_satext/sat_widgets.py @ 74:0afff3c54b6e

replaced deprecated set_focus by focus_position
author Goffi <goffi@goffi.org>
date Fri, 21 Mar 2014 15:14:53 +0100
parents eddb8369ba06
children 8ff563825080
comparison
equal deleted inserted replaced
73:62c4288e5a97 74:0afff3c54b6e
502 self.unselectAll() 502 self.unselectAll()
503 idx = 0 503 idx = 0
504 for widget in self.content: 504 for widget in self.content:
505 if widget.getValue() == value: 505 if widget.getValue() == value:
506 widget.setState(True) 506 widget.setState(True)
507 self.list_box.set_focus(idx) 507 self.list_box.focus_position = idx
508 return 508 return
509 idx+=1 509 idx+=1
510 510
511 511
512 class List(urwid.Widget): 512 class List(urwid.Widget):
883 if style is None: 883 if style is None:
884 style = ['OK/CANCEL'] 884 style = ['OK/CANCEL']
885 instr_wid = urwid.Text(instrucions+':') 885 instr_wid = urwid.Text(instrucions+':')
886 edit_box = AdvancedEdit(edit_text=default_txt) 886 edit_box = AdvancedEdit(edit_text=default_txt)
887 GenericDialog.__init__(self, [instr_wid,edit_box], title, style, ok_value=edit_box, **kwargs) 887 GenericDialog.__init__(self, [instr_wid,edit_box], title, style, ok_value=edit_box, **kwargs)
888 self._w.base_widget.set_focus('body') 888 self._w.base_widget.focusposition = 'body'
889 889
890 890
891 class ConfirmDialog(GenericDialog): 891 class ConfirmDialog(GenericDialog):
892 """Dialog with buttons for confirm or cancel an action""" 892 """Dialog with buttons for confirm or cancel an action"""
893 893
916 self.__next = False 916 self.__next = False
917 917
918 def addWidget(self, widget, width): 918 def addWidget(self, widget, width):
919 self.widget_list.append((width,widget)) 919 self.widget_list.append((width,widget))
920 if len(self.widget_list) == 1: 920 if len(self.widget_list) == 1:
921 self.set_focus(0) 921 self.focus_position = 0
922 922
923 def getStartCol(self, widget): 923 def getStartCol(self, widget):
924 """Return the column of the left corner of the widget""" 924 """Return the column of the left corner of the widget"""
925 start_col = 0 925 start_col = 0
926 for wid in self.widget_list[self.__start:]: 926 for wid in self.widget_list[self.__start:]:
952 952
953 def getSelected(self): 953 def getSelected(self):
954 """Return selected widget""" 954 """Return selected widget"""
955 return self.widget_list[self.focus_column][1] 955 return self.widget_list[self.focus_column][1]
956 956
957 def set_focus(self, idx): 957 @property
958 def focus_position(self):
959 return self.focus_column
960
961 @focus_position.setter
962 def focus_position(self, idx):
958 if idx>len(self.widget_list)-1: 963 if idx>len(self.widget_list)-1:
959 idx = len(self.widget_list)-1 964 idx = len(self.widget_list)-1
960 self.focus_column = idx 965 self.focus_column = idx
961 966
962 def rows(self,size,focus=False): 967 def rows(self,size,focus=False):