annotate sat/tools/common/template_xmlui.py @ 2650:3a8e7ec4648a

tools (trigger, async_trigger): added no_cancel argument to point and asyncPoint when a trigger must not be cancellable
author Goffi <goffi@goffi.org>
date Sat, 11 Aug 2018 18:24:52 +0200
parents 56f94936df1e
children bdb8276fd2da
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
2483
0046283a285d dates update
Goffi <goffi@goffi.org>
parents: 2455
diff changeset
5 # Copyright (C) 2009-2018 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
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
26
2362
3acbaf5c29f5 template: template XMLUI first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
27 log = getLogger(__name__)
3acbaf5c29f5 template: template XMLUI first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
28 from sat_frontends.tools import xmlui
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
3acbaf5c29f5 template: template XMLUI first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
31 ## Widgets ##
3acbaf5c29f5 template: template XMLUI first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
32
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
33
2362
3acbaf5c29f5 template: template XMLUI first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
34 class Widget(object):
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
35 category = u"widget"
2362
3acbaf5c29f5 template: template XMLUI first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
36 type = None
3acbaf5c29f5 template: template XMLUI first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
37 enabled = True
3acbaf5c29f5 template: template XMLUI first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
38 read_only = True
3acbaf5c29f5 template: template XMLUI first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
39
3acbaf5c29f5 template: template XMLUI first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
40 def __init__(self, xmlui_parent):
3acbaf5c29f5 template: template XMLUI first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
41 self.xmlui_parent = xmlui_parent
3acbaf5c29f5 template: template XMLUI first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
42
3acbaf5c29f5 template: template XMLUI first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
43 @property
3acbaf5c29f5 template: template XMLUI first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
44 def name(self):
3acbaf5c29f5 template: template XMLUI first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
45 return self._xmlui_name
3acbaf5c29f5 template: template XMLUI first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
46
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 class ValueWidget(Widget):
3acbaf5c29f5 template: template XMLUI first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
49 def __init__(self, xmlui_parent, value):
3acbaf5c29f5 template: template XMLUI first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
50 super(ValueWidget, self).__init__(xmlui_parent)
3acbaf5c29f5 template: template XMLUI first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
51 self.value = value
3acbaf5c29f5 template: template XMLUI first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
52
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
53 @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
54 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
55 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
56
2455
7b02372f8734 template (xmlui): added labels property in ValueWidget (actually return values) and values property in OptionsWidget
Goffi <goffi@goffi.org>
parents: 2435
diff changeset
57 @property
7b02372f8734 template (xmlui): added labels property in ValueWidget (actually return values) and values property in OptionsWidget
Goffi <goffi@goffi.org>
parents: 2435
diff changeset
58 def labels(self):
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
59 #  helper property, there is not label for ValueWidget
2455
7b02372f8734 template (xmlui): added labels property in ValueWidget (actually return values) and values property in OptionsWidget
Goffi <goffi@goffi.org>
parents: 2435
diff changeset
60 # but using labels make rendering more easy (one single method to call)
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
61 #  values are actually returned
2455
7b02372f8734 template (xmlui): added labels property in ValueWidget (actually return values) and values property in OptionsWidget
Goffi <goffi@goffi.org>
parents: 2435
diff changeset
62 return [self.value]
7b02372f8734 template (xmlui): added labels property in ValueWidget (actually return values) and values property in OptionsWidget
Goffi <goffi@goffi.org>
parents: 2435
diff changeset
63
2362
3acbaf5c29f5 template: template XMLUI first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
64
3acbaf5c29f5 template: template XMLUI first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
65 class InputWidget(ValueWidget):
3acbaf5c29f5 template: template XMLUI first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
66 def __init__(self, xmlui_parent, value, read_only=False):
3acbaf5c29f5 template: template XMLUI first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
67 super(InputWidget, self).__init__(xmlui_parent, value)
3acbaf5c29f5 template: template XMLUI first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
68 self.read_only = read_only
3acbaf5c29f5 template: template XMLUI first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
69
3acbaf5c29f5 template: template XMLUI first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
70
3acbaf5c29f5 template: template XMLUI first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
71 class OptionsWidget(Widget):
3acbaf5c29f5 template: template XMLUI first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
72 def __init__(self, xmlui_parent, options, selected, style):
3acbaf5c29f5 template: template XMLUI first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
73 super(OptionsWidget, self).__init__(xmlui_parent)
3acbaf5c29f5 template: template XMLUI first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
74 self.options = options
3acbaf5c29f5 template: template XMLUI first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
75 self.selected = selected
3acbaf5c29f5 template: template XMLUI first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
76 self.style = style
3acbaf5c29f5 template: template XMLUI first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
77
2379
42a54cbc1872 template (xmlui): new properties + inheritance fix:
Goffi <goffi@goffi.org>
parents: 2367
diff changeset
78 @property
42a54cbc1872 template (xmlui): new properties + inheritance fix:
Goffi <goffi@goffi.org>
parents: 2367
diff changeset
79 def values(self):
2455
7b02372f8734 template (xmlui): added labels property in ValueWidget (actually return values) and values property in OptionsWidget
Goffi <goffi@goffi.org>
parents: 2435
diff changeset
80 for value, label in self.items:
7b02372f8734 template (xmlui): added labels property in ValueWidget (actually return values) and values property in OptionsWidget
Goffi <goffi@goffi.org>
parents: 2435
diff changeset
81 yield value
2379
42a54cbc1872 template (xmlui): new properties + inheritance fix:
Goffi <goffi@goffi.org>
parents: 2367
diff changeset
82
42a54cbc1872 template (xmlui): new properties + inheritance fix:
Goffi <goffi@goffi.org>
parents: 2367
diff changeset
83 @property
42a54cbc1872 template (xmlui): new properties + inheritance fix:
Goffi <goffi@goffi.org>
parents: 2367
diff changeset
84 def labels(self):
2400
8253ea069781 template(XMLUI): added items property to ListWidget:
Goffi <goffi@goffi.org>
parents: 2397
diff changeset
85 """return only labels from self.items"""
8253ea069781 template(XMLUI): added items property to ListWidget:
Goffi <goffi@goffi.org>
parents: 2397
diff changeset
86 for value, label in self.items:
8253ea069781 template(XMLUI): added items property to ListWidget:
Goffi <goffi@goffi.org>
parents: 2397
diff changeset
87 yield label
8253ea069781 template(XMLUI): added items property to ListWidget:
Goffi <goffi@goffi.org>
parents: 2397
diff changeset
88
8253ea069781 template(XMLUI): added items property to ListWidget:
Goffi <goffi@goffi.org>
parents: 2397
diff changeset
89 @property
8253ea069781 template(XMLUI): added items property to ListWidget:
Goffi <goffi@goffi.org>
parents: 2397
diff changeset
90 def items(self):
8253ea069781 template(XMLUI): added items property to ListWidget:
Goffi <goffi@goffi.org>
parents: 2397
diff changeset
91 """return suitable items, according to style"""
8253ea069781 template(XMLUI): added items property to ListWidget:
Goffi <goffi@goffi.org>
parents: 2397
diff changeset
92 no_select = self.no_select
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
93 for value, label in self.options:
2400
8253ea069781 template(XMLUI): added items property to ListWidget:
Goffi <goffi@goffi.org>
parents: 2397
diff changeset
94 if no_select or value in self.selected:
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
95 yield value, label
2379
42a54cbc1872 template (xmlui): new properties + inheritance fix:
Goffi <goffi@goffi.org>
parents: 2367
diff changeset
96
2397
7fff98d64ab5 core (XMLUI), template(XMLUI): added flags to ListWidget:
Goffi <goffi@goffi.org>
parents: 2379
diff changeset
97 @property
7fff98d64ab5 core (XMLUI), template(XMLUI): added flags to ListWidget:
Goffi <goffi@goffi.org>
parents: 2379
diff changeset
98 def inline(self):
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
99 return u"inline" in self.style
2397
7fff98d64ab5 core (XMLUI), template(XMLUI): added flags to ListWidget:
Goffi <goffi@goffi.org>
parents: 2379
diff changeset
100
7fff98d64ab5 core (XMLUI), template(XMLUI): added flags to ListWidget:
Goffi <goffi@goffi.org>
parents: 2379
diff changeset
101 @property
7fff98d64ab5 core (XMLUI), template(XMLUI): added flags to ListWidget:
Goffi <goffi@goffi.org>
parents: 2379
diff changeset
102 def no_select(self):
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
103 return u"noselect" in self.style
2397
7fff98d64ab5 core (XMLUI), template(XMLUI): added flags to ListWidget:
Goffi <goffi@goffi.org>
parents: 2379
diff changeset
104
2362
3acbaf5c29f5 template: template XMLUI first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
105
3acbaf5c29f5 template: template XMLUI first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
106 class EmptyWidget(xmlui.EmptyWidget, Widget):
3acbaf5c29f5 template: template XMLUI first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
107 def __init__(self, _xmlui_parent):
3acbaf5c29f5 template: template XMLUI first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
108 Widget.__init__(self)
3acbaf5c29f5 template: template XMLUI first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
109
3acbaf5c29f5 template: template XMLUI first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
110
3acbaf5c29f5 template: template XMLUI first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
111 class TextWidget(xmlui.TextWidget, ValueWidget):
3acbaf5c29f5 template: template XMLUI first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
112 type = u"text"
3acbaf5c29f5 template: template XMLUI first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
113
3acbaf5c29f5 template: template XMLUI first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
114
3acbaf5c29f5 template: template XMLUI first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
115 class LabelWidget(xmlui.LabelWidget, ValueWidget):
3acbaf5c29f5 template: template XMLUI first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
116 type = u"label"
3acbaf5c29f5 template: template XMLUI first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
117
2379
42a54cbc1872 template (xmlui): new properties + inheritance fix:
Goffi <goffi@goffi.org>
parents: 2367
diff changeset
118 @property
42a54cbc1872 template (xmlui): new properties + inheritance fix:
Goffi <goffi@goffi.org>
parents: 2367
diff changeset
119 def for_name(self):
42a54cbc1872 template (xmlui): new properties + inheritance fix:
Goffi <goffi@goffi.org>
parents: 2367
diff changeset
120 try:
42a54cbc1872 template (xmlui): new properties + inheritance fix:
Goffi <goffi@goffi.org>
parents: 2367
diff changeset
121 return self._xmlui_for_name
42a54cbc1872 template (xmlui): new properties + inheritance fix:
Goffi <goffi@goffi.org>
parents: 2367
diff changeset
122 except AttributeError:
42a54cbc1872 template (xmlui): new properties + inheritance fix:
Goffi <goffi@goffi.org>
parents: 2367
diff changeset
123 return None
2362
3acbaf5c29f5 template: template XMLUI first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
124
2379
42a54cbc1872 template (xmlui): new properties + inheritance fix:
Goffi <goffi@goffi.org>
parents: 2367
diff changeset
125
42a54cbc1872 template (xmlui): new properties + inheritance fix:
Goffi <goffi@goffi.org>
parents: 2367
diff changeset
126 class StringWidget(xmlui.StringWidget, InputWidget):
2362
3acbaf5c29f5 template: template XMLUI first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
127 type = u"string"
3acbaf5c29f5 template: template XMLUI first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
128
3acbaf5c29f5 template: template XMLUI first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
129
2435
49884c579266 template (XMLUI): added JidInputWidget
Goffi <goffi@goffi.org>
parents: 2419
diff changeset
130 class JidInputWidget(xmlui.JidInputWidget, StringWidget):
49884c579266 template (XMLUI): added JidInputWidget
Goffi <goffi@goffi.org>
parents: 2419
diff changeset
131 type = u"jid"
49884c579266 template (XMLUI): added JidInputWidget
Goffi <goffi@goffi.org>
parents: 2419
diff changeset
132
49884c579266 template (XMLUI): added JidInputWidget
Goffi <goffi@goffi.org>
parents: 2419
diff changeset
133
2379
42a54cbc1872 template (xmlui): new properties + inheritance fix:
Goffi <goffi@goffi.org>
parents: 2367
diff changeset
134 class TextBoxWidget(xmlui.TextWidget, InputWidget):
2362
3acbaf5c29f5 template: template XMLUI first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
135 type = u"textbox"
3acbaf5c29f5 template: template XMLUI first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
136
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 ListWidget(xmlui.ListWidget, OptionsWidget):
3acbaf5c29f5 template: template XMLUI first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
139 type = u"list"
3acbaf5c29f5 template: template XMLUI first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
140
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 ## Containers ##
3acbaf5c29f5 template: template XMLUI first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
143
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
144
2362
3acbaf5c29f5 template: template XMLUI first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
145 class Container(object):
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
146 category = u"container"
2362
3acbaf5c29f5 template: template XMLUI first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
147 type = None
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 __init__(self, xmlui_parent):
3acbaf5c29f5 template: template XMLUI first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
150 self.xmlui_parent = xmlui_parent
3acbaf5c29f5 template: template XMLUI first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
151 self.children = []
3acbaf5c29f5 template: template XMLUI first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
152
3acbaf5c29f5 template: template XMLUI first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
153 def __iter__(self):
3acbaf5c29f5 template: template XMLUI first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
154 return iter(self.children)
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 def _xmluiAppend(self, widget):
3acbaf5c29f5 template: template XMLUI first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
157 self.children.append(widget)
3acbaf5c29f5 template: template XMLUI first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
158
2419
c38c54c47e16 frontends (xmlui): added an attribute to ignore some widgets (and their label) in create
Goffi <goffi@goffi.org>
parents: 2414
diff changeset
159 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
160 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
161
2362
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 class VerticalContainer(xmlui.VerticalContainer, Container):
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
164 type = u"vertical"
2362
3acbaf5c29f5 template: template XMLUI first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
165
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 class PairsContainer(xmlui.PairsContainer, Container):
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
168 type = u"pairs"
2362
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
3acbaf5c29f5 template: template XMLUI first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
171 class LabelContainer(xmlui.PairsContainer, Container):
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
172 type = u"label"
2362
3acbaf5c29f5 template: template XMLUI first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
173
3acbaf5c29f5 template: template XMLUI first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
174
3acbaf5c29f5 template: template XMLUI first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
175 ## Factory ##
3acbaf5c29f5 template: template XMLUI first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
176
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
177
2362
3acbaf5c29f5 template: template XMLUI first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
178 class WidgetFactory(object):
3acbaf5c29f5 template: template XMLUI first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
179 def __getattr__(self, attr):
3acbaf5c29f5 template: template XMLUI first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
180 if attr.startswith("create"):
3acbaf5c29f5 template: template XMLUI first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
181 cls = globals()[attr[6:]]
3acbaf5c29f5 template: template XMLUI first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
182 return cls
3acbaf5c29f5 template: template XMLUI first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
183
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
184
2362
3acbaf5c29f5 template: template XMLUI first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
185 ## Core ##
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
3acbaf5c29f5 template: template XMLUI first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
188 class XMLUIPanel(xmlui.XMLUIPanel):
3acbaf5c29f5 template: template XMLUI first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
189 widget_factory = WidgetFactory()
3acbaf5c29f5 template: template XMLUI first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
190
3acbaf5c29f5 template: template XMLUI first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
191 def show(self, *args, **kwargs):
3acbaf5c29f5 template: template XMLUI first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
192 raise NotImplementedError
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
3acbaf5c29f5 template: template XMLUI first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
195 class XMLUIDialog(xmlui.XMLUIDialog):
3acbaf5c29f5 template: template XMLUI first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
196 dialog_factory = WidgetFactory()
3acbaf5c29f5 template: template XMLUI first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
197
3acbaf5c29f5 template: template XMLUI first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
198 def __init__(*args, **kwargs):
3acbaf5c29f5 template: template XMLUI first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
199 raise NotImplementedError
3acbaf5c29f5 template: template XMLUI first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
200
3acbaf5c29f5 template: template XMLUI first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
201
3acbaf5c29f5 template: template XMLUI first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
202 xmlui.registerClass(xmlui.CLASS_PANEL, XMLUIPanel)
3acbaf5c29f5 template: template XMLUI first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
203 xmlui.registerClass(xmlui.CLASS_DIALOG, XMLUIDialog)
3acbaf5c29f5 template: template XMLUI first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
204 create = xmlui.create