diff urwid_satext/sat_widgets.py @ 69:b39c81cdd863

removed __valid_text: urwid now manage basestring subclasses, it's not necessary anymore
author Goffi <goffi@goffi.org>
date Tue, 24 Dec 2013 15:09:21 +0100
parents 5c28bb50ae0d
children 24d49f1d735f
line wrap: on
line diff
--- a/urwid_satext/sat_widgets.py	Tue Dec 24 15:01:09 2013 +0100
+++ b/urwid_satext/sat_widgets.py	Tue Dec 24 15:09:21 2013 +0100
@@ -192,31 +192,12 @@
         self.focus_attr = focus_attr
         self.__selected = False
         self.__was_focused = False
-        self.header = self.__valid_text(header)
-        self.default_txt = self.__valid_text(text)
+        self.header = header
+        self.default_txt = text
         urwid.WidgetWrap.__init__(self, urwid.Text("",align=align))
         self.setSelectedText(selected_text)
         self.setState(selected)
 
-    def __valid_text(self, text):
-        """Tmp method needed until dbus and urwid are more friends"""
-        if isinstance(text, ListOption):
-            return text
-        if isinstance(text,basestring):
-            return unicode(text)
-        elif isinstance(text,tuple):
-            return (unicode(text[0]),text[1])
-        elif isinstance(text,list):
-            for idx in range(len(text)):
-                elem = text[idx]
-                if isinstance(elem,basestring):
-                    text[idx] = unicode(elem)
-                if isinstance(elem,tuple):
-                    text[idx] = (unicode(elem[0]),elem[1])
-        else:
-            warning (_('WARNING: unknown text type'))
-        return text
-
     def getValue(self):
         if isinstance(self.default_txt,basestring):
             return self.default_txt
@@ -235,7 +216,7 @@
 
     def set_text(self, text):
         """/!\ set_text doesn't change self.selected_txt !"""
-        self.default_txt = self.__valid_text(text)
+        self.default_txt = text
         self.setState(self.__selected,invisible=True)
 
     def setSelectedText(self, text=None):
@@ -243,7 +224,7 @@
         @text: text as in urwid.Text or None for default value"""
         if text == None:
             text = ('selected',self.getValue())
-        self.selected_txt = self.__valid_text(text)
+        self.selected_txt = text
         if self.__selected:
             self.setState(self.__selected)