misc documentation
This commit is contained in:
parent
dbb3520a4f
commit
493bf1d0c8
2 changed files with 18 additions and 3 deletions
|
|
@ -35,7 +35,7 @@ class ContactList(urwid.WidgetWrap, QuickContactList):
|
|||
#we now build the widget
|
||||
body_content = urwid.SimpleListWalker([self.list_wid])
|
||||
frame_body = urwid.ListBox(body_content)
|
||||
frame = urwid.Frame(frame_body) #,urwid.AttrMap(urwid.Text(_("Contacts"),align='center'),'title'))
|
||||
frame = urwid.Frame(frame_body)
|
||||
self.main_widget = LabelLine(frame,SurroundedText(_("Contacts")))
|
||||
urwid.WidgetWrap.__init__(self, self.main_widget)
|
||||
if on_click:
|
||||
|
|
|
|||
|
|
@ -23,8 +23,12 @@ import urwid
|
|||
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 @@ class Password(urwid.Edit):
|
|||
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 AdvancedEdit(urwid.Edit):
|
|||
|
||||
|
||||
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 GenericDialog(urwid.WidgetWrap):
|
|||
|
||||
|
||||
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 @@ class InputDialog(GenericDialog):
|
|||
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 @@ class Alert(GenericDialog):
|
|||
## 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 @@ class FocusFrame(urwid.Frame):
|
|||
|
||||
## 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)
|
||||
|
|
|
|||
Loading…
Reference in a new issue