Here is a patch that adds a Checkbox on SHA field to toggle the
visibility of their content
Please review this at http://codereview.appspot.com/4277051/
Affected files:
M tryton/gui/window/view_form/view/form_gtk/char.py
Index: tryton/gui/window/view_form/view/form_gtk/char.py
===================================================================
--- a/tryton/gui/window/view_form/view/form_gtk/char.py
+++ b/tryton/gui/window/view_form/view/form_gtk/char.py
@@ -2,6 +2,7 @@
#this repository contains the full copyright notices and license terms.
import gtk
from interface import WidgetInterface
+from tryton.common import Tooltips
class Char(WidgetInterface):
"Char"
@@ -50,4 +51,21 @@
def __init__(self, field_name, model_name, window, attrs=None):
super(Sha, self).__init__(field_name, model_name, window,
attrs=attrs)
- self.entry.set_visibility(False)
+ self.entry.props.visibility = False
+
+ self.visibility_checkbox = gtk.CheckButton()
+ self.visibility_checkbox.connect('toggled', self.toggle_visibility)
+ Tooltips().set_tip(self.visibility_checkbox, 'Show password')
+ self.widget.pack_start(self.visibility_checkbox, expand=False)
+
+ def _readonly_set(self, value):
+ super(Char, self)._readonly_set(value)
+ self.entry.set_editable(not value)
+ self.visibility_checkbox.props.visible = not value
+ if value:
+ self.widget.set_focus_chain([])
+ else:
+ self.widget.set_focus_chain([self.entry,
self.visibility_checkbox])
+
+ def toggle_visibility(self, button):
+ self.entry.props.visibility = not self.entry.props.visibility
--
[email protected] mailing list