diff frontends/primitivus/custom_widgets.py @ 121:03d8bcc67182

misc documentation
author Goffi <goffi@goffi.org>
date Thu, 08 Jul 2010 14:19:30 +0800
parents 1ca5f254ce41
children 961e0898271f
line wrap: on
line diff
--- a/frontends/primitivus/custom_widgets.py	Thu Jul 08 14:12:18 2010 +0800
+++ b/frontends/primitivus/custom_widgets.py	Thu Jul 08 14:19:30 2010 +0800
@@ -23,8 +23,12 @@
 from urwid.escape import utf8decode
 
 class Password(urwid.Edit):
+    """Edit box which doesn't show what is entered (show '*' or other char instead)"""
 
     def __init__(self, *args, **kwargs):
+        """Same args than Edit.__init__ with an additional keyword arg 'hidden_char'
+        @param hidden_char: char to show instead of what is actually entered: default '*'
+        """
         self.hidden_char=kwargs['hidden_char'] if kwargs.has_key('hidden_char') else '*'
         self.__real_text=''
         super(Password, self).__init__(*args, **kwargs)
@@ -38,7 +42,13 @@
         return self.__real_text
 
 class AdvancedEdit(urwid.Edit):
-    """Edit box with some custom improvments"""
+    """Edit box with some custom improvments
+    new chars:
+              - C-a: like 'home'
+              - C-e: like 'end'
+              - C-k: remove everything on the right of the cursor
+              - C-w: remove the word on the back
+    new behaviour: emit a 'click' signal when enter is pressed"""
     signals = urwid.Edit.signals + ['click']
 
     def keypress(self, size, key):
@@ -61,6 +71,7 @@
        
 
 class SurroundedText(urwid.FlowWidget):
+    """Text centered on a repeated character (like a Divider, but with a text in the center)"""
 
     def __init__(self,text,car=utf8decode('─')):
         self.text=text
@@ -309,6 +320,7 @@
 
 
 class InputDialog(GenericDialog):
+    """Dialog with an edit box"""
 
     def __init__(self, title, instrucions, style=['OK/CANCEL'], default_txt = '', **kwargs):
         instr_wid = urwid.Text(instrucions+':')
@@ -316,11 +328,13 @@
         GenericDialog.__init__(self, [instr_wid,edit_box], title, style, ok_value=edit_box, **kwargs)
 
 class ConfirmDialog(GenericDialog):
+    """Dialog with buttons for confirm or cancel an action"""
 
     def __init__(self, title, style=['YES/NO'], **kwargs):
         GenericDialog.__init__(self, [], title, style, yes_value=None, **kwargs)
 
 class Alert(GenericDialog):
+    """Dialog with just a message and a OK button"""
 
     def __init__(self, title, message, style=['OK'], **kwargs):
         GenericDialog.__init__(self, [urwid.Text(message, 'center')], title, style, ok_value=None, **kwargs)
@@ -328,7 +342,7 @@
 ## CONTAINERS ##
 
 class FocusFrame(urwid.Frame):
-    """Frame which manage "tab" key"""
+    """Frame which manage 'tab' key"""
 
     def keypress(self, size, key):
         if key == 'tab':
@@ -345,6 +359,7 @@
 
 ## DECORATORS ##
 class LabelLine(urwid.LineBox):
+    """Like LineBox, but with a Label centered in the top line"""
 
     def __init__(self, original_widget, label_widget):
         urwid.LineBox.__init__(self, original_widget)