annotate src/tools/common/template_xmlui.py @ 2440:51d346e283fd

plugin XML Log: Monkey patch is done on the whole XmlStream class, making it available as soon as the stream start + long received message are sent once fully parsed (not cut anymore)
author Goffi <goffi@goffi.org>
date Sat, 18 Nov 2017 18:49:57 +0100
parents 49884c579266
children 7b02372f8734
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
2362
3acbaf5c29f5 template: template XMLUI first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
1 #!/usr/bin/env python2
3acbaf5c29f5 template: template XMLUI first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
2 # -*- coding: utf-8 -*-
3acbaf5c29f5 template: template XMLUI first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
3
3acbaf5c29f5 template: template XMLUI first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
4 # SAT: a jabber client
2414
8b37a62336c3 misc: date update (yes it's a bit late :p )
Goffi <goffi@goffi.org>
parents: 2400
diff changeset
5 # Copyright (C) 2009-2017 Jérôme Poisson (goffi@goffi.org)
2362
3acbaf5c29f5 template: template XMLUI first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
6
3acbaf5c29f5 template: template XMLUI first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
7 # This program is free software: you can redistribute it and/or modify
3acbaf5c29f5 template: template XMLUI first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
8 # it under the terms of the GNU Affero General Public License as published by
3acbaf5c29f5 template: template XMLUI first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
9 # the Free Software Foundation, either version 3 of the License, or
3acbaf5c29f5 template: template XMLUI first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
10 # (at your option) any later version.
3acbaf5c29f5 template: template XMLUI first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
11
3acbaf5c29f5 template: template XMLUI first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
12 # This program is distributed in the hope that it will be useful,
3acbaf5c29f5 template: template XMLUI first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
3acbaf5c29f5 template: template XMLUI first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3acbaf5c29f5 template: template XMLUI first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
15 # GNU Affero General Public License for more details.
3acbaf5c29f5 template: template XMLUI first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
16
3acbaf5c29f5 template: template XMLUI first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
17 # You should have received a copy of the GNU Affero General Public License
3acbaf5c29f5 template: template XMLUI first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
18 # along with this program. If not, see <http://www.gnu.org/licenses/>.
3acbaf5c29f5 template: template XMLUI first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
19
3acbaf5c29f5 template: template XMLUI first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
20 """ template XMLUI parsing
3acbaf5c29f5 template: template XMLUI first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
21
3acbaf5c29f5 template: template XMLUI first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
22 XMLUI classes from this modules can then be iterated to create the template
3acbaf5c29f5 template: template XMLUI first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
23 """
3acbaf5c29f5 template: template XMLUI first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
24
3acbaf5c29f5 template: template XMLUI first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
25 from sat.core.log import getLogger
3acbaf5c29f5 template: template XMLUI first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
26 log = getLogger(__name__)
3acbaf5c29f5 template: template XMLUI first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
27 from sat_frontends.tools import xmlui
3acbaf5c29f5 template: template XMLUI first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
28
3acbaf5c29f5 template: template XMLUI first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
29
3acbaf5c29f5 template: template XMLUI first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
30 ## Widgets ##
3acbaf5c29f5 template: template XMLUI first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
31
3acbaf5c29f5 template: template XMLUI first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
32 class Widget(object):
3acbaf5c29f5 template: template XMLUI first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
33 category = u'widget'
3acbaf5c29f5 template: template XMLUI first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
34 type = None
3acbaf5c29f5 template: template XMLUI first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
35 enabled = True
3acbaf5c29f5 template: template XMLUI first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
36 read_only = True
3acbaf5c29f5 template: template XMLUI first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
37
3acbaf5c29f5 template: template XMLUI first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
38 def __init__(self, xmlui_parent):
3acbaf5c29f5 template: template XMLUI first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
39 self.xmlui_parent = xmlui_parent
3acbaf5c29f5 template: template XMLUI first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
40
3acbaf5c29f5 template: template XMLUI first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
41 @property
3acbaf5c29f5 template: template XMLUI first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
42 def name(self):
3acbaf5c29f5 template: template XMLUI first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
43 return self._xmlui_name
3acbaf5c29f5 template: template XMLUI first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
44
3acbaf5c29f5 template: template XMLUI first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
45
3acbaf5c29f5 template: template XMLUI first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
46 class ValueWidget(Widget):
3acbaf5c29f5 template: template XMLUI first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
47
3acbaf5c29f5 template: template XMLUI first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
48 def __init__(self, xmlui_parent, value):
3acbaf5c29f5 template: template XMLUI first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
49 super(ValueWidget, self).__init__(xmlui_parent)
3acbaf5c29f5 template: template XMLUI first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
50 self.value = value
3acbaf5c29f5 template: template XMLUI first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
51
2367
9878635586f3 template (xmlui): added values property to be able to use always values even when there is only one value
Goffi <goffi@goffi.org>
parents: 2362
diff changeset
52 @property
9878635586f3 template (xmlui): added values property to be able to use always values even when there is only one value
Goffi <goffi@goffi.org>
parents: 2362
diff changeset
53 def values(self):
9878635586f3 template (xmlui): added values property to be able to use always values even when there is only one value
Goffi <goffi@goffi.org>
parents: 2362
diff changeset
54 return [self.value]
9878635586f3 template (xmlui): added values property to be able to use always values even when there is only one value
Goffi <goffi@goffi.org>
parents: 2362
diff changeset
55
2362
3acbaf5c29f5 template: template XMLUI first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
56
3acbaf5c29f5 template: template XMLUI first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
57 class InputWidget(ValueWidget):
3acbaf5c29f5 template: template XMLUI first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
58
3acbaf5c29f5 template: template XMLUI first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
59 def __init__(self, xmlui_parent, value, read_only=False):
3acbaf5c29f5 template: template XMLUI first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
60 super(InputWidget, self).__init__(xmlui_parent, value)
3acbaf5c29f5 template: template XMLUI first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
61 self.read_only = read_only
3acbaf5c29f5 template: template XMLUI first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
62
3acbaf5c29f5 template: template XMLUI first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
63
3acbaf5c29f5 template: template XMLUI first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
64 class OptionsWidget(Widget):
3acbaf5c29f5 template: template XMLUI first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
65
3acbaf5c29f5 template: template XMLUI first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
66 def __init__(self, xmlui_parent, options, selected, style):
3acbaf5c29f5 template: template XMLUI first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
67 super(OptionsWidget, self).__init__(xmlui_parent)
3acbaf5c29f5 template: template XMLUI first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
68 self.options = options
3acbaf5c29f5 template: template XMLUI first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
69 self.selected = selected
3acbaf5c29f5 template: template XMLUI first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
70 self.style = style
3acbaf5c29f5 template: template XMLUI first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
71
2379
42a54cbc1872 template (xmlui): new properties + inheritance fix:
Goffi <goffi@goffi.org>
parents: 2367
diff changeset
72 @property
42a54cbc1872 template (xmlui): new properties + inheritance fix:
Goffi <goffi@goffi.org>
parents: 2367
diff changeset
73 def values(self):
42a54cbc1872 template (xmlui): new properties + inheritance fix:
Goffi <goffi@goffi.org>
parents: 2367
diff changeset
74 return self.selected
42a54cbc1872 template (xmlui): new properties + inheritance fix:
Goffi <goffi@goffi.org>
parents: 2367
diff changeset
75
42a54cbc1872 template (xmlui): new properties + inheritance fix:
Goffi <goffi@goffi.org>
parents: 2367
diff changeset
76 @property
42a54cbc1872 template (xmlui): new properties + inheritance fix:
Goffi <goffi@goffi.org>
parents: 2367
diff changeset
77 def labels(self):
2400
8253ea069781 template(XMLUI): added items property to ListWidget:
Goffi <goffi@goffi.org>
parents: 2397
diff changeset
78 """return only labels from self.items"""
8253ea069781 template(XMLUI): added items property to ListWidget:
Goffi <goffi@goffi.org>
parents: 2397
diff changeset
79 for value, label in self.items:
8253ea069781 template(XMLUI): added items property to ListWidget:
Goffi <goffi@goffi.org>
parents: 2397
diff changeset
80 yield label
8253ea069781 template(XMLUI): added items property to ListWidget:
Goffi <goffi@goffi.org>
parents: 2397
diff changeset
81
8253ea069781 template(XMLUI): added items property to ListWidget:
Goffi <goffi@goffi.org>
parents: 2397
diff changeset
82 @property
8253ea069781 template(XMLUI): added items property to ListWidget:
Goffi <goffi@goffi.org>
parents: 2397
diff changeset
83 def items(self):
8253ea069781 template(XMLUI): added items property to ListWidget:
Goffi <goffi@goffi.org>
parents: 2397
diff changeset
84 """return suitable items, according to style"""
8253ea069781 template(XMLUI): added items property to ListWidget:
Goffi <goffi@goffi.org>
parents: 2397
diff changeset
85 no_select = self.no_select
2379
42a54cbc1872 template (xmlui): new properties + inheritance fix:
Goffi <goffi@goffi.org>
parents: 2367
diff changeset
86 for value,label in self.options:
2400
8253ea069781 template(XMLUI): added items property to ListWidget:
Goffi <goffi@goffi.org>
parents: 2397
diff changeset
87 if no_select or value in self.selected:
8253ea069781 template(XMLUI): added items property to ListWidget:
Goffi <goffi@goffi.org>
parents: 2397
diff changeset
88 yield value,label
2379
42a54cbc1872 template (xmlui): new properties + inheritance fix:
Goffi <goffi@goffi.org>
parents: 2367
diff changeset
89
2397
7fff98d64ab5 core (XMLUI), template(XMLUI): added flags to ListWidget:
Goffi <goffi@goffi.org>
parents: 2379
diff changeset
90 @property
7fff98d64ab5 core (XMLUI), template(XMLUI): added flags to ListWidget:
Goffi <goffi@goffi.org>
parents: 2379
diff changeset
91 def inline(self):
7fff98d64ab5 core (XMLUI), template(XMLUI): added flags to ListWidget:
Goffi <goffi@goffi.org>
parents: 2379
diff changeset
92 return u'inline' in self.style
7fff98d64ab5 core (XMLUI), template(XMLUI): added flags to ListWidget:
Goffi <goffi@goffi.org>
parents: 2379
diff changeset
93
7fff98d64ab5 core (XMLUI), template(XMLUI): added flags to ListWidget:
Goffi <goffi@goffi.org>
parents: 2379
diff changeset
94 @property
7fff98d64ab5 core (XMLUI), template(XMLUI): added flags to ListWidget:
Goffi <goffi@goffi.org>
parents: 2379
diff changeset
95 def no_select(self):
7fff98d64ab5 core (XMLUI), template(XMLUI): added flags to ListWidget:
Goffi <goffi@goffi.org>
parents: 2379
diff changeset
96 return u'noselect' in self.style
7fff98d64ab5 core (XMLUI), template(XMLUI): added flags to ListWidget:
Goffi <goffi@goffi.org>
parents: 2379
diff changeset
97
2362
3acbaf5c29f5 template: template XMLUI first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
98
3acbaf5c29f5 template: template XMLUI first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
99 class EmptyWidget(xmlui.EmptyWidget, Widget):
3acbaf5c29f5 template: template XMLUI first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
100
3acbaf5c29f5 template: template XMLUI first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
101 def __init__(self, _xmlui_parent):
3acbaf5c29f5 template: template XMLUI first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
102 Widget.__init__(self)
3acbaf5c29f5 template: template XMLUI first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
103
3acbaf5c29f5 template: template XMLUI first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
104
3acbaf5c29f5 template: template XMLUI first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
105 class TextWidget(xmlui.TextWidget, ValueWidget):
3acbaf5c29f5 template: template XMLUI first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
106 type = u"text"
3acbaf5c29f5 template: template XMLUI first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
107
3acbaf5c29f5 template: template XMLUI first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
108
3acbaf5c29f5 template: template XMLUI first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
109 class LabelWidget(xmlui.LabelWidget, ValueWidget):
3acbaf5c29f5 template: template XMLUI first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
110 type = u"label"
3acbaf5c29f5 template: template XMLUI first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
111
2379
42a54cbc1872 template (xmlui): new properties + inheritance fix:
Goffi <goffi@goffi.org>
parents: 2367
diff changeset
112 @property
42a54cbc1872 template (xmlui): new properties + inheritance fix:
Goffi <goffi@goffi.org>
parents: 2367
diff changeset
113 def for_name(self):
42a54cbc1872 template (xmlui): new properties + inheritance fix:
Goffi <goffi@goffi.org>
parents: 2367
diff changeset
114 try:
42a54cbc1872 template (xmlui): new properties + inheritance fix:
Goffi <goffi@goffi.org>
parents: 2367
diff changeset
115 return self._xmlui_for_name
42a54cbc1872 template (xmlui): new properties + inheritance fix:
Goffi <goffi@goffi.org>
parents: 2367
diff changeset
116 except AttributeError:
42a54cbc1872 template (xmlui): new properties + inheritance fix:
Goffi <goffi@goffi.org>
parents: 2367
diff changeset
117 return None
2362
3acbaf5c29f5 template: template XMLUI first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
118
2379
42a54cbc1872 template (xmlui): new properties + inheritance fix:
Goffi <goffi@goffi.org>
parents: 2367
diff changeset
119
42a54cbc1872 template (xmlui): new properties + inheritance fix:
Goffi <goffi@goffi.org>
parents: 2367
diff changeset
120 class StringWidget(xmlui.StringWidget, InputWidget):
2362
3acbaf5c29f5 template: template XMLUI first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
121 type = u"string"
3acbaf5c29f5 template: template XMLUI first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
122
3acbaf5c29f5 template: template XMLUI first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
123
2435
49884c579266 template (XMLUI): added JidInputWidget
Goffi <goffi@goffi.org>
parents: 2419
diff changeset
124 class JidInputWidget(xmlui.JidInputWidget, StringWidget):
49884c579266 template (XMLUI): added JidInputWidget
Goffi <goffi@goffi.org>
parents: 2419
diff changeset
125 type = u"jid"
49884c579266 template (XMLUI): added JidInputWidget
Goffi <goffi@goffi.org>
parents: 2419
diff changeset
126
49884c579266 template (XMLUI): added JidInputWidget
Goffi <goffi@goffi.org>
parents: 2419
diff changeset
127
2379
42a54cbc1872 template (xmlui): new properties + inheritance fix:
Goffi <goffi@goffi.org>
parents: 2367
diff changeset
128 class TextBoxWidget(xmlui.TextWidget, InputWidget):
2362
3acbaf5c29f5 template: template XMLUI first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
129 type = u"textbox"
3acbaf5c29f5 template: template XMLUI first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
130
3acbaf5c29f5 template: template XMLUI first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
131
3acbaf5c29f5 template: template XMLUI first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
132 class ListWidget(xmlui.ListWidget, OptionsWidget):
3acbaf5c29f5 template: template XMLUI first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
133 type = u"list"
3acbaf5c29f5 template: template XMLUI first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
134
3acbaf5c29f5 template: template XMLUI first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
135
3acbaf5c29f5 template: template XMLUI first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
136 ## Containers ##
3acbaf5c29f5 template: template XMLUI first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
137
3acbaf5c29f5 template: template XMLUI first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
138 class Container(object):
3acbaf5c29f5 template: template XMLUI first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
139 category = u'container'
3acbaf5c29f5 template: template XMLUI first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
140 type = None
3acbaf5c29f5 template: template XMLUI first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
141
3acbaf5c29f5 template: template XMLUI first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
142 def __init__(self, xmlui_parent):
3acbaf5c29f5 template: template XMLUI first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
143 self.xmlui_parent = xmlui_parent
3acbaf5c29f5 template: template XMLUI first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
144 self.children = []
3acbaf5c29f5 template: template XMLUI first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
145
3acbaf5c29f5 template: template XMLUI first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
146 def __iter__(self):
3acbaf5c29f5 template: template XMLUI first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
147 return iter(self.children)
3acbaf5c29f5 template: template XMLUI first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
148
3acbaf5c29f5 template: template XMLUI first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
149 def _xmluiAppend(self, widget):
3acbaf5c29f5 template: template XMLUI first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
150 self.children.append(widget)
3acbaf5c29f5 template: template XMLUI first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
151
2419
c38c54c47e16 frontends (xmlui): added an attribute to ignore some widgets (and their label) in create
Goffi <goffi@goffi.org>
parents: 2414
diff changeset
152 def _xmluiRemove(self, widget):
c38c54c47e16 frontends (xmlui): added an attribute to ignore some widgets (and their label) in create
Goffi <goffi@goffi.org>
parents: 2414
diff changeset
153 self.children.remove(widget)
c38c54c47e16 frontends (xmlui): added an attribute to ignore some widgets (and their label) in create
Goffi <goffi@goffi.org>
parents: 2414
diff changeset
154
2362
3acbaf5c29f5 template: template XMLUI first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
155
3acbaf5c29f5 template: template XMLUI first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
156 class VerticalContainer(xmlui.VerticalContainer, Container):
3acbaf5c29f5 template: template XMLUI first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
157 type = u'vertical'
3acbaf5c29f5 template: template XMLUI first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
158
3acbaf5c29f5 template: template XMLUI first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
159
3acbaf5c29f5 template: template XMLUI first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
160 class PairsContainer(xmlui.PairsContainer, Container):
3acbaf5c29f5 template: template XMLUI first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
161 type = u'pairs'
3acbaf5c29f5 template: template XMLUI first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
162
3acbaf5c29f5 template: template XMLUI first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
163
3acbaf5c29f5 template: template XMLUI first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
164 class LabelContainer(xmlui.PairsContainer, Container):
3acbaf5c29f5 template: template XMLUI first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
165 type = u'label'
3acbaf5c29f5 template: template XMLUI first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
166
3acbaf5c29f5 template: template XMLUI first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
167
3acbaf5c29f5 template: template XMLUI first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
168 ## Factory ##
3acbaf5c29f5 template: template XMLUI first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
169
3acbaf5c29f5 template: template XMLUI first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
170 class WidgetFactory(object):
3acbaf5c29f5 template: template XMLUI first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
171
3acbaf5c29f5 template: template XMLUI first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
172 def __getattr__(self, attr):
3acbaf5c29f5 template: template XMLUI first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
173 if attr.startswith("create"):
3acbaf5c29f5 template: template XMLUI first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
174 cls = globals()[attr[6:]]
3acbaf5c29f5 template: template XMLUI first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
175 return cls
3acbaf5c29f5 template: template XMLUI first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
176
3acbaf5c29f5 template: template XMLUI first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
177 ## Core ##
3acbaf5c29f5 template: template XMLUI first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
178
3acbaf5c29f5 template: template XMLUI first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
179
3acbaf5c29f5 template: template XMLUI first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
180 class XMLUIPanel(xmlui.XMLUIPanel):
3acbaf5c29f5 template: template XMLUI first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
181 widget_factory = WidgetFactory()
3acbaf5c29f5 template: template XMLUI first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
182
3acbaf5c29f5 template: template XMLUI first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
183 def show(self, *args, **kwargs):
3acbaf5c29f5 template: template XMLUI first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
184 raise NotImplementedError
3acbaf5c29f5 template: template XMLUI first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
185
3acbaf5c29f5 template: template XMLUI first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
186
3acbaf5c29f5 template: template XMLUI first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
187 class XMLUIDialog(xmlui.XMLUIDialog):
3acbaf5c29f5 template: template XMLUI first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
188 dialog_factory = WidgetFactory()
3acbaf5c29f5 template: template XMLUI first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
189
3acbaf5c29f5 template: template XMLUI first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
190 def __init__(*args, **kwargs):
3acbaf5c29f5 template: template XMLUI first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
191 raise NotImplementedError
3acbaf5c29f5 template: template XMLUI first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
192
3acbaf5c29f5 template: template XMLUI first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
193
3acbaf5c29f5 template: template XMLUI first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
194 xmlui.registerClass(xmlui.CLASS_PANEL, XMLUIPanel)
3acbaf5c29f5 template: template XMLUI first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
195 xmlui.registerClass(xmlui.CLASS_DIALOG, XMLUIDialog)
3acbaf5c29f5 template: template XMLUI first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
196 create = xmlui.create