comparison 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
comparison
equal deleted inserted replaced
1084:03dcb6ca7e49 1085:7a39ae3950f7
44 urwid.Text.__init__(self, '') 44 urwid.Text.__init__(self, '')
45 45
46 46
47 class PrimitivusTextWidget(xmlui.TextWidget, urwid.Text): 47 class PrimitivusTextWidget(xmlui.TextWidget, urwid.Text):
48 48
49 def __init__(self, parent, value): 49 def __init__(self, parent, value, read_only=False):
50 urwid.Text.__init__(self, value) 50 urwid.Text.__init__(self, value)
51 51
52 52
53 class PrimitivusLabelWidget(xmlui.LabelWidget, PrimitivusTextWidget): 53 class PrimitivusLabelWidget(xmlui.LabelWidget, PrimitivusTextWidget):
54 54
80 urwid.Divider.__init__(self, div_char) 80 urwid.Divider.__init__(self, div_char)
81 81
82 82
83 class PrimitivusStringWidget(xmlui.StringWidget, sat_widgets.AdvancedEdit, PrimitivusEvents): 83 class PrimitivusStringWidget(xmlui.StringWidget, sat_widgets.AdvancedEdit, PrimitivusEvents):
84 84
85 def __init__(self, parent, value): 85 def __init__(self, parent, value, read_only=False):
86 sat_widgets.AdvancedEdit.__init__(self, edit_text=value) 86 sat_widgets.AdvancedEdit.__init__(self, edit_text=value)
87 self.read_only = read_only
88
89 def selectable(self):
90 if self.read_only:
91 return False
92 return super(PrimitivusStringWidget, self).selectable()
87 93
88 def _xmluiSetValue(self, value): 94 def _xmluiSetValue(self, value):
89 self.set_edit_text(value) 95 self.set_edit_text(value)
90 96
91 def _xmluiGetValue(self): 97 def _xmluiGetValue(self):
92 return self.get_edit_text() 98 return self.get_edit_text()
93 99
94 100
95 class PrimitivusPasswordWidget(xmlui.PasswordWidget, sat_widgets.Password, PrimitivusEvents): 101 class PrimitivusPasswordWidget(xmlui.PasswordWidget, sat_widgets.Password, PrimitivusEvents):
96 102
97 def __init__(self, parent, value): 103 def __init__(self, parent, value, read_only=False):
98 sat_widgets.Password.__init__(self, edit_text=value) 104 sat_widgets.Password.__init__(self, edit_text=value)
105 self.read_only = read_only
106
107 def selectable(self):
108 if self.read_only:
109 return False
110 return super(PrimitivusPasswordWidget, self).selectable()
99 111
100 def _xmluiSetValue(self, value): 112 def _xmluiSetValue(self, value):
101 self.set_edit_text(value) 113 self.set_edit_text(value)
102 114
103 def _xmluiGetValue(self): 115 def _xmluiGetValue(self):
104 return self.get_edit_text() 116 return self.get_edit_text()
105 117
106 118
107 class PrimitivusTextBoxWidget(xmlui.TextBoxWidget, sat_widgets.AdvancedEdit, PrimitivusEvents): 119 class PrimitivusTextBoxWidget(xmlui.TextBoxWidget, sat_widgets.AdvancedEdit, PrimitivusEvents):
108 120
109 def __init__(self, parent, value): 121 def __init__(self, parent, value, read_only=False):
110 sat_widgets.AdvancedEdit.__init__(self, edit_text=value, multiline=True) 122 sat_widgets.AdvancedEdit.__init__(self, edit_text=value, multiline=True)
123 self.read_only = read_only
124
125 def selectable(self):
126 if self.read_only:
127 return False
128 return super(PrimitivusTextBoxWidget, self).selectable()
111 129
112 def _xmluiSetValue(self, value): 130 def _xmluiSetValue(self, value):
113 self.set_edit_text(value) 131 self.set_edit_text(value)
114 132
115 def _xmluiGetValue(self): 133 def _xmluiGetValue(self):
116 return self.get_edit_text() 134 return self.get_edit_text()
117 135
118 136
119 class PrimitivusBoolWidget(xmlui.BoolWidget, urwid.CheckBox, PrimitivusEvents): 137 class PrimitivusBoolWidget(xmlui.BoolWidget, urwid.CheckBox, PrimitivusEvents):
120 138
121 def __init__(self, parent, state): 139 def __init__(self, parent, state, read_only=False):
122 urwid.CheckBox.__init__(self, '', state=state) 140 urwid.CheckBox.__init__(self, '', state=state)
141 self.read_only = read_only
142
143 def selectable(self):
144 if self.read_only:
145 return False
146 return super(PrimitivusBoolWidget, self).selectable()
123 147
124 def _xmluiSetValue(self, value): 148 def _xmluiSetValue(self, value):
125 self.set_state(value == "true") 149 self.set_state(value == "true")
126 150
127 def _xmluiGetValue(self): 151 def _xmluiGetValue(self):