rev |
line source |
mojo@14649
|
1 === modified file 'curses/curses_misc.py'
|
mojo@14649
|
2 --- curses/curses_misc.py 2012-05-06 15:16:15 +0000
|
mojo@14649
|
3 +++ curses/curses_misc.py 2012-11-15 09:26:21 +0000
|
mojo@14649
|
4 @@ -349,7 +349,10 @@
|
mojo@14649
|
5 # We need this to pick our keypresses
|
mojo@14649
|
6 self.use_enter = use_enter
|
mojo@14649
|
7
|
mojo@14649
|
8 - self.focus = focus
|
mojo@14649
|
9 + if urwid.VERSION < (1, 1, 0):
|
mojo@14649
|
10 + self.focus = focus
|
mojo@14649
|
11 + else:
|
mojo@14649
|
12 + self.focus_position = focus
|
mojo@14649
|
13
|
mojo@14649
|
14 self.callback = callback
|
mojo@14649
|
15 self.user_args = user_args
|
mojo@14649
|
16 @@ -362,7 +365,11 @@
|
mojo@14649
|
17 self.list = list
|
mojo@14649
|
18
|
mojo@14649
|
19 def set_focus(self,index):
|
mojo@14649
|
20 - self.focus = index
|
mojo@14649
|
21 + if urwid.VERSION < (1, 1, 0):
|
mojo@14649
|
22 + self.focus = index
|
mojo@14649
|
23 + else:
|
mojo@14649
|
24 + self.focus_position = index
|
mojo@14649
|
25 +
|
mojo@14649
|
26 # API changed between urwid 0.9.8.4 and 0.9.9
|
mojo@14649
|
27 try:
|
mojo@14649
|
28 self.cbox.set_w(SelText(self.list[index]+self.DOWN_ARROW))
|
mojo@14649
|
29 @@ -376,16 +383,21 @@
|
mojo@14649
|
30 def build_combobox(self,parent,ui,row):
|
mojo@14649
|
31 str,trash = self.label.get_text()
|
mojo@14649
|
32
|
mojo@14649
|
33 - self.cbox = DynWrap(SelText([self.list[self.focus]+self.DOWN_ARROW]),
|
mojo@14649
|
34 + if urwid.VERSION < (1, 1, 0):
|
mojo@14649
|
35 + index = self.focus
|
mojo@14649
|
36 + else:
|
mojo@14649
|
37 + index = self.focus_position
|
mojo@14649
|
38 +
|
mojo@14649
|
39 + self.cbox = DynWrap(SelText([self.list[index]+self.DOWN_ARROW]),
|
mojo@14649
|
40 attrs=self.attrs,focus_attr=self.focus_attr)
|
mojo@14649
|
41 if str != '':
|
mojo@14649
|
42 w = urwid.Columns([('fixed',len(str),self.label),self.cbox],
|
mojo@14649
|
43 dividechars=1)
|
mojo@14649
|
44 - self.overlay = self.ComboSpace(self.list,parent,ui,self.focus,
|
mojo@14649
|
45 + self.overlay = self.ComboSpace(self.list,parent,ui,index,
|
mojo@14649
|
46 pos=(len(str)+1,row))
|
mojo@14649
|
47 else:
|
mojo@14649
|
48 w = urwid.Columns([self.cbox])
|
mojo@14649
|
49 - self.overlay = self.ComboSpace(self.list,parent,ui,self.focus,
|
mojo@14649
|
50 + self.overlay = self.ComboSpace(self.list,parent,ui,index,
|
mojo@14649
|
51 pos=(0,row))
|
mojo@14649
|
52
|
mojo@14649
|
53 self._w = w
|
mojo@14649
|
54 @@ -419,7 +431,10 @@
|
mojo@14649
|
55 if self.overlay:
|
mojo@14649
|
56 return self.overlay._listbox.get_focus()
|
mojo@14649
|
57 else:
|
mojo@14649
|
58 - return None,self.focus
|
mojo@14649
|
59 + if urwid.VERSION < (1, 1, 0):
|
mojo@14649
|
60 + return None, self.focus
|
mojo@14649
|
61 + else:
|
mojo@14649
|
62 + return None, self.focus_position
|
mojo@14649
|
63
|
mojo@14649
|
64 def get_sensitive(self):
|
mojo@14649
|
65 return self.cbox.get_sensitive()
|
mojo@14649
|
66
|