diff frontends/primitivus/custom_widgets.py @ 24:67a19cfeab8f

Primitivus now implement showDialog + new "newAlert" bridge method to show a dialog from core
author Goffi <goffi@goffi.org>
date Wed, 18 Aug 2010 12:45:48 +0800
parents dfabea6f73b5
children e6bd6146dd31
line wrap: on
line diff
--- a/frontends/primitivus/custom_widgets.py	Mon Aug 16 21:11:00 2010 +0800
+++ b/frontends/primitivus/custom_widgets.py	Wed Aug 18 12:45:48 2010 +0800
@@ -693,18 +693,23 @@
         buttons = None
 
         if "OK/CANCEL" in style:
-            buttons = [urwid.Button(_("Cancel"), kwargs['cancel_cb']),
-                      urwid.Button(_("Ok"), kwargs['ok_cb'], kwargs['ok_value'])]
+            cancel_arg = [kwargs['cancel_value']] if kwargs.has_key('cancel_value') else []
+            ok_arg = [kwargs['ok_value']] if kwargs.has_key('ok_value') else []
+            buttons = [urwid.Button(_("Cancel"), kwargs['cancel_cb'], *cancel_arg),
+                      urwid.Button(_("Ok"), kwargs['ok_cb'], *ok_arg)]
         elif "YES/NO" in style:
-            buttons = [urwid.Button(_("Yes"), kwargs['yes_cb']),
-                      urwid.Button(_("No"), kwargs['no_cb'], kwargs['yes_value'])]
+            yes_arg = [kwargs['yes_value']] if kwargs.has_key('yes_value') else []
+            no_arg = [kwargs['no_value']] if kwargs.has_key('no_value') else []
+            buttons = [urwid.Button(_("Yes"), kwargs['yes_cb'], *yes_arg),
+                      urwid.Button(_("No"), kwargs['no_cb'], *no_arg)]
         if "OK" in style:
-            buttons = [urwid.Button(_("Ok"), kwargs['ok_cb'], kwargs['ok_value'])]
+            ok_arg = [kwargs['ok_value']] if kwargs.has_key('ok_value') else []
+            buttons = [urwid.Button(_("Ok"), kwargs['ok_cb'], *ok_arg)]
         if buttons:
             buttons_flow = urwid.GridFlow(buttons, max([len(button.get_label()) for button in buttons])+4, 1, 1, 'center')
         body_content = urwid.SimpleListWalker(widgets_lst)
         frame_body = urwid.ListBox(body_content)
-        frame = urwid.Frame(frame_body, frame_header, buttons_flow if buttons else None)
+        frame = FocusFrame(frame_body, frame_header, buttons_flow if buttons else None, 'footer' if buttons else 'body')
         decorated_frame = urwid.LineBox(frame)
         urwid.WidgetWrap.__init__(self, decorated_frame)
 
@@ -715,14 +720,14 @@
 
     def __init__(self, title, instrucions, style=['OK/CANCEL'], default_txt = '', **kwargs):
         instr_wid = urwid.Text(instrucions+':')
-        edit_box = urwid.Edit(edit_text=default_txt)
+        edit_box = AdvancedEdit(edit_text=default_txt)
         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)
+        GenericDialog.__init__(self, [], title, style, **kwargs)
 
 class Alert(GenericDialog):
     """Dialog with just a message and a OK button"""