primitivus: fixed urwid issues with recent urwid versions

fix bug 18
This commit is contained in:
Goffi 2013-02-24 13:57:37 +01:00
commit 05c53bf2d6

View file

@ -95,7 +95,7 @@ class Chat(urwid.WidgetWrap, QuickChat):
def keypress(self, size, key):
if key == "meta p": #user wants to (un)hide the presents panel
if self.type == 'group':
widgets = self.chat_colums.widget_list
widgets = [widget for (widget, options) in self.chat_colums.contents]
if self.present_panel in widgets:
self.__removePresentPanel()
else:
@ -141,7 +141,7 @@ class Chat(urwid.WidgetWrap, QuickChat):
if type == 'one2one':
self.historyPrint(profile=self.host.profile)
elif type == 'group':
if len(self.chat_colums.widget_list) == 1:
if len(self.chat_colums.contents) == 1:
present_widget = self.__buildPresentList()
self.present_panel = sat_widgets.VerticalSeparator(present_widget)
self.__appendPresentPanel()
@ -177,27 +177,23 @@ class Chat(urwid.WidgetWrap, QuickChat):
return self.present_wid
def __appendPresentPanel(self):
self.chat_colums.widget_list.append(self.present_panel)
self.chat_colums.column_types.append(('weight', 2))
self.chat_colums.contents.append((self.present_panel,('weight', 2, False)))
def __removePresentPanel(self):
self.chat_colums.set_focus(0) #necessary as the focus change to the next object, we can go out of range if we are on the last object of self.chat_colums
self.chat_colums.widget_list.remove(self.present_panel)
del self.chat_colums.column_types[-1]
for widget, options in self.chat_colums.contents:
if widget is self.present_panel:
self.chat_colums.contents.remove((widget, options))
break
def __appendGamePanel(self, widget):
assert (len(self.pile.widget_list) == 1)
self.pile.widget_list.insert(0,widget)
self.pile.item_types.insert(0,('weight', 1))
self.pile.widget_list.insert(1,urwid.Filler(urwid.Divider('-')))
self.pile.item_types.insert(1,('fixed', 1))
assert (len(self.pile.contents) == 1)
self.pile.contents.insert(0,(widget,('weight', 1, False)))
self.pile.contents.insert(1,(urwid.Filler(urwid.Divider('-'),('fixed', 1))))
self.host.redraw()
def __removeGamePanel(self):
assert (len(self.pile.widget_list) == 3)
self.pile.set_focus(0) #necessary as the focus change to the next object, we can go out of range if we are on the last object of self.chat_colums
del self.pile.widget_list[0]
del self.pile.item_types[0]
assert (len(self.pile.contents) == 3)
del self.pile.contents[0]
self.host.redraw()
def setSubject(self, subject, wrap='space'):