mirror of
https://github.com/gryf/wicd.git
synced 2025-12-20 12:58:07 +01:00
Support urwid 1.1.0
This commit is contained in:
@@ -349,7 +349,10 @@ class ComboBox(urwid.WidgetWrap):
|
|||||||
# We need this to pick our keypresses
|
# We need this to pick our keypresses
|
||||||
self.use_enter = use_enter
|
self.use_enter = use_enter
|
||||||
|
|
||||||
|
if urwid.VERSION < (1, 1, 0):
|
||||||
self.focus = focus
|
self.focus = focus
|
||||||
|
else:
|
||||||
|
self.focus_position = focus
|
||||||
|
|
||||||
self.callback = callback
|
self.callback = callback
|
||||||
self.user_args = user_args
|
self.user_args = user_args
|
||||||
@@ -362,7 +365,11 @@ class ComboBox(urwid.WidgetWrap):
|
|||||||
self.list = list
|
self.list = list
|
||||||
|
|
||||||
def set_focus(self,index):
|
def set_focus(self,index):
|
||||||
|
if urwid.VERSION < (1, 1, 0):
|
||||||
self.focus = index
|
self.focus = index
|
||||||
|
else:
|
||||||
|
self.focus_position = index
|
||||||
|
|
||||||
# API changed between urwid 0.9.8.4 and 0.9.9
|
# API changed between urwid 0.9.8.4 and 0.9.9
|
||||||
try:
|
try:
|
||||||
self.cbox.set_w(SelText(self.list[index]+self.DOWN_ARROW))
|
self.cbox.set_w(SelText(self.list[index]+self.DOWN_ARROW))
|
||||||
@@ -376,16 +383,21 @@ class ComboBox(urwid.WidgetWrap):
|
|||||||
def build_combobox(self,parent,ui,row):
|
def build_combobox(self,parent,ui,row):
|
||||||
str,trash = self.label.get_text()
|
str,trash = self.label.get_text()
|
||||||
|
|
||||||
self.cbox = DynWrap(SelText([self.list[self.focus]+self.DOWN_ARROW]),
|
if urwid.VERSION < (1, 1, 0):
|
||||||
|
index = self.focus
|
||||||
|
else:
|
||||||
|
index = self.focus_position
|
||||||
|
|
||||||
|
self.cbox = DynWrap(SelText([self.list[index]+self.DOWN_ARROW]),
|
||||||
attrs=self.attrs,focus_attr=self.focus_attr)
|
attrs=self.attrs,focus_attr=self.focus_attr)
|
||||||
if str != '':
|
if str != '':
|
||||||
w = urwid.Columns([('fixed',len(str),self.label),self.cbox],
|
w = urwid.Columns([('fixed',len(str),self.label),self.cbox],
|
||||||
dividechars=1)
|
dividechars=1)
|
||||||
self.overlay = self.ComboSpace(self.list,parent,ui,self.focus,
|
self.overlay = self.ComboSpace(self.list,parent,ui,index,
|
||||||
pos=(len(str)+1,row))
|
pos=(len(str)+1,row))
|
||||||
else:
|
else:
|
||||||
w = urwid.Columns([self.cbox])
|
w = urwid.Columns([self.cbox])
|
||||||
self.overlay = self.ComboSpace(self.list,parent,ui,self.focus,
|
self.overlay = self.ComboSpace(self.list,parent,ui,index,
|
||||||
pos=(0,row))
|
pos=(0,row))
|
||||||
|
|
||||||
self._w = w
|
self._w = w
|
||||||
@@ -419,7 +431,10 @@ class ComboBox(urwid.WidgetWrap):
|
|||||||
if self.overlay:
|
if self.overlay:
|
||||||
return self.overlay._listbox.get_focus()
|
return self.overlay._listbox.get_focus()
|
||||||
else:
|
else:
|
||||||
return None,self.focus
|
if urwid.VERSION < (1, 1, 0):
|
||||||
|
return None, self.focus
|
||||||
|
else:
|
||||||
|
return None, self.focus_position
|
||||||
|
|
||||||
def get_sensitive(self):
|
def get_sensitive(self):
|
||||||
return self.cbox.get_sensitive()
|
return self.cbox.get_sensitive()
|
||||||
|
|||||||
Reference in New Issue
Block a user