diff frontends/src/primitivus/xmlui.py @ 1085:7a39ae3950f7

frontends (XMLUI): implementation of read_only attributes for widgets String, TextBox, Password and Bool
author Goffi <goffi@goffi.org>
date Wed, 25 Jun 2014 14:01:56 +0200
parents ad023e60da8c
children e2e1e27a3680
line wrap: on
line diff
--- a/frontends/src/primitivus/xmlui.py	Wed Jun 25 14:01:55 2014 +0200
+++ b/frontends/src/primitivus/xmlui.py	Wed Jun 25 14:01:56 2014 +0200
@@ -46,7 +46,7 @@
 
 class PrimitivusTextWidget(xmlui.TextWidget, urwid.Text):
 
-    def __init__(self, parent, value):
+    def __init__(self, parent, value, read_only=False):
         urwid.Text.__init__(self, value)
 
 
@@ -82,8 +82,14 @@
 
 class PrimitivusStringWidget(xmlui.StringWidget, sat_widgets.AdvancedEdit, PrimitivusEvents):
 
-    def __init__(self, parent, value):
+    def __init__(self, parent, value, read_only=False):
         sat_widgets.AdvancedEdit.__init__(self, edit_text=value)
+        self.read_only = read_only
+
+    def selectable(self):
+        if self.read_only:
+            return False
+        return super(PrimitivusStringWidget, self).selectable()
 
     def _xmluiSetValue(self, value):
         self.set_edit_text(value)
@@ -94,8 +100,14 @@
 
 class PrimitivusPasswordWidget(xmlui.PasswordWidget, sat_widgets.Password, PrimitivusEvents):
 
-    def __init__(self, parent, value):
+    def __init__(self, parent, value, read_only=False):
         sat_widgets.Password.__init__(self, edit_text=value)
+        self.read_only = read_only
+
+    def selectable(self):
+        if self.read_only:
+            return False
+        return super(PrimitivusPasswordWidget, self).selectable()
 
     def _xmluiSetValue(self, value):
         self.set_edit_text(value)
@@ -106,8 +118,14 @@
 
 class PrimitivusTextBoxWidget(xmlui.TextBoxWidget, sat_widgets.AdvancedEdit, PrimitivusEvents):
 
-    def __init__(self, parent, value):
+    def __init__(self, parent, value, read_only=False):
         sat_widgets.AdvancedEdit.__init__(self, edit_text=value, multiline=True)
+        self.read_only = read_only
+
+    def selectable(self):
+        if self.read_only:
+            return False
+        return super(PrimitivusTextBoxWidget, self).selectable()
 
     def _xmluiSetValue(self, value):
         self.set_edit_text(value)
@@ -118,8 +136,14 @@
 
 class PrimitivusBoolWidget(xmlui.BoolWidget, urwid.CheckBox, PrimitivusEvents):
 
-    def __init__(self, parent, state):
+    def __init__(self, parent, state, read_only=False):
         urwid.CheckBox.__init__(self, '', state=state)
+        self.read_only = read_only
+
+    def selectable(self):
+        if self.read_only:
+            return False
+        return super(PrimitivusBoolWidget, self).selectable()
 
     def _xmluiSetValue(self, value):
         self.set_state(value == "true")