annotate frontends/src/tools/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 d2e612a45e76
children 2cb30f46e560
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
144
80661755ea8d Primitivus: Tarot card game implementation
Goffi <goffi@goffi.org>
parents:
diff changeset
1 #!/usr/bin/python
80661755ea8d Primitivus: Tarot card game implementation
Goffi <goffi@goffi.org>
parents:
diff changeset
2 # -*- coding: utf-8 -*-
80661755ea8d Primitivus: Tarot card game implementation
Goffi <goffi@goffi.org>
parents:
diff changeset
3
796
46aa5ada61bf core, frontends: XMLUI refactoring:
Goffi <goffi@goffi.org>
parents: 771
diff changeset
4 # SàT frontend tools
811
1fe00f0c9a91 dates update
Goffi <goffi@goffi.org>
parents: 808
diff changeset
5 # Copyright (C) 2009, 2010, 2011, 2012, 2013, 2014 Jérôme Poisson (goffi@goffi.org)
144
80661755ea8d Primitivus: Tarot card game implementation
Goffi <goffi@goffi.org>
parents:
diff changeset
6
609
84a6e83157c2 fixed licences in docstrings (they are now in comments)
Goffi <goffi@goffi.org>
parents: 607
diff changeset
7 # This program is free software: you can redistribute it and/or modify
84a6e83157c2 fixed licences in docstrings (they are now in comments)
Goffi <goffi@goffi.org>
parents: 607
diff changeset
8 # it under the terms of the GNU Affero General Public License as published by
84a6e83157c2 fixed licences in docstrings (they are now in comments)
Goffi <goffi@goffi.org>
parents: 607
diff changeset
9 # the Free Software Foundation, either version 3 of the License, or
84a6e83157c2 fixed licences in docstrings (they are now in comments)
Goffi <goffi@goffi.org>
parents: 607
diff changeset
10 # (at your option) any later version.
144
80661755ea8d Primitivus: Tarot card game implementation
Goffi <goffi@goffi.org>
parents:
diff changeset
11
609
84a6e83157c2 fixed licences in docstrings (they are now in comments)
Goffi <goffi@goffi.org>
parents: 607
diff changeset
12 # This program is distributed in the hope that it will be useful,
84a6e83157c2 fixed licences in docstrings (they are now in comments)
Goffi <goffi@goffi.org>
parents: 607
diff changeset
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
84a6e83157c2 fixed licences in docstrings (they are now in comments)
Goffi <goffi@goffi.org>
parents: 607
diff changeset
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
84a6e83157c2 fixed licences in docstrings (they are now in comments)
Goffi <goffi@goffi.org>
parents: 607
diff changeset
15 # GNU Affero General Public License for more details.
144
80661755ea8d Primitivus: Tarot card game implementation
Goffi <goffi@goffi.org>
parents:
diff changeset
16
609
84a6e83157c2 fixed licences in docstrings (they are now in comments)
Goffi <goffi@goffi.org>
parents: 607
diff changeset
17 # You should have received a copy of the GNU Affero General Public License
84a6e83157c2 fixed licences in docstrings (they are now in comments)
Goffi <goffi@goffi.org>
parents: 607
diff changeset
18 # along with this program. If not, see <http://www.gnu.org/licenses/>.
144
80661755ea8d Primitivus: Tarot card game implementation
Goffi <goffi@goffi.org>
parents:
diff changeset
19
771
bfabeedbf32e core: i18n refactoring:
Goffi <goffi@goffi.org>
parents: 762
diff changeset
20 from sat.core.i18n import _
796
46aa5ada61bf core, frontends: XMLUI refactoring:
Goffi <goffi@goffi.org>
parents: 771
diff changeset
21 from sat_frontends.constants import Const
864
241f6baa6687 frontends: fix typos, do not use logging in the xmlui tools:
souliane <souliane@mailoo.org>
parents: 811
diff changeset
22 from sat.core.exceptions import DataError
144
80661755ea8d Primitivus: Tarot card game implementation
Goffi <goffi@goffi.org>
parents:
diff changeset
23
762
aed7d99276b8 core (xml_tools), frontends: added a prefix to XMLUI form names in result data, to avoid name conflicts (e.g.: if a form has name "submit", and this name is also used internally by SàT)
Goffi <goffi@goffi.org>
parents: 760
diff changeset
24
796
46aa5ada61bf core, frontends: XMLUI refactoring:
Goffi <goffi@goffi.org>
parents: 771
diff changeset
25 class InvalidXMLUI(Exception):
46aa5ada61bf core, frontends: XMLUI refactoring:
Goffi <goffi@goffi.org>
parents: 771
diff changeset
26 pass
46aa5ada61bf core, frontends: XMLUI refactoring:
Goffi <goffi@goffi.org>
parents: 771
diff changeset
27
762
aed7d99276b8 core (xml_tools), frontends: added a prefix to XMLUI form names in result data, to avoid name conflicts (e.g.: if a form has name "submit", and this name is also used internally by SàT)
Goffi <goffi@goffi.org>
parents: 760
diff changeset
28
632
06f44f797a1b primitivus: really basic implementation of advanced list.
Goffi <goffi@goffi.org>
parents: 610
diff changeset
29 def getText(node):
06f44f797a1b primitivus: really basic implementation of advanced list.
Goffi <goffi@goffi.org>
parents: 610
diff changeset
30 """Get child text nodes
06f44f797a1b primitivus: really basic implementation of advanced list.
Goffi <goffi@goffi.org>
parents: 610
diff changeset
31 @param node: dom Node
06f44f797a1b primitivus: really basic implementation of advanced list.
Goffi <goffi@goffi.org>
parents: 610
diff changeset
32 @return: joined unicode text of all nodes
06f44f797a1b primitivus: really basic implementation of advanced list.
Goffi <goffi@goffi.org>
parents: 610
diff changeset
33
06f44f797a1b primitivus: really basic implementation of advanced list.
Goffi <goffi@goffi.org>
parents: 610
diff changeset
34 """
06f44f797a1b primitivus: really basic implementation of advanced list.
Goffi <goffi@goffi.org>
parents: 610
diff changeset
35 data = []
06f44f797a1b primitivus: really basic implementation of advanced list.
Goffi <goffi@goffi.org>
parents: 610
diff changeset
36 for child in node.childNodes:
06f44f797a1b primitivus: really basic implementation of advanced list.
Goffi <goffi@goffi.org>
parents: 610
diff changeset
37 if child.nodeType == child.TEXT_NODE:
06f44f797a1b primitivus: really basic implementation of advanced list.
Goffi <goffi@goffi.org>
parents: 610
diff changeset
38 data.append(child.wholeText)
06f44f797a1b primitivus: really basic implementation of advanced list.
Goffi <goffi@goffi.org>
parents: 610
diff changeset
39 return u"".join(data)
06f44f797a1b primitivus: really basic implementation of advanced list.
Goffi <goffi@goffi.org>
parents: 610
diff changeset
40
641
49587e170f53 core: added the security_limit to setParam
souliane <souliane@mailoo.org>
parents: 632
diff changeset
41
796
46aa5ada61bf core, frontends: XMLUI refactoring:
Goffi <goffi@goffi.org>
parents: 771
diff changeset
42 class Widget(object):
46aa5ada61bf core, frontends: XMLUI refactoring:
Goffi <goffi@goffi.org>
parents: 771
diff changeset
43 """ base Widget """
46aa5ada61bf core, frontends: XMLUI refactoring:
Goffi <goffi@goffi.org>
parents: 771
diff changeset
44 pass
144
80661755ea8d Primitivus: Tarot card game implementation
Goffi <goffi@goffi.org>
parents:
diff changeset
45
80661755ea8d Primitivus: Tarot card game implementation
Goffi <goffi@goffi.org>
parents:
diff changeset
46
796
46aa5ada61bf core, frontends: XMLUI refactoring:
Goffi <goffi@goffi.org>
parents: 771
diff changeset
47 class EmptyWidget(Widget):
46aa5ada61bf core, frontends: XMLUI refactoring:
Goffi <goffi@goffi.org>
parents: 771
diff changeset
48 """ Just a placeholder widget """
46aa5ada61bf core, frontends: XMLUI refactoring:
Goffi <goffi@goffi.org>
parents: 771
diff changeset
49 pass
587
952322b1d490 Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 572
diff changeset
50
796
46aa5ada61bf core, frontends: XMLUI refactoring:
Goffi <goffi@goffi.org>
parents: 771
diff changeset
51
46aa5ada61bf core, frontends: XMLUI refactoring:
Goffi <goffi@goffi.org>
parents: 771
diff changeset
52 class TextWidget(Widget):
46aa5ada61bf core, frontends: XMLUI refactoring:
Goffi <goffi@goffi.org>
parents: 771
diff changeset
53 """ Non interactive text """
152
b1f1955d96b3 Primitivus: XMLUI: tabs layout management + CustomButton now used instead of urwid's buttons
Goffi <goffi@goffi.org>
parents: 149
diff changeset
54 pass
144
80661755ea8d Primitivus: Tarot card game implementation
Goffi <goffi@goffi.org>
parents:
diff changeset
55
796
46aa5ada61bf core, frontends: XMLUI refactoring:
Goffi <goffi@goffi.org>
parents: 771
diff changeset
56
804
5174657b3378 XMLUI (core, frontends): added JidWidget and DividerWidget + popup type + some bugfixes:
Goffi <goffi@goffi.org>
parents: 803
diff changeset
57 class LabelWidget(Widget):
5174657b3378 XMLUI (core, frontends): added JidWidget and DividerWidget + popup type + some bugfixes:
Goffi <goffi@goffi.org>
parents: 803
diff changeset
58 """ Non interactive text """
5174657b3378 XMLUI (core, frontends): added JidWidget and DividerWidget + popup type + some bugfixes:
Goffi <goffi@goffi.org>
parents: 803
diff changeset
59 pass
5174657b3378 XMLUI (core, frontends): added JidWidget and DividerWidget + popup type + some bugfixes:
Goffi <goffi@goffi.org>
parents: 803
diff changeset
60
5174657b3378 XMLUI (core, frontends): added JidWidget and DividerWidget + popup type + some bugfixes:
Goffi <goffi@goffi.org>
parents: 803
diff changeset
61
5174657b3378 XMLUI (core, frontends): added JidWidget and DividerWidget + popup type + some bugfixes:
Goffi <goffi@goffi.org>
parents: 803
diff changeset
62 class JidWidget(Widget):
5174657b3378 XMLUI (core, frontends): added JidWidget and DividerWidget + popup type + some bugfixes:
Goffi <goffi@goffi.org>
parents: 803
diff changeset
63 """ Jabber ID """
5174657b3378 XMLUI (core, frontends): added JidWidget and DividerWidget + popup type + some bugfixes:
Goffi <goffi@goffi.org>
parents: 803
diff changeset
64 pass
5174657b3378 XMLUI (core, frontends): added JidWidget and DividerWidget + popup type + some bugfixes:
Goffi <goffi@goffi.org>
parents: 803
diff changeset
65
5174657b3378 XMLUI (core, frontends): added JidWidget and DividerWidget + popup type + some bugfixes:
Goffi <goffi@goffi.org>
parents: 803
diff changeset
66
5174657b3378 XMLUI (core, frontends): added JidWidget and DividerWidget + popup type + some bugfixes:
Goffi <goffi@goffi.org>
parents: 803
diff changeset
67 class DividerWidget(Widget):
5174657b3378 XMLUI (core, frontends): added JidWidget and DividerWidget + popup type + some bugfixes:
Goffi <goffi@goffi.org>
parents: 803
diff changeset
68 """ Separator """
5174657b3378 XMLUI (core, frontends): added JidWidget and DividerWidget + popup type + some bugfixes:
Goffi <goffi@goffi.org>
parents: 803
diff changeset
69 pass
5174657b3378 XMLUI (core, frontends): added JidWidget and DividerWidget + popup type + some bugfixes:
Goffi <goffi@goffi.org>
parents: 803
diff changeset
70
5174657b3378 XMLUI (core, frontends): added JidWidget and DividerWidget + popup type + some bugfixes:
Goffi <goffi@goffi.org>
parents: 803
diff changeset
71
796
46aa5ada61bf core, frontends: XMLUI refactoring:
Goffi <goffi@goffi.org>
parents: 771
diff changeset
72 class StringWidget(Widget):
46aa5ada61bf core, frontends: XMLUI refactoring:
Goffi <goffi@goffi.org>
parents: 771
diff changeset
73 """ Input widget with require a string
46aa5ada61bf core, frontends: XMLUI refactoring:
Goffi <goffi@goffi.org>
parents: 771
diff changeset
74 often called Edit in toolkits
46aa5ada61bf core, frontends: XMLUI refactoring:
Goffi <goffi@goffi.org>
parents: 771
diff changeset
75
46aa5ada61bf core, frontends: XMLUI refactoring:
Goffi <goffi@goffi.org>
parents: 771
diff changeset
76 """
46aa5ada61bf core, frontends: XMLUI refactoring:
Goffi <goffi@goffi.org>
parents: 771
diff changeset
77
46aa5ada61bf core, frontends: XMLUI refactoring:
Goffi <goffi@goffi.org>
parents: 771
diff changeset
78
46aa5ada61bf core, frontends: XMLUI refactoring:
Goffi <goffi@goffi.org>
parents: 771
diff changeset
79 class PasswordWidget(Widget):
46aa5ada61bf core, frontends: XMLUI refactoring:
Goffi <goffi@goffi.org>
parents: 771
diff changeset
80 """ Input widget with require a masked string
46aa5ada61bf core, frontends: XMLUI refactoring:
Goffi <goffi@goffi.org>
parents: 771
diff changeset
81
46aa5ada61bf core, frontends: XMLUI refactoring:
Goffi <goffi@goffi.org>
parents: 771
diff changeset
82 """
46aa5ada61bf core, frontends: XMLUI refactoring:
Goffi <goffi@goffi.org>
parents: 771
diff changeset
83
46aa5ada61bf core, frontends: XMLUI refactoring:
Goffi <goffi@goffi.org>
parents: 771
diff changeset
84
46aa5ada61bf core, frontends: XMLUI refactoring:
Goffi <goffi@goffi.org>
parents: 771
diff changeset
85 class TextBoxWidget(Widget):
46aa5ada61bf core, frontends: XMLUI refactoring:
Goffi <goffi@goffi.org>
parents: 771
diff changeset
86 """ Input widget with require a long, possibly multilines string
46aa5ada61bf core, frontends: XMLUI refactoring:
Goffi <goffi@goffi.org>
parents: 771
diff changeset
87 often called TextArea in toolkits
46aa5ada61bf core, frontends: XMLUI refactoring:
Goffi <goffi@goffi.org>
parents: 771
diff changeset
88
46aa5ada61bf core, frontends: XMLUI refactoring:
Goffi <goffi@goffi.org>
parents: 771
diff changeset
89 """
46aa5ada61bf core, frontends: XMLUI refactoring:
Goffi <goffi@goffi.org>
parents: 771
diff changeset
90
46aa5ada61bf core, frontends: XMLUI refactoring:
Goffi <goffi@goffi.org>
parents: 771
diff changeset
91
46aa5ada61bf core, frontends: XMLUI refactoring:
Goffi <goffi@goffi.org>
parents: 771
diff changeset
92 class BoolWidget(Widget):
46aa5ada61bf core, frontends: XMLUI refactoring:
Goffi <goffi@goffi.org>
parents: 771
diff changeset
93 """ Input widget with require a boolean value
46aa5ada61bf core, frontends: XMLUI refactoring:
Goffi <goffi@goffi.org>
parents: 771
diff changeset
94 often called CheckBox in toolkits
46aa5ada61bf core, frontends: XMLUI refactoring:
Goffi <goffi@goffi.org>
parents: 771
diff changeset
95
46aa5ada61bf core, frontends: XMLUI refactoring:
Goffi <goffi@goffi.org>
parents: 771
diff changeset
96 """
46aa5ada61bf core, frontends: XMLUI refactoring:
Goffi <goffi@goffi.org>
parents: 771
diff changeset
97
46aa5ada61bf core, frontends: XMLUI refactoring:
Goffi <goffi@goffi.org>
parents: 771
diff changeset
98
46aa5ada61bf core, frontends: XMLUI refactoring:
Goffi <goffi@goffi.org>
parents: 771
diff changeset
99 class ButtonWidget(Widget):
46aa5ada61bf core, frontends: XMLUI refactoring:
Goffi <goffi@goffi.org>
parents: 771
diff changeset
100 """ A clickable widget """
46aa5ada61bf core, frontends: XMLUI refactoring:
Goffi <goffi@goffi.org>
parents: 771
diff changeset
101
46aa5ada61bf core, frontends: XMLUI refactoring:
Goffi <goffi@goffi.org>
parents: 771
diff changeset
102
46aa5ada61bf core, frontends: XMLUI refactoring:
Goffi <goffi@goffi.org>
parents: 771
diff changeset
103 class ListWidget(Widget):
46aa5ada61bf core, frontends: XMLUI refactoring:
Goffi <goffi@goffi.org>
parents: 771
diff changeset
104 """ A widget able to show/choose one or several strings in a list """
46aa5ada61bf core, frontends: XMLUI refactoring:
Goffi <goffi@goffi.org>
parents: 771
diff changeset
105
46aa5ada61bf core, frontends: XMLUI refactoring:
Goffi <goffi@goffi.org>
parents: 771
diff changeset
106
46aa5ada61bf core, frontends: XMLUI refactoring:
Goffi <goffi@goffi.org>
parents: 771
diff changeset
107 class Container(Widget):
46aa5ada61bf core, frontends: XMLUI refactoring:
Goffi <goffi@goffi.org>
parents: 771
diff changeset
108 """ Widget which can contain other ones with a specific layout """
46aa5ada61bf core, frontends: XMLUI refactoring:
Goffi <goffi@goffi.org>
parents: 771
diff changeset
109
46aa5ada61bf core, frontends: XMLUI refactoring:
Goffi <goffi@goffi.org>
parents: 771
diff changeset
110 @classmethod
46aa5ada61bf core, frontends: XMLUI refactoring:
Goffi <goffi@goffi.org>
parents: 771
diff changeset
111 def _xmluiAdapt(cls, instance):
46aa5ada61bf core, frontends: XMLUI refactoring:
Goffi <goffi@goffi.org>
parents: 771
diff changeset
112 """ Make cls as instance.__class__
46aa5ada61bf core, frontends: XMLUI refactoring:
Goffi <goffi@goffi.org>
parents: 771
diff changeset
113 cls must inherit from original instance class
46aa5ada61bf core, frontends: XMLUI refactoring:
Goffi <goffi@goffi.org>
parents: 771
diff changeset
114 Usefull when you get a class from UI toolkit
587
952322b1d490 Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 572
diff changeset
115
796
46aa5ada61bf core, frontends: XMLUI refactoring:
Goffi <goffi@goffi.org>
parents: 771
diff changeset
116 """
46aa5ada61bf core, frontends: XMLUI refactoring:
Goffi <goffi@goffi.org>
parents: 771
diff changeset
117 assert instance.__class__ in cls.__bases__
46aa5ada61bf core, frontends: XMLUI refactoring:
Goffi <goffi@goffi.org>
parents: 771
diff changeset
118 instance.__class__ = type(cls.__name__, cls.__bases__, dict(cls.__dict__))
46aa5ada61bf core, frontends: XMLUI refactoring:
Goffi <goffi@goffi.org>
parents: 771
diff changeset
119
46aa5ada61bf core, frontends: XMLUI refactoring:
Goffi <goffi@goffi.org>
parents: 771
diff changeset
120
46aa5ada61bf core, frontends: XMLUI refactoring:
Goffi <goffi@goffi.org>
parents: 771
diff changeset
121 class PairsContainer(Container):
46aa5ada61bf core, frontends: XMLUI refactoring:
Goffi <goffi@goffi.org>
parents: 771
diff changeset
122 """ Widgets are disposed in rows of two (usually label/input) """
46aa5ada61bf core, frontends: XMLUI refactoring:
Goffi <goffi@goffi.org>
parents: 771
diff changeset
123 pass
46aa5ada61bf core, frontends: XMLUI refactoring:
Goffi <goffi@goffi.org>
parents: 771
diff changeset
124
46aa5ada61bf core, frontends: XMLUI refactoring:
Goffi <goffi@goffi.org>
parents: 771
diff changeset
125
46aa5ada61bf core, frontends: XMLUI refactoring:
Goffi <goffi@goffi.org>
parents: 771
diff changeset
126 class TabsContainer(Container):
46aa5ada61bf core, frontends: XMLUI refactoring:
Goffi <goffi@goffi.org>
parents: 771
diff changeset
127 """ A container which several other containers in tabs
46aa5ada61bf core, frontends: XMLUI refactoring:
Goffi <goffi@goffi.org>
parents: 771
diff changeset
128 Often called Notebook in toolkits
46aa5ada61bf core, frontends: XMLUI refactoring:
Goffi <goffi@goffi.org>
parents: 771
diff changeset
129
46aa5ada61bf core, frontends: XMLUI refactoring:
Goffi <goffi@goffi.org>
parents: 771
diff changeset
130 """
46aa5ada61bf core, frontends: XMLUI refactoring:
Goffi <goffi@goffi.org>
parents: 771
diff changeset
131
46aa5ada61bf core, frontends: XMLUI refactoring:
Goffi <goffi@goffi.org>
parents: 771
diff changeset
132
46aa5ada61bf core, frontends: XMLUI refactoring:
Goffi <goffi@goffi.org>
parents: 771
diff changeset
133 class VerticalContainer(Container):
46aa5ada61bf core, frontends: XMLUI refactoring:
Goffi <goffi@goffi.org>
parents: 771
diff changeset
134 """ Widgets are disposed vertically """
46aa5ada61bf core, frontends: XMLUI refactoring:
Goffi <goffi@goffi.org>
parents: 771
diff changeset
135 pass
46aa5ada61bf core, frontends: XMLUI refactoring:
Goffi <goffi@goffi.org>
parents: 771
diff changeset
136
46aa5ada61bf core, frontends: XMLUI refactoring:
Goffi <goffi@goffi.org>
parents: 771
diff changeset
137
803
f100fd8d279f core, frontends: implementation of AdvancedListContainer first draft + misc:
Goffi <goffi@goffi.org>
parents: 802
diff changeset
138 class AdvancedListContainer(Container):
f100fd8d279f core, frontends: implementation of AdvancedListContainer first draft + misc:
Goffi <goffi@goffi.org>
parents: 802
diff changeset
139 """ Widgets are disposed in rows with advaned features """
f100fd8d279f core, frontends: implementation of AdvancedListContainer first draft + misc:
Goffi <goffi@goffi.org>
parents: 802
diff changeset
140 pass
f100fd8d279f core, frontends: implementation of AdvancedListContainer first draft + misc:
Goffi <goffi@goffi.org>
parents: 802
diff changeset
141
804
5174657b3378 XMLUI (core, frontends): added JidWidget and DividerWidget + popup type + some bugfixes:
Goffi <goffi@goffi.org>
parents: 803
diff changeset
142
796
46aa5ada61bf core, frontends: XMLUI refactoring:
Goffi <goffi@goffi.org>
parents: 771
diff changeset
143 class XMLUI(object):
46aa5ada61bf core, frontends: XMLUI refactoring:
Goffi <goffi@goffi.org>
parents: 771
diff changeset
144 """ Base class to construct SàT XML User Interface
46aa5ada61bf core, frontends: XMLUI refactoring:
Goffi <goffi@goffi.org>
parents: 771
diff changeset
145 New frontends can inherite this class to easily implement XMLUI
46aa5ada61bf core, frontends: XMLUI refactoring:
Goffi <goffi@goffi.org>
parents: 771
diff changeset
146 @property widget_factory: factory to create frontend-specific widgets
46aa5ada61bf core, frontends: XMLUI refactoring:
Goffi <goffi@goffi.org>
parents: 771
diff changeset
147 @proporety dialog_factory: factory to create frontend-specific dialogs
46aa5ada61bf core, frontends: XMLUI refactoring:
Goffi <goffi@goffi.org>
parents: 771
diff changeset
148
46aa5ada61bf core, frontends: XMLUI refactoring:
Goffi <goffi@goffi.org>
parents: 771
diff changeset
149 """
46aa5ada61bf core, frontends: XMLUI refactoring:
Goffi <goffi@goffi.org>
parents: 771
diff changeset
150 widget_factory = None
46aa5ada61bf core, frontends: XMLUI refactoring:
Goffi <goffi@goffi.org>
parents: 771
diff changeset
151 dialog_factory = None # TODO
46aa5ada61bf core, frontends: XMLUI refactoring:
Goffi <goffi@goffi.org>
parents: 771
diff changeset
152
46aa5ada61bf core, frontends: XMLUI refactoring:
Goffi <goffi@goffi.org>
parents: 771
diff changeset
153 def __init__(self, host, xml_data, title = None, flags = None, dom_parse=None, dom_free=None):
46aa5ada61bf core, frontends: XMLUI refactoring:
Goffi <goffi@goffi.org>
parents: 771
diff changeset
154 """ Initialise the XMLUI instance
46aa5ada61bf core, frontends: XMLUI refactoring:
Goffi <goffi@goffi.org>
parents: 771
diff changeset
155 @param host: %(doc_host)s
46aa5ada61bf core, frontends: XMLUI refactoring:
Goffi <goffi@goffi.org>
parents: 771
diff changeset
156 @param xml_data: the raw XML containing the UI
46aa5ada61bf core, frontends: XMLUI refactoring:
Goffi <goffi@goffi.org>
parents: 771
diff changeset
157 @param title: force the title, or use XMLUI one if None
46aa5ada61bf core, frontends: XMLUI refactoring:
Goffi <goffi@goffi.org>
parents: 771
diff changeset
158 @param flags: list of string which can be:
46aa5ada61bf core, frontends: XMLUI refactoring:
Goffi <goffi@goffi.org>
parents: 771
diff changeset
159 - NO_CANCEL: the UI can't be cancelled
46aa5ada61bf core, frontends: XMLUI refactoring:
Goffi <goffi@goffi.org>
parents: 771
diff changeset
160 @param dom_parse: methode equivalent to minidom.parseString (but which must manage unicode), or None to use default one
46aa5ada61bf core, frontends: XMLUI refactoring:
Goffi <goffi@goffi.org>
parents: 771
diff changeset
161 @param dom_free: method used to free the parsed DOM
46aa5ada61bf core, frontends: XMLUI refactoring:
Goffi <goffi@goffi.org>
parents: 771
diff changeset
162
46aa5ada61bf core, frontends: XMLUI refactoring:
Goffi <goffi@goffi.org>
parents: 771
diff changeset
163 """
46aa5ada61bf core, frontends: XMLUI refactoring:
Goffi <goffi@goffi.org>
parents: 771
diff changeset
164 if dom_parse is None:
46aa5ada61bf core, frontends: XMLUI refactoring:
Goffi <goffi@goffi.org>
parents: 771
diff changeset
165 from xml.dom import minidom
46aa5ada61bf core, frontends: XMLUI refactoring:
Goffi <goffi@goffi.org>
parents: 771
diff changeset
166 self.dom_parse = lambda xml_data: minidom.parseString(xml_data.encode('utf-8'))
46aa5ada61bf core, frontends: XMLUI refactoring:
Goffi <goffi@goffi.org>
parents: 771
diff changeset
167 self.dom_free = lambda cat_dom: cat_dom.unlink()
46aa5ada61bf core, frontends: XMLUI refactoring:
Goffi <goffi@goffi.org>
parents: 771
diff changeset
168 else:
46aa5ada61bf core, frontends: XMLUI refactoring:
Goffi <goffi@goffi.org>
parents: 771
diff changeset
169 self.dom_parse = dom_parse
46aa5ada61bf core, frontends: XMLUI refactoring:
Goffi <goffi@goffi.org>
parents: 771
diff changeset
170 self.dom_free = dom_free or (lambda cat_dom: None)
144
80661755ea8d Primitivus: Tarot card game implementation
Goffi <goffi@goffi.org>
parents:
diff changeset
171 self.host = host
796
46aa5ada61bf core, frontends: XMLUI refactoring:
Goffi <goffi@goffi.org>
parents: 771
diff changeset
172 self.title = title or ""
46aa5ada61bf core, frontends: XMLUI refactoring:
Goffi <goffi@goffi.org>
parents: 771
diff changeset
173 if flags is None:
46aa5ada61bf core, frontends: XMLUI refactoring:
Goffi <goffi@goffi.org>
parents: 771
diff changeset
174 flags = []
46aa5ada61bf core, frontends: XMLUI refactoring:
Goffi <goffi@goffi.org>
parents: 771
diff changeset
175 self.flags = flags
144
80661755ea8d Primitivus: Tarot card game implementation
Goffi <goffi@goffi.org>
parents:
diff changeset
176 self.ctrl_list = {} # usefull to access ctrl
802
9007bb133009 core, frontends: XMLUI refactoring:
Goffi <goffi@goffi.org>
parents: 796
diff changeset
177 self._main_cont = None
796
46aa5ada61bf core, frontends: XMLUI refactoring:
Goffi <goffi@goffi.org>
parents: 771
diff changeset
178 self.constructUI(xml_data)
144
80661755ea8d Primitivus: Tarot card game implementation
Goffi <goffi@goffi.org>
parents:
diff changeset
179
805
7c05c39156a2 core (XMLUI), frontends: advancedListContainer part 2:
Goffi <goffi@goffi.org>
parents: 804
diff changeset
180 def escape(self, name):
7c05c39156a2 core (XMLUI), frontends: advancedListContainer part 2:
Goffi <goffi@goffi.org>
parents: 804
diff changeset
181 """ return escaped name for forms """
7c05c39156a2 core (XMLUI), frontends: advancedListContainer part 2:
Goffi <goffi@goffi.org>
parents: 804
diff changeset
182 return u"%s%s" % (Const.SAT_FORM_PREFIX, name)
7c05c39156a2 core (XMLUI), frontends: advancedListContainer part 2:
Goffi <goffi@goffi.org>
parents: 804
diff changeset
183
802
9007bb133009 core, frontends: XMLUI refactoring:
Goffi <goffi@goffi.org>
parents: 796
diff changeset
184 @property
9007bb133009 core, frontends: XMLUI refactoring:
Goffi <goffi@goffi.org>
parents: 796
diff changeset
185 def main_cont(self):
9007bb133009 core, frontends: XMLUI refactoring:
Goffi <goffi@goffi.org>
parents: 796
diff changeset
186 return self._main_cont
796
46aa5ada61bf core, frontends: XMLUI refactoring:
Goffi <goffi@goffi.org>
parents: 771
diff changeset
187
802
9007bb133009 core, frontends: XMLUI refactoring:
Goffi <goffi@goffi.org>
parents: 796
diff changeset
188 @main_cont.setter
9007bb133009 core, frontends: XMLUI refactoring:
Goffi <goffi@goffi.org>
parents: 796
diff changeset
189 def main_cont(self, value):
9007bb133009 core, frontends: XMLUI refactoring:
Goffi <goffi@goffi.org>
parents: 796
diff changeset
190 if self._main_cont is not None:
9007bb133009 core, frontends: XMLUI refactoring:
Goffi <goffi@goffi.org>
parents: 796
diff changeset
191 raise ValueError(_("XMLUI can have only one main container"))
9007bb133009 core, frontends: XMLUI refactoring:
Goffi <goffi@goffi.org>
parents: 796
diff changeset
192 self._main_cont = value
796
46aa5ada61bf core, frontends: XMLUI refactoring:
Goffi <goffi@goffi.org>
parents: 771
diff changeset
193
1085
7a39ae3950f7 frontends (XMLUI): implementation of read_only attributes for widgets String, TextBox, Password and Bool
Goffi <goffi@goffi.org>
parents: 977
diff changeset
194 def _isAttrSet(self, name, node):
7a39ae3950f7 frontends (XMLUI): implementation of read_only attributes for widgets String, TextBox, Password and Bool
Goffi <goffi@goffi.org>
parents: 977
diff changeset
195 """Returnw widget boolean attribute status
7a39ae3950f7 frontends (XMLUI): implementation of read_only attributes for widgets String, TextBox, Password and Bool
Goffi <goffi@goffi.org>
parents: 977
diff changeset
196
7a39ae3950f7 frontends (XMLUI): implementation of read_only attributes for widgets String, TextBox, Password and Bool
Goffi <goffi@goffi.org>
parents: 977
diff changeset
197 @param name: name of the attribute (e.g. "read_only")
7a39ae3950f7 frontends (XMLUI): implementation of read_only attributes for widgets String, TextBox, Password and Bool
Goffi <goffi@goffi.org>
parents: 977
diff changeset
198 @param node: Node instance
7a39ae3950f7 frontends (XMLUI): implementation of read_only attributes for widgets String, TextBox, Password and Bool
Goffi <goffi@goffi.org>
parents: 977
diff changeset
199 @return (bool): True if widget's attribute is set ("true")
7a39ae3950f7 frontends (XMLUI): implementation of read_only attributes for widgets String, TextBox, Password and Bool
Goffi <goffi@goffi.org>
parents: 977
diff changeset
200 """
7a39ae3950f7 frontends (XMLUI): implementation of read_only attributes for widgets String, TextBox, Password and Bool
Goffi <goffi@goffi.org>
parents: 977
diff changeset
201 read_only = node.getAttribute(name) or "false"
7a39ae3950f7 frontends (XMLUI): implementation of read_only attributes for widgets String, TextBox, Password and Bool
Goffi <goffi@goffi.org>
parents: 977
diff changeset
202 return read_only.lower().strip() == "true"
7a39ae3950f7 frontends (XMLUI): implementation of read_only attributes for widgets String, TextBox, Password and Bool
Goffi <goffi@goffi.org>
parents: 977
diff changeset
203
802
9007bb133009 core, frontends: XMLUI refactoring:
Goffi <goffi@goffi.org>
parents: 796
diff changeset
204 def _parseChilds(self, parent, current_node, wanted = ('container',), data = None):
796
46aa5ada61bf core, frontends: XMLUI refactoring:
Goffi <goffi@goffi.org>
parents: 771
diff changeset
205 """ Recursively parse childNodes of an elemen
802
9007bb133009 core, frontends: XMLUI refactoring:
Goffi <goffi@goffi.org>
parents: 796
diff changeset
206 @param parent: widget container with '_xmluiAppend' method
9007bb133009 core, frontends: XMLUI refactoring:
Goffi <goffi@goffi.org>
parents: 796
diff changeset
207 @param current_node: element from which childs will be parsed
796
46aa5ada61bf core, frontends: XMLUI refactoring:
Goffi <goffi@goffi.org>
parents: 771
diff changeset
208 @param wanted: list of tag names that can be present in the childs to be SàT XMLUI compliant
46aa5ada61bf core, frontends: XMLUI refactoring:
Goffi <goffi@goffi.org>
parents: 771
diff changeset
209 @param data: additionnal data which are needed in some cases
46aa5ada61bf core, frontends: XMLUI refactoring:
Goffi <goffi@goffi.org>
parents: 771
diff changeset
210
46aa5ada61bf core, frontends: XMLUI refactoring:
Goffi <goffi@goffi.org>
parents: 771
diff changeset
211 """
802
9007bb133009 core, frontends: XMLUI refactoring:
Goffi <goffi@goffi.org>
parents: 796
diff changeset
212 for node in current_node.childNodes:
144
80661755ea8d Primitivus: Tarot card game implementation
Goffi <goffi@goffi.org>
parents:
diff changeset
213 if wanted and not node.nodeName in wanted:
803
f100fd8d279f core, frontends: implementation of AdvancedListContainer first draft + misc:
Goffi <goffi@goffi.org>
parents: 802
diff changeset
214 raise InvalidXMLUI('Unexpected node: [%s]' % node.nodeName)
802
9007bb133009 core, frontends: XMLUI refactoring:
Goffi <goffi@goffi.org>
parents: 796
diff changeset
215
9007bb133009 core, frontends: XMLUI refactoring:
Goffi <goffi@goffi.org>
parents: 796
diff changeset
216 if node.nodeName == "container":
796
46aa5ada61bf core, frontends: XMLUI refactoring:
Goffi <goffi@goffi.org>
parents: 771
diff changeset
217 type_ = node.getAttribute('type')
802
9007bb133009 core, frontends: XMLUI refactoring:
Goffi <goffi@goffi.org>
parents: 796
diff changeset
218 if parent is self and type_ != 'vertical':
9007bb133009 core, frontends: XMLUI refactoring:
Goffi <goffi@goffi.org>
parents: 796
diff changeset
219 # main container is not a VerticalContainer and we want one, so we create one to wrap it
9007bb133009 core, frontends: XMLUI refactoring:
Goffi <goffi@goffi.org>
parents: 796
diff changeset
220 parent = self.widget_factory.createVerticalContainer(self)
9007bb133009 core, frontends: XMLUI refactoring:
Goffi <goffi@goffi.org>
parents: 796
diff changeset
221 self.main_cont = parent
796
46aa5ada61bf core, frontends: XMLUI refactoring:
Goffi <goffi@goffi.org>
parents: 771
diff changeset
222 if type_ == "tabs":
802
9007bb133009 core, frontends: XMLUI refactoring:
Goffi <goffi@goffi.org>
parents: 796
diff changeset
223 cont = self.widget_factory.createTabsContainer(parent)
9007bb133009 core, frontends: XMLUI refactoring:
Goffi <goffi@goffi.org>
parents: 796
diff changeset
224 self._parseChilds(parent, node, ('tab',), cont)
796
46aa5ada61bf core, frontends: XMLUI refactoring:
Goffi <goffi@goffi.org>
parents: 771
diff changeset
225 elif type_ == "vertical":
802
9007bb133009 core, frontends: XMLUI refactoring:
Goffi <goffi@goffi.org>
parents: 796
diff changeset
226 cont = self.widget_factory.createVerticalContainer(parent)
9007bb133009 core, frontends: XMLUI refactoring:
Goffi <goffi@goffi.org>
parents: 796
diff changeset
227 self._parseChilds(cont, node, ('widget', 'container'))
796
46aa5ada61bf core, frontends: XMLUI refactoring:
Goffi <goffi@goffi.org>
parents: 771
diff changeset
228 elif type_ == "pairs":
802
9007bb133009 core, frontends: XMLUI refactoring:
Goffi <goffi@goffi.org>
parents: 796
diff changeset
229 cont = self.widget_factory.createPairsContainer(parent)
9007bb133009 core, frontends: XMLUI refactoring:
Goffi <goffi@goffi.org>
parents: 796
diff changeset
230 self._parseChilds(cont, node, ('widget', 'container'))
803
f100fd8d279f core, frontends: implementation of AdvancedListContainer first draft + misc:
Goffi <goffi@goffi.org>
parents: 802
diff changeset
231 elif type_ == "advanced_list":
f100fd8d279f core, frontends: implementation of AdvancedListContainer first draft + misc:
Goffi <goffi@goffi.org>
parents: 802
diff changeset
232 try:
f100fd8d279f core, frontends: implementation of AdvancedListContainer first draft + misc:
Goffi <goffi@goffi.org>
parents: 802
diff changeset
233 columns = int(node.getAttribute('columns'))
f100fd8d279f core, frontends: implementation of AdvancedListContainer first draft + misc:
Goffi <goffi@goffi.org>
parents: 802
diff changeset
234 except (TypeError, ValueError):
f100fd8d279f core, frontends: implementation of AdvancedListContainer first draft + misc:
Goffi <goffi@goffi.org>
parents: 802
diff changeset
235 raise DataError("Invalid columns")
805
7c05c39156a2 core (XMLUI), frontends: advancedListContainer part 2:
Goffi <goffi@goffi.org>
parents: 804
diff changeset
236 selectable = node.getAttribute('selectable') or 'no'
7c05c39156a2 core (XMLUI), frontends: advancedListContainer part 2:
Goffi <goffi@goffi.org>
parents: 804
diff changeset
237 auto_index = node.getAttribute('auto_index') == 'true'
7c05c39156a2 core (XMLUI), frontends: advancedListContainer part 2:
Goffi <goffi@goffi.org>
parents: 804
diff changeset
238 data = {'index': 0} if auto_index else None
7c05c39156a2 core (XMLUI), frontends: advancedListContainer part 2:
Goffi <goffi@goffi.org>
parents: 804
diff changeset
239 cont = self.widget_factory.createAdvancedListContainer(parent, columns, selectable)
7c05c39156a2 core (XMLUI), frontends: advancedListContainer part 2:
Goffi <goffi@goffi.org>
parents: 804
diff changeset
240 callback_id = node.getAttribute("callback") or None
7c05c39156a2 core (XMLUI), frontends: advancedListContainer part 2:
Goffi <goffi@goffi.org>
parents: 804
diff changeset
241 if callback_id is not None:
7c05c39156a2 core (XMLUI), frontends: advancedListContainer part 2:
Goffi <goffi@goffi.org>
parents: 804
diff changeset
242 if selectable == 'no':
7c05c39156a2 core (XMLUI), frontends: advancedListContainer part 2:
Goffi <goffi@goffi.org>
parents: 804
diff changeset
243 raise ValueError("can't have selectable=='no' and callback_id at the same time")
7c05c39156a2 core (XMLUI), frontends: advancedListContainer part 2:
Goffi <goffi@goffi.org>
parents: 804
diff changeset
244 cont._xmlui_callback_id = callback_id
7c05c39156a2 core (XMLUI), frontends: advancedListContainer part 2:
Goffi <goffi@goffi.org>
parents: 804
diff changeset
245 cont._xmluiOnSelect(self.onAdvListSelect)
7c05c39156a2 core (XMLUI), frontends: advancedListContainer part 2:
Goffi <goffi@goffi.org>
parents: 804
diff changeset
246
7c05c39156a2 core (XMLUI), frontends: advancedListContainer part 2:
Goffi <goffi@goffi.org>
parents: 804
diff changeset
247 self._parseChilds(cont, node, ('row',), data)
144
80661755ea8d Primitivus: Tarot card game implementation
Goffi <goffi@goffi.org>
parents:
diff changeset
248 else:
864
241f6baa6687 frontends: fix typos, do not use logging in the xmlui tools:
souliane <souliane@mailoo.org>
parents: 811
diff changeset
249 print(_("Unknown container [%s], using default one") % type_)
802
9007bb133009 core, frontends: XMLUI refactoring:
Goffi <goffi@goffi.org>
parents: 796
diff changeset
250 cont = self.widget_factory.createVerticalContainer(parent)
9007bb133009 core, frontends: XMLUI refactoring:
Goffi <goffi@goffi.org>
parents: 796
diff changeset
251 self._parseChilds(cont, node, ('widget', 'container'))
9007bb133009 core, frontends: XMLUI refactoring:
Goffi <goffi@goffi.org>
parents: 796
diff changeset
252 try:
9007bb133009 core, frontends: XMLUI refactoring:
Goffi <goffi@goffi.org>
parents: 796
diff changeset
253 parent._xmluiAppend(cont)
808
d035c662b357 frontends: some modifications to ease the the use of the new sat_frontends.tools.xmlui.XMLUI class in Libervia
Goffi <goffi@goffi.org>
parents: 805
diff changeset
254 except (AttributeError, TypeError): # XXX: TypeError is here because pyjamas raise a TypeError instead of an AttributeError
802
9007bb133009 core, frontends: XMLUI refactoring:
Goffi <goffi@goffi.org>
parents: 796
diff changeset
255 if parent is self:
9007bb133009 core, frontends: XMLUI refactoring:
Goffi <goffi@goffi.org>
parents: 796
diff changeset
256 self.main_cont = cont
9007bb133009 core, frontends: XMLUI refactoring:
Goffi <goffi@goffi.org>
parents: 796
diff changeset
257 else:
9007bb133009 core, frontends: XMLUI refactoring:
Goffi <goffi@goffi.org>
parents: 796
diff changeset
258 raise Exception(_("Internal Error, container has not _xmluiAppend method"))
9007bb133009 core, frontends: XMLUI refactoring:
Goffi <goffi@goffi.org>
parents: 796
diff changeset
259
803
f100fd8d279f core, frontends: implementation of AdvancedListContainer first draft + misc:
Goffi <goffi@goffi.org>
parents: 802
diff changeset
260 elif node.nodeName == 'tab':
587
952322b1d490 Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 572
diff changeset
261 name = node.getAttribute('name')
952322b1d490 Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 572
diff changeset
262 label = node.getAttribute('label')
796
46aa5ada61bf core, frontends: XMLUI refactoring:
Goffi <goffi@goffi.org>
parents: 771
diff changeset
263 if not name or not isinstance(data, TabsContainer):
587
952322b1d490 Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 572
diff changeset
264 raise InvalidXMLUI
166
b318d2b58887 Primitivus: parameters management via XMLUI
Goffi <goffi@goffi.org>
parents: 162
diff changeset
265 if self.type == 'param':
b318d2b58887 Primitivus: parameters management via XMLUI
Goffi <goffi@goffi.org>
parents: 162
diff changeset
266 self._current_category = name #XXX: awful hack because params need category and we don't keep parent
152
b1f1955d96b3 Primitivus: XMLUI: tabs layout management + CustomButton now used instead of urwid's buttons
Goffi <goffi@goffi.org>
parents: 149
diff changeset
267 tab_cont = data
796
46aa5ada61bf core, frontends: XMLUI refactoring:
Goffi <goffi@goffi.org>
parents: 771
diff changeset
268 new_tab = tab_cont._xmluiAddTab(label or name)
802
9007bb133009 core, frontends: XMLUI refactoring:
Goffi <goffi@goffi.org>
parents: 796
diff changeset
269 self._parseChilds(new_tab, node, ('widget', 'container'))
9007bb133009 core, frontends: XMLUI refactoring:
Goffi <goffi@goffi.org>
parents: 796
diff changeset
270
803
f100fd8d279f core, frontends: implementation of AdvancedListContainer first draft + misc:
Goffi <goffi@goffi.org>
parents: 802
diff changeset
271 elif node.nodeName == 'row':
805
7c05c39156a2 core (XMLUI), frontends: advancedListContainer part 2:
Goffi <goffi@goffi.org>
parents: 804
diff changeset
272 try:
7c05c39156a2 core (XMLUI), frontends: advancedListContainer part 2:
Goffi <goffi@goffi.org>
parents: 804
diff changeset
273 index = str(data['index'])
7c05c39156a2 core (XMLUI), frontends: advancedListContainer part 2:
Goffi <goffi@goffi.org>
parents: 804
diff changeset
274 data['index'] += 1
7c05c39156a2 core (XMLUI), frontends: advancedListContainer part 2:
Goffi <goffi@goffi.org>
parents: 804
diff changeset
275 except TypeError:
7c05c39156a2 core (XMLUI), frontends: advancedListContainer part 2:
Goffi <goffi@goffi.org>
parents: 804
diff changeset
276 index = node.getAttribute('index') or None
7c05c39156a2 core (XMLUI), frontends: advancedListContainer part 2:
Goffi <goffi@goffi.org>
parents: 804
diff changeset
277 parent._xmluiAddRow(index)
803
f100fd8d279f core, frontends: implementation of AdvancedListContainer first draft + misc:
Goffi <goffi@goffi.org>
parents: 802
diff changeset
278 self._parseChilds(parent, node, ('widget', 'container'))
f100fd8d279f core, frontends: implementation of AdvancedListContainer first draft + misc:
Goffi <goffi@goffi.org>
parents: 802
diff changeset
279
802
9007bb133009 core, frontends: XMLUI refactoring:
Goffi <goffi@goffi.org>
parents: 796
diff changeset
280 elif node.nodeName == "widget":
9007bb133009 core, frontends: XMLUI refactoring:
Goffi <goffi@goffi.org>
parents: 796
diff changeset
281 id_ = node.getAttribute("id")
9007bb133009 core, frontends: XMLUI refactoring:
Goffi <goffi@goffi.org>
parents: 796
diff changeset
282 name = node.getAttribute("name")
9007bb133009 core, frontends: XMLUI refactoring:
Goffi <goffi@goffi.org>
parents: 796
diff changeset
283 type_ = node.getAttribute("type")
9007bb133009 core, frontends: XMLUI refactoring:
Goffi <goffi@goffi.org>
parents: 796
diff changeset
284 value = node.getAttribute("value") if node.hasAttribute('value') else u''
9007bb133009 core, frontends: XMLUI refactoring:
Goffi <goffi@goffi.org>
parents: 796
diff changeset
285 if type_=="empty":
9007bb133009 core, frontends: XMLUI refactoring:
Goffi <goffi@goffi.org>
parents: 796
diff changeset
286 ctrl = self.widget_factory.createEmptyWidget(parent)
9007bb133009 core, frontends: XMLUI refactoring:
Goffi <goffi@goffi.org>
parents: 796
diff changeset
287 elif type_=="text":
9007bb133009 core, frontends: XMLUI refactoring:
Goffi <goffi@goffi.org>
parents: 796
diff changeset
288 try:
9007bb133009 core, frontends: XMLUI refactoring:
Goffi <goffi@goffi.org>
parents: 796
diff changeset
289 value = node.childNodes[0].wholeText
9007bb133009 core, frontends: XMLUI refactoring:
Goffi <goffi@goffi.org>
parents: 796
diff changeset
290 except IndexError:
808
d035c662b357 frontends: some modifications to ease the the use of the new sat_frontends.tools.xmlui.XMLUI class in Libervia
Goffi <goffi@goffi.org>
parents: 805
diff changeset
291 # warning (_("text node has no child !"))
d035c662b357 frontends: some modifications to ease the the use of the new sat_frontends.tools.xmlui.XMLUI class in Libervia
Goffi <goffi@goffi.org>
parents: 805
diff changeset
292 pass # FIXME proper warning (this one is not OK with Libervia)
802
9007bb133009 core, frontends: XMLUI refactoring:
Goffi <goffi@goffi.org>
parents: 796
diff changeset
293 ctrl = self.widget_factory.createTextWidget(parent, value)
9007bb133009 core, frontends: XMLUI refactoring:
Goffi <goffi@goffi.org>
parents: 796
diff changeset
294 elif type_=="label":
804
5174657b3378 XMLUI (core, frontends): added JidWidget and DividerWidget + popup type + some bugfixes:
Goffi <goffi@goffi.org>
parents: 803
diff changeset
295 ctrl = self.widget_factory.createLabelWidget(parent, value)
5174657b3378 XMLUI (core, frontends): added JidWidget and DividerWidget + popup type + some bugfixes:
Goffi <goffi@goffi.org>
parents: 803
diff changeset
296 elif type_=="jid":
5174657b3378 XMLUI (core, frontends): added JidWidget and DividerWidget + popup type + some bugfixes:
Goffi <goffi@goffi.org>
parents: 803
diff changeset
297 ctrl = self.widget_factory.createJidWidget(parent, value)
5174657b3378 XMLUI (core, frontends): added JidWidget and DividerWidget + popup type + some bugfixes:
Goffi <goffi@goffi.org>
parents: 803
diff changeset
298 elif type_=="divider":
5174657b3378 XMLUI (core, frontends): added JidWidget and DividerWidget + popup type + some bugfixes:
Goffi <goffi@goffi.org>
parents: 803
diff changeset
299 style = node.getAttribute("style") or 'line'
5174657b3378 XMLUI (core, frontends): added JidWidget and DividerWidget + popup type + some bugfixes:
Goffi <goffi@goffi.org>
parents: 803
diff changeset
300 ctrl = self.widget_factory.createDividerWidget(parent, style)
802
9007bb133009 core, frontends: XMLUI refactoring:
Goffi <goffi@goffi.org>
parents: 796
diff changeset
301 elif type_=="string":
1085
7a39ae3950f7 frontends (XMLUI): implementation of read_only attributes for widgets String, TextBox, Password and Bool
Goffi <goffi@goffi.org>
parents: 977
diff changeset
302 ctrl = self.widget_factory.createStringWidget(parent, value, self._isAttrSet("read_only", node))
802
9007bb133009 core, frontends: XMLUI refactoring:
Goffi <goffi@goffi.org>
parents: 796
diff changeset
303 self.ctrl_list[name] = ({'type':type_, 'control':ctrl})
9007bb133009 core, frontends: XMLUI refactoring:
Goffi <goffi@goffi.org>
parents: 796
diff changeset
304 elif type_=="password":
1085
7a39ae3950f7 frontends (XMLUI): implementation of read_only attributes for widgets String, TextBox, Password and Bool
Goffi <goffi@goffi.org>
parents: 977
diff changeset
305 ctrl = self.widget_factory.createPasswordWidget(parent, value, self._isAttrSet("read_only", node))
802
9007bb133009 core, frontends: XMLUI refactoring:
Goffi <goffi@goffi.org>
parents: 796
diff changeset
306 self.ctrl_list[name] = ({'type':type_, 'control':ctrl})
9007bb133009 core, frontends: XMLUI refactoring:
Goffi <goffi@goffi.org>
parents: 796
diff changeset
307 elif type_=="textbox":
1085
7a39ae3950f7 frontends (XMLUI): implementation of read_only attributes for widgets String, TextBox, Password and Bool
Goffi <goffi@goffi.org>
parents: 977
diff changeset
308 ctrl = self.widget_factory.createTextBoxWidget(parent, value, self._isAttrSet("read_only", node))
802
9007bb133009 core, frontends: XMLUI refactoring:
Goffi <goffi@goffi.org>
parents: 796
diff changeset
309 self.ctrl_list[name] = ({'type':type_, 'control':ctrl})
9007bb133009 core, frontends: XMLUI refactoring:
Goffi <goffi@goffi.org>
parents: 796
diff changeset
310 elif type_=="bool":
1085
7a39ae3950f7 frontends (XMLUI): implementation of read_only attributes for widgets String, TextBox, Password and Bool
Goffi <goffi@goffi.org>
parents: 977
diff changeset
311 ctrl = self.widget_factory.createBoolWidget(parent, value=='true', self._isAttrSet("read_only", node))
802
9007bb133009 core, frontends: XMLUI refactoring:
Goffi <goffi@goffi.org>
parents: 796
diff changeset
312 self.ctrl_list[name] = ({'type':type_, 'control':ctrl})
968
75f3b3b430ff tools, frontends, memory: param definition and XMLUI handle multi-selection for list widgets:
souliane <souliane@mailoo.org>
parents: 865
diff changeset
313 elif type_ == "list":
75f3b3b430ff tools, frontends, memory: param definition and XMLUI handle multi-selection for list widgets:
souliane <souliane@mailoo.org>
parents: 865
diff changeset
314 style = [] if node.getAttribute("multi") == 'yes' else ['single']
802
9007bb133009 core, frontends: XMLUI refactoring:
Goffi <goffi@goffi.org>
parents: 796
diff changeset
315 _options = [(option.getAttribute("value"), option.getAttribute("label")) for option in node.getElementsByTagName("option")]
968
75f3b3b430ff tools, frontends, memory: param definition and XMLUI handle multi-selection for list widgets:
souliane <souliane@mailoo.org>
parents: 865
diff changeset
316 _selected = [option.getAttribute("value") for option in node.getElementsByTagName("option") if option.getAttribute('selected') == 'true']
75f3b3b430ff tools, frontends, memory: param definition and XMLUI handle multi-selection for list widgets:
souliane <souliane@mailoo.org>
parents: 865
diff changeset
317 ctrl = self.widget_factory.createListWidget(parent, _options, _selected, style)
75f3b3b430ff tools, frontends, memory: param definition and XMLUI handle multi-selection for list widgets:
souliane <souliane@mailoo.org>
parents: 865
diff changeset
318 self.ctrl_list[name] = ({'type': type_, 'control': ctrl})
802
9007bb133009 core, frontends: XMLUI refactoring:
Goffi <goffi@goffi.org>
parents: 796
diff changeset
319 elif type_=="button":
9007bb133009 core, frontends: XMLUI refactoring:
Goffi <goffi@goffi.org>
parents: 796
diff changeset
320 callback_id = node.getAttribute("callback")
9007bb133009 core, frontends: XMLUI refactoring:
Goffi <goffi@goffi.org>
parents: 796
diff changeset
321 ctrl = self.widget_factory.createButtonWidget(parent, value, self.onButtonPress)
968
75f3b3b430ff tools, frontends, memory: param definition and XMLUI handle multi-selection for list widgets:
souliane <souliane@mailoo.org>
parents: 865
diff changeset
322 ctrl._xmlui_param_id = (callback_id, [field.getAttribute('name') for field in node.getElementsByTagName("field_back")])
802
9007bb133009 core, frontends: XMLUI refactoring:
Goffi <goffi@goffi.org>
parents: 796
diff changeset
323 else:
864
241f6baa6687 frontends: fix typos, do not use logging in the xmlui tools:
souliane <souliane@mailoo.org>
parents: 811
diff changeset
324 print(_("FIXME FIXME FIXME: widget type [%s] is not implemented") % type_)
802
9007bb133009 core, frontends: XMLUI refactoring:
Goffi <goffi@goffi.org>
parents: 796
diff changeset
325 raise NotImplementedError(_("FIXME FIXME FIXME: type [%s] is not implemented") % type_)
9007bb133009 core, frontends: XMLUI refactoring:
Goffi <goffi@goffi.org>
parents: 796
diff changeset
326
977
d2e612a45e76 tools, frontends (xmlui): add Widget.setInternalCallback:
souliane <souliane@mailoo.org>
parents: 975
diff changeset
327 if self.type == 'param' and type_ not in ('text', 'button'):
802
9007bb133009 core, frontends: XMLUI refactoring:
Goffi <goffi@goffi.org>
parents: 796
diff changeset
328 try:
9007bb133009 core, frontends: XMLUI refactoring:
Goffi <goffi@goffi.org>
parents: 796
diff changeset
329 ctrl._xmluiOnChange(self.onParamChange)
9007bb133009 core, frontends: XMLUI refactoring:
Goffi <goffi@goffi.org>
parents: 796
diff changeset
330 ctrl._param_category = self._current_category
977
d2e612a45e76 tools, frontends (xmlui): add Widget.setInternalCallback:
souliane <souliane@mailoo.org>
parents: 975
diff changeset
331 except (AttributeError, TypeError): # XXX: TypeError is here because pyjamas raise a TypeError instead of an AttributeError
808
d035c662b357 frontends: some modifications to ease the the use of the new sat_frontends.tools.xmlui.XMLUI class in Libervia
Goffi <goffi@goffi.org>
parents: 805
diff changeset
332 if not isinstance(ctrl, (EmptyWidget, TextWidget, LabelWidget, JidWidget)):
864
241f6baa6687 frontends: fix typos, do not use logging in the xmlui tools:
souliane <souliane@mailoo.org>
parents: 811
diff changeset
333 print(_("No change listener on [%s]") % ctrl)
802
9007bb133009 core, frontends: XMLUI refactoring:
Goffi <goffi@goffi.org>
parents: 796
diff changeset
334
977
d2e612a45e76 tools, frontends (xmlui): add Widget.setInternalCallback:
souliane <souliane@mailoo.org>
parents: 975
diff changeset
335 if type_ != 'text':
d2e612a45e76 tools, frontends (xmlui): add Widget.setInternalCallback:
souliane <souliane@mailoo.org>
parents: 975
diff changeset
336 callback = node.getAttribute("internal_callback") or None
d2e612a45e76 tools, frontends (xmlui): add Widget.setInternalCallback:
souliane <souliane@mailoo.org>
parents: 975
diff changeset
337 if callback:
d2e612a45e76 tools, frontends (xmlui): add Widget.setInternalCallback:
souliane <souliane@mailoo.org>
parents: 975
diff changeset
338 fields = [field.getAttribute('name') for field in node.getElementsByTagName("internal_field")]
d2e612a45e76 tools, frontends (xmlui): add Widget.setInternalCallback:
souliane <souliane@mailoo.org>
parents: 975
diff changeset
339 data = self.getInternalCallbackData(callback, node)
d2e612a45e76 tools, frontends (xmlui): add Widget.setInternalCallback:
souliane <souliane@mailoo.org>
parents: 975
diff changeset
340 ctrl._xmlui_param_internal = (callback, fields, data)
d2e612a45e76 tools, frontends (xmlui): add Widget.setInternalCallback:
souliane <souliane@mailoo.org>
parents: 975
diff changeset
341 if type_ == 'button':
d2e612a45e76 tools, frontends (xmlui): add Widget.setInternalCallback:
souliane <souliane@mailoo.org>
parents: 975
diff changeset
342 ctrl._xmluiOnClick(self.onChangeInternal)
d2e612a45e76 tools, frontends (xmlui): add Widget.setInternalCallback:
souliane <souliane@mailoo.org>
parents: 975
diff changeset
343 else:
d2e612a45e76 tools, frontends (xmlui): add Widget.setInternalCallback:
souliane <souliane@mailoo.org>
parents: 975
diff changeset
344 ctrl._xmluiOnChange(self.onChangeInternal)
d2e612a45e76 tools, frontends (xmlui): add Widget.setInternalCallback:
souliane <souliane@mailoo.org>
parents: 975
diff changeset
345
805
7c05c39156a2 core (XMLUI), frontends: advancedListContainer part 2:
Goffi <goffi@goffi.org>
parents: 804
diff changeset
346 ctrl._xmlui_name = name
802
9007bb133009 core, frontends: XMLUI refactoring:
Goffi <goffi@goffi.org>
parents: 796
diff changeset
347 parent._xmluiAppend(ctrl)
9007bb133009 core, frontends: XMLUI refactoring:
Goffi <goffi@goffi.org>
parents: 796
diff changeset
348
144
80661755ea8d Primitivus: Tarot card game implementation
Goffi <goffi@goffi.org>
parents:
diff changeset
349 else:
802
9007bb133009 core, frontends: XMLUI refactoring:
Goffi <goffi@goffi.org>
parents: 796
diff changeset
350 raise NotImplementedError(_('Unknown tag [%s]') % node.nodeName)
144
80661755ea8d Primitivus: Tarot card game implementation
Goffi <goffi@goffi.org>
parents:
diff changeset
351
796
46aa5ada61bf core, frontends: XMLUI refactoring:
Goffi <goffi@goffi.org>
parents: 771
diff changeset
352 def constructUI(self, xml_data, post_treat=None):
46aa5ada61bf core, frontends: XMLUI refactoring:
Goffi <goffi@goffi.org>
parents: 771
diff changeset
353 """ Actually construct the UI
46aa5ada61bf core, frontends: XMLUI refactoring:
Goffi <goffi@goffi.org>
parents: 771
diff changeset
354 @param xml_data: raw XMLUI
46aa5ada61bf core, frontends: XMLUI refactoring:
Goffi <goffi@goffi.org>
parents: 771
diff changeset
355 @param post_treat: frontend specific treatments to do once the UI is constructed
46aa5ada61bf core, frontends: XMLUI refactoring:
Goffi <goffi@goffi.org>
parents: 771
diff changeset
356 @return: constructed widget
46aa5ada61bf core, frontends: XMLUI refactoring:
Goffi <goffi@goffi.org>
parents: 771
diff changeset
357 """
46aa5ada61bf core, frontends: XMLUI refactoring:
Goffi <goffi@goffi.org>
parents: 771
diff changeset
358 cat_dom = self.dom_parse(xml_data)
152
b1f1955d96b3 Primitivus: XMLUI: tabs layout management + CustomButton now used instead of urwid's buttons
Goffi <goffi@goffi.org>
parents: 149
diff changeset
359 top=cat_dom.documentElement
144
80661755ea8d Primitivus: Tarot card game implementation
Goffi <goffi@goffi.org>
parents:
diff changeset
360 self.type = top.getAttribute("type")
796
46aa5ada61bf core, frontends: XMLUI refactoring:
Goffi <goffi@goffi.org>
parents: 771
diff changeset
361 self.title = self.title or top.getAttribute("title") or u""
760
73a0077f80cc backend, frontends: XMLUI refactoring:
Goffi <goffi@goffi.org>
parents: 759
diff changeset
362 self.session_id = top.getAttribute("session_id") or None
759
93bd868b8fb6 backend, frontends: callbacks refactoring:
Goffi <goffi@goffi.org>
parents: 687
diff changeset
363 self.submit_id = top.getAttribute("submit") or None
804
5174657b3378 XMLUI (core, frontends): added JidWidget and DividerWidget + popup type + some bugfixes:
Goffi <goffi@goffi.org>
parents: 803
diff changeset
364 if top.nodeName != "sat_xmlui" or not self.type in ['form', 'param', 'window', 'popup']:
152
b1f1955d96b3 Primitivus: XMLUI: tabs layout management + CustomButton now used instead of urwid's buttons
Goffi <goffi@goffi.org>
parents: 149
diff changeset
365 raise InvalidXMLUI
144
80661755ea8d Primitivus: Tarot card game implementation
Goffi <goffi@goffi.org>
parents:
diff changeset
366
166
b318d2b58887 Primitivus: parameters management via XMLUI
Goffi <goffi@goffi.org>
parents: 162
diff changeset
367 if self.type == 'param':
b318d2b58887 Primitivus: parameters management via XMLUI
Goffi <goffi@goffi.org>
parents: 162
diff changeset
368 self.param_changed = set()
b318d2b58887 Primitivus: parameters management via XMLUI
Goffi <goffi@goffi.org>
parents: 162
diff changeset
369
802
9007bb133009 core, frontends: XMLUI refactoring:
Goffi <goffi@goffi.org>
parents: 796
diff changeset
370 self._parseChilds(self, cat_dom.documentElement)
152
b1f1955d96b3 Primitivus: XMLUI: tabs layout management + CustomButton now used instead of urwid's buttons
Goffi <goffi@goffi.org>
parents: 149
diff changeset
371
796
46aa5ada61bf core, frontends: XMLUI refactoring:
Goffi <goffi@goffi.org>
parents: 771
diff changeset
372 if post_treat is not None:
802
9007bb133009 core, frontends: XMLUI refactoring:
Goffi <goffi@goffi.org>
parents: 796
diff changeset
373 post_treat()
587
952322b1d490 Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 572
diff changeset
374
796
46aa5ada61bf core, frontends: XMLUI refactoring:
Goffi <goffi@goffi.org>
parents: 771
diff changeset
375 self.dom_free(cat_dom)
46aa5ada61bf core, frontends: XMLUI refactoring:
Goffi <goffi@goffi.org>
parents: 771
diff changeset
376
46aa5ada61bf core, frontends: XMLUI refactoring:
Goffi <goffi@goffi.org>
parents: 771
diff changeset
377 def _xmluiClose(self):
46aa5ada61bf core, frontends: XMLUI refactoring:
Goffi <goffi@goffi.org>
parents: 771
diff changeset
378 """ Close the window/popup/... where the constructeur XMLUI is
46aa5ada61bf core, frontends: XMLUI refactoring:
Goffi <goffi@goffi.org>
parents: 771
diff changeset
379 this method must be overrided
144
80661755ea8d Primitivus: Tarot card game implementation
Goffi <goffi@goffi.org>
parents:
diff changeset
380
687
af0d08a84cc6 primitivus card_game: bug fix and improvement
souliane <souliane@mailoo.org>
parents: 655
diff changeset
381 """
796
46aa5ada61bf core, frontends: XMLUI refactoring:
Goffi <goffi@goffi.org>
parents: 771
diff changeset
382 raise NotImplementedError
144
80661755ea8d Primitivus: Tarot card game implementation
Goffi <goffi@goffi.org>
parents:
diff changeset
383
808
d035c662b357 frontends: some modifications to ease the the use of the new sat_frontends.tools.xmlui.XMLUI class in Libervia
Goffi <goffi@goffi.org>
parents: 805
diff changeset
384 def _xmluiLaunchAction(self, action_id, data):
d035c662b357 frontends: some modifications to ease the the use of the new sat_frontends.tools.xmlui.XMLUI class in Libervia
Goffi <goffi@goffi.org>
parents: 805
diff changeset
385 self.host.launchAction(action_id, data, profile_key = self.host.profile)
d035c662b357 frontends: some modifications to ease the the use of the new sat_frontends.tools.xmlui.XMLUI class in Libervia
Goffi <goffi@goffi.org>
parents: 805
diff changeset
386
d035c662b357 frontends: some modifications to ease the the use of the new sat_frontends.tools.xmlui.XMLUI class in Libervia
Goffi <goffi@goffi.org>
parents: 805
diff changeset
387 def _xmluiSetParam(self, name, value, category):
d035c662b357 frontends: some modifications to ease the the use of the new sat_frontends.tools.xmlui.XMLUI class in Libervia
Goffi <goffi@goffi.org>
parents: 805
diff changeset
388 self.host.bridge.setParam(name, value, category, profile_key=self.host.profile)
d035c662b357 frontends: some modifications to ease the the use of the new sat_frontends.tools.xmlui.XMLUI class in Libervia
Goffi <goffi@goffi.org>
parents: 805
diff changeset
389
144
80661755ea8d Primitivus: Tarot card game implementation
Goffi <goffi@goffi.org>
parents:
diff changeset
390 ##EVENTS##
80661755ea8d Primitivus: Tarot card game implementation
Goffi <goffi@goffi.org>
parents:
diff changeset
391
796
46aa5ada61bf core, frontends: XMLUI refactoring:
Goffi <goffi@goffi.org>
parents: 771
diff changeset
392 def onParamChange(self, ctrl):
46aa5ada61bf core, frontends: XMLUI refactoring:
Goffi <goffi@goffi.org>
parents: 771
diff changeset
393 """ Called when type is param and a widget to save is modified
46aa5ada61bf core, frontends: XMLUI refactoring:
Goffi <goffi@goffi.org>
parents: 771
diff changeset
394 @param ctrl: widget modified
46aa5ada61bf core, frontends: XMLUI refactoring:
Goffi <goffi@goffi.org>
parents: 771
diff changeset
395
46aa5ada61bf core, frontends: XMLUI refactoring:
Goffi <goffi@goffi.org>
parents: 771
diff changeset
396 """
46aa5ada61bf core, frontends: XMLUI refactoring:
Goffi <goffi@goffi.org>
parents: 771
diff changeset
397 assert(self.type == "param")
46aa5ada61bf core, frontends: XMLUI refactoring:
Goffi <goffi@goffi.org>
parents: 771
diff changeset
398 self.param_changed.add(ctrl)
46aa5ada61bf core, frontends: XMLUI refactoring:
Goffi <goffi@goffi.org>
parents: 771
diff changeset
399
805
7c05c39156a2 core (XMLUI), frontends: advancedListContainer part 2:
Goffi <goffi@goffi.org>
parents: 804
diff changeset
400 def onAdvListSelect(self, ctrl):
7c05c39156a2 core (XMLUI), frontends: advancedListContainer part 2:
Goffi <goffi@goffi.org>
parents: 804
diff changeset
401 data = {}
7c05c39156a2 core (XMLUI), frontends: advancedListContainer part 2:
Goffi <goffi@goffi.org>
parents: 804
diff changeset
402 widgets = ctrl._xmluiGetSelectedWidgets()
7c05c39156a2 core (XMLUI), frontends: advancedListContainer part 2:
Goffi <goffi@goffi.org>
parents: 804
diff changeset
403 for wid in widgets:
7c05c39156a2 core (XMLUI), frontends: advancedListContainer part 2:
Goffi <goffi@goffi.org>
parents: 804
diff changeset
404 try:
7c05c39156a2 core (XMLUI), frontends: advancedListContainer part 2:
Goffi <goffi@goffi.org>
parents: 804
diff changeset
405 name = self.escape(wid._xmlui_name)
7c05c39156a2 core (XMLUI), frontends: advancedListContainer part 2:
Goffi <goffi@goffi.org>
parents: 804
diff changeset
406 value = wid._xmluiGetValue()
864
241f6baa6687 frontends: fix typos, do not use logging in the xmlui tools:
souliane <souliane@mailoo.org>
parents: 811
diff changeset
407 data[name] = value
808
d035c662b357 frontends: some modifications to ease the the use of the new sat_frontends.tools.xmlui.XMLUI class in Libervia
Goffi <goffi@goffi.org>
parents: 805
diff changeset
408 except (AttributeError, TypeError): # XXX: TypeError is here because pyjamas raise a TypeError instead of an AttributeError
805
7c05c39156a2 core (XMLUI), frontends: advancedListContainer part 2:
Goffi <goffi@goffi.org>
parents: 804
diff changeset
409 pass
7c05c39156a2 core (XMLUI), frontends: advancedListContainer part 2:
Goffi <goffi@goffi.org>
parents: 804
diff changeset
410 idx = ctrl._xmluiGetSelectedIndex()
7c05c39156a2 core (XMLUI), frontends: advancedListContainer part 2:
Goffi <goffi@goffi.org>
parents: 804
diff changeset
411 if idx is not None:
7c05c39156a2 core (XMLUI), frontends: advancedListContainer part 2:
Goffi <goffi@goffi.org>
parents: 804
diff changeset
412 data['index'] = idx
7c05c39156a2 core (XMLUI), frontends: advancedListContainer part 2:
Goffi <goffi@goffi.org>
parents: 804
diff changeset
413 callback_id = ctrl._xmlui_callback_id
7c05c39156a2 core (XMLUI), frontends: advancedListContainer part 2:
Goffi <goffi@goffi.org>
parents: 804
diff changeset
414 if callback_id is None:
864
241f6baa6687 frontends: fix typos, do not use logging in the xmlui tools:
souliane <souliane@mailoo.org>
parents: 811
diff changeset
415 print(_("No callback_id found"))
805
7c05c39156a2 core (XMLUI), frontends: advancedListContainer part 2:
Goffi <goffi@goffi.org>
parents: 804
diff changeset
416 return
808
d035c662b357 frontends: some modifications to ease the the use of the new sat_frontends.tools.xmlui.XMLUI class in Libervia
Goffi <goffi@goffi.org>
parents: 805
diff changeset
417 self._xmluiLaunchAction(callback_id, data)
805
7c05c39156a2 core (XMLUI), frontends: advancedListContainer part 2:
Goffi <goffi@goffi.org>
parents: 804
diff changeset
418
144
80661755ea8d Primitivus: Tarot card game implementation
Goffi <goffi@goffi.org>
parents:
diff changeset
419 def onButtonPress(self, button):
796
46aa5ada61bf core, frontends: XMLUI refactoring:
Goffi <goffi@goffi.org>
parents: 771
diff changeset
420 """ Called when an XMLUI button is clicked
46aa5ada61bf core, frontends: XMLUI refactoring:
Goffi <goffi@goffi.org>
parents: 771
diff changeset
421 Launch the action associated to the button
46aa5ada61bf core, frontends: XMLUI refactoring:
Goffi <goffi@goffi.org>
parents: 771
diff changeset
422 @param button: the button clicked
46aa5ada61bf core, frontends: XMLUI refactoring:
Goffi <goffi@goffi.org>
parents: 771
diff changeset
423
46aa5ada61bf core, frontends: XMLUI refactoring:
Goffi <goffi@goffi.org>
parents: 771
diff changeset
424 """
46aa5ada61bf core, frontends: XMLUI refactoring:
Goffi <goffi@goffi.org>
parents: 771
diff changeset
425 callback_id, fields = button._xmlui_param_id
977
d2e612a45e76 tools, frontends (xmlui): add Widget.setInternalCallback:
souliane <souliane@mailoo.org>
parents: 975
diff changeset
426 if not callback_id: # the button is probably bound to an internal action
d2e612a45e76 tools, frontends (xmlui): add Widget.setInternalCallback:
souliane <souliane@mailoo.org>
parents: 975
diff changeset
427 return
759
93bd868b8fb6 backend, frontends: callbacks refactoring:
Goffi <goffi@goffi.org>
parents: 687
diff changeset
428 data = {}
157
13888bdb72b6 primitivus: button are now working with XMLUI
Goffi <goffi@goffi.org>
parents: 152
diff changeset
429 for field in fields:
805
7c05c39156a2 core (XMLUI), frontends: advancedListContainer part 2:
Goffi <goffi@goffi.org>
parents: 804
diff changeset
430 escaped = self.escape(field)
157
13888bdb72b6 primitivus: button are now working with XMLUI
Goffi <goffi@goffi.org>
parents: 152
diff changeset
431 ctrl = self.ctrl_list[field]
796
46aa5ada61bf core, frontends: XMLUI refactoring:
Goffi <goffi@goffi.org>
parents: 771
diff changeset
432 if isinstance(ctrl['control'], ListWidget):
968
75f3b3b430ff tools, frontends, memory: param definition and XMLUI handle multi-selection for list widgets:
souliane <souliane@mailoo.org>
parents: 865
diff changeset
433 data[escaped] = u'\t'.join(ctrl['control']._xmluiGetSelectedValues())
157
13888bdb72b6 primitivus: button are now working with XMLUI
Goffi <goffi@goffi.org>
parents: 152
diff changeset
434 else:
805
7c05c39156a2 core (XMLUI), frontends: advancedListContainer part 2:
Goffi <goffi@goffi.org>
parents: 804
diff changeset
435 data[escaped] = ctrl['control']._xmluiGetValue()
808
d035c662b357 frontends: some modifications to ease the the use of the new sat_frontends.tools.xmlui.XMLUI class in Libervia
Goffi <goffi@goffi.org>
parents: 805
diff changeset
436 self._xmluiLaunchAction(callback_id, data)
144
80661755ea8d Primitivus: Tarot card game implementation
Goffi <goffi@goffi.org>
parents:
diff changeset
437
977
d2e612a45e76 tools, frontends (xmlui): add Widget.setInternalCallback:
souliane <souliane@mailoo.org>
parents: 975
diff changeset
438 def onChangeInternal(self, ctrl):
d2e612a45e76 tools, frontends (xmlui): add Widget.setInternalCallback:
souliane <souliane@mailoo.org>
parents: 975
diff changeset
439 """ Called when a widget that has been bound to an internal callback is changed.
d2e612a45e76 tools, frontends (xmlui): add Widget.setInternalCallback:
souliane <souliane@mailoo.org>
parents: 975
diff changeset
440
d2e612a45e76 tools, frontends (xmlui): add Widget.setInternalCallback:
souliane <souliane@mailoo.org>
parents: 975
diff changeset
441 This is used to perform some UI actions without communicating with the backend.
d2e612a45e76 tools, frontends (xmlui): add Widget.setInternalCallback:
souliane <souliane@mailoo.org>
parents: 975
diff changeset
442 See sat.tools.xml_tools.Widget.setInternalCallback for more details.
d2e612a45e76 tools, frontends (xmlui): add Widget.setInternalCallback:
souliane <souliane@mailoo.org>
parents: 975
diff changeset
443 @param ctrl: widget modified
d2e612a45e76 tools, frontends (xmlui): add Widget.setInternalCallback:
souliane <souliane@mailoo.org>
parents: 975
diff changeset
444 """
d2e612a45e76 tools, frontends (xmlui): add Widget.setInternalCallback:
souliane <souliane@mailoo.org>
parents: 975
diff changeset
445 action, fields, data = ctrl._xmlui_param_internal
d2e612a45e76 tools, frontends (xmlui): add Widget.setInternalCallback:
souliane <souliane@mailoo.org>
parents: 975
diff changeset
446 if action not in ('copy', 'move', 'groups_of_contact'):
d2e612a45e76 tools, frontends (xmlui): add Widget.setInternalCallback:
souliane <souliane@mailoo.org>
parents: 975
diff changeset
447 raise NotImplementedError(_("FIXME: XMLUI internal action [%s] is not implemented") % action)
d2e612a45e76 tools, frontends (xmlui): add Widget.setInternalCallback:
souliane <souliane@mailoo.org>
parents: 975
diff changeset
448
d2e612a45e76 tools, frontends (xmlui): add Widget.setInternalCallback:
souliane <souliane@mailoo.org>
parents: 975
diff changeset
449 def copy_move(source, target):
d2e612a45e76 tools, frontends (xmlui): add Widget.setInternalCallback:
souliane <souliane@mailoo.org>
parents: 975
diff changeset
450 """Depending of 'action' value, copy or move from source to target."""
d2e612a45e76 tools, frontends (xmlui): add Widget.setInternalCallback:
souliane <souliane@mailoo.org>
parents: 975
diff changeset
451 if isinstance(target, ListWidget):
d2e612a45e76 tools, frontends (xmlui): add Widget.setInternalCallback:
souliane <souliane@mailoo.org>
parents: 975
diff changeset
452 if isinstance(source, ListWidget):
d2e612a45e76 tools, frontends (xmlui): add Widget.setInternalCallback:
souliane <souliane@mailoo.org>
parents: 975
diff changeset
453 values = source._xmluiGetSelectedValues()
d2e612a45e76 tools, frontends (xmlui): add Widget.setInternalCallback:
souliane <souliane@mailoo.org>
parents: 975
diff changeset
454 else:
d2e612a45e76 tools, frontends (xmlui): add Widget.setInternalCallback:
souliane <souliane@mailoo.org>
parents: 975
diff changeset
455 values = [source._xmluiGetValue()]
d2e612a45e76 tools, frontends (xmlui): add Widget.setInternalCallback:
souliane <souliane@mailoo.org>
parents: 975
diff changeset
456 if action == 'move':
d2e612a45e76 tools, frontends (xmlui): add Widget.setInternalCallback:
souliane <souliane@mailoo.org>
parents: 975
diff changeset
457 source._xmluiSetValue('')
d2e612a45e76 tools, frontends (xmlui): add Widget.setInternalCallback:
souliane <souliane@mailoo.org>
parents: 975
diff changeset
458 values = [value for value in values if value]
d2e612a45e76 tools, frontends (xmlui): add Widget.setInternalCallback:
souliane <souliane@mailoo.org>
parents: 975
diff changeset
459 if values:
d2e612a45e76 tools, frontends (xmlui): add Widget.setInternalCallback:
souliane <souliane@mailoo.org>
parents: 975
diff changeset
460 target._xmluiAddValues(values, select=True)
d2e612a45e76 tools, frontends (xmlui): add Widget.setInternalCallback:
souliane <souliane@mailoo.org>
parents: 975
diff changeset
461 else:
d2e612a45e76 tools, frontends (xmlui): add Widget.setInternalCallback:
souliane <souliane@mailoo.org>
parents: 975
diff changeset
462 if isinstance(source, ListWidget):
d2e612a45e76 tools, frontends (xmlui): add Widget.setInternalCallback:
souliane <souliane@mailoo.org>
parents: 975
diff changeset
463 value = u', '.join(source._xmluiGetSelectedValues())
d2e612a45e76 tools, frontends (xmlui): add Widget.setInternalCallback:
souliane <souliane@mailoo.org>
parents: 975
diff changeset
464 else:
d2e612a45e76 tools, frontends (xmlui): add Widget.setInternalCallback:
souliane <souliane@mailoo.org>
parents: 975
diff changeset
465 value = source._xmluiGetValue()
d2e612a45e76 tools, frontends (xmlui): add Widget.setInternalCallback:
souliane <souliane@mailoo.org>
parents: 975
diff changeset
466 if action == 'move':
d2e612a45e76 tools, frontends (xmlui): add Widget.setInternalCallback:
souliane <souliane@mailoo.org>
parents: 975
diff changeset
467 source._xmluiSetValue('')
d2e612a45e76 tools, frontends (xmlui): add Widget.setInternalCallback:
souliane <souliane@mailoo.org>
parents: 975
diff changeset
468 target._xmluiSetValue(value)
d2e612a45e76 tools, frontends (xmlui): add Widget.setInternalCallback:
souliane <souliane@mailoo.org>
parents: 975
diff changeset
469
d2e612a45e76 tools, frontends (xmlui): add Widget.setInternalCallback:
souliane <souliane@mailoo.org>
parents: 975
diff changeset
470 def groups_of_contact(source, target):
d2e612a45e76 tools, frontends (xmlui): add Widget.setInternalCallback:
souliane <souliane@mailoo.org>
parents: 975
diff changeset
471 """Select in target the groups of the contact which is selected in source."""
d2e612a45e76 tools, frontends (xmlui): add Widget.setInternalCallback:
souliane <souliane@mailoo.org>
parents: 975
diff changeset
472 assert(isinstance(source, ListWidget))
d2e612a45e76 tools, frontends (xmlui): add Widget.setInternalCallback:
souliane <souliane@mailoo.org>
parents: 975
diff changeset
473 assert(isinstance(target, ListWidget))
d2e612a45e76 tools, frontends (xmlui): add Widget.setInternalCallback:
souliane <souliane@mailoo.org>
parents: 975
diff changeset
474 try:
d2e612a45e76 tools, frontends (xmlui): add Widget.setInternalCallback:
souliane <souliane@mailoo.org>
parents: 975
diff changeset
475 contact_jid_s = source._xmluiGetSelectedValues()[0]
d2e612a45e76 tools, frontends (xmlui): add Widget.setInternalCallback:
souliane <souliane@mailoo.org>
parents: 975
diff changeset
476 except IndexError:
d2e612a45e76 tools, frontends (xmlui): add Widget.setInternalCallback:
souliane <souliane@mailoo.org>
parents: 975
diff changeset
477 return
d2e612a45e76 tools, frontends (xmlui): add Widget.setInternalCallback:
souliane <souliane@mailoo.org>
parents: 975
diff changeset
478 target._xmluiSelectValues(data[contact_jid_s])
d2e612a45e76 tools, frontends (xmlui): add Widget.setInternalCallback:
souliane <souliane@mailoo.org>
parents: 975
diff changeset
479 pass
d2e612a45e76 tools, frontends (xmlui): add Widget.setInternalCallback:
souliane <souliane@mailoo.org>
parents: 975
diff changeset
480
d2e612a45e76 tools, frontends (xmlui): add Widget.setInternalCallback:
souliane <souliane@mailoo.org>
parents: 975
diff changeset
481 source = None
d2e612a45e76 tools, frontends (xmlui): add Widget.setInternalCallback:
souliane <souliane@mailoo.org>
parents: 975
diff changeset
482 for field in fields:
d2e612a45e76 tools, frontends (xmlui): add Widget.setInternalCallback:
souliane <souliane@mailoo.org>
parents: 975
diff changeset
483 widget = self.ctrl_list[field]['control']
d2e612a45e76 tools, frontends (xmlui): add Widget.setInternalCallback:
souliane <souliane@mailoo.org>
parents: 975
diff changeset
484 if not source:
d2e612a45e76 tools, frontends (xmlui): add Widget.setInternalCallback:
souliane <souliane@mailoo.org>
parents: 975
diff changeset
485 source = widget
d2e612a45e76 tools, frontends (xmlui): add Widget.setInternalCallback:
souliane <souliane@mailoo.org>
parents: 975
diff changeset
486 continue
d2e612a45e76 tools, frontends (xmlui): add Widget.setInternalCallback:
souliane <souliane@mailoo.org>
parents: 975
diff changeset
487 if action in ('copy', 'move'):
d2e612a45e76 tools, frontends (xmlui): add Widget.setInternalCallback:
souliane <souliane@mailoo.org>
parents: 975
diff changeset
488 copy_move(source, widget)
d2e612a45e76 tools, frontends (xmlui): add Widget.setInternalCallback:
souliane <souliane@mailoo.org>
parents: 975
diff changeset
489 elif action == 'groups_of_contact':
d2e612a45e76 tools, frontends (xmlui): add Widget.setInternalCallback:
souliane <souliane@mailoo.org>
parents: 975
diff changeset
490 groups_of_contact(source, widget)
d2e612a45e76 tools, frontends (xmlui): add Widget.setInternalCallback:
souliane <souliane@mailoo.org>
parents: 975
diff changeset
491 source = None
d2e612a45e76 tools, frontends (xmlui): add Widget.setInternalCallback:
souliane <souliane@mailoo.org>
parents: 975
diff changeset
492
d2e612a45e76 tools, frontends (xmlui): add Widget.setInternalCallback:
souliane <souliane@mailoo.org>
parents: 975
diff changeset
493 def getInternalCallbackData(self, action, node):
d2e612a45e76 tools, frontends (xmlui): add Widget.setInternalCallback:
souliane <souliane@mailoo.org>
parents: 975
diff changeset
494 """Retrieve from node the data needed to perform given action.
d2e612a45e76 tools, frontends (xmlui): add Widget.setInternalCallback:
souliane <souliane@mailoo.org>
parents: 975
diff changeset
495
d2e612a45e76 tools, frontends (xmlui): add Widget.setInternalCallback:
souliane <souliane@mailoo.org>
parents: 975
diff changeset
496 TODO: it would be better to not have a specific way to retrieve
d2e612a45e76 tools, frontends (xmlui): add Widget.setInternalCallback:
souliane <souliane@mailoo.org>
parents: 975
diff changeset
497 data for each action, but instead to have a generic method to
d2e612a45e76 tools, frontends (xmlui): add Widget.setInternalCallback:
souliane <souliane@mailoo.org>
parents: 975
diff changeset
498 extract any kind of data structure from the 'internal_data' element.
d2e612a45e76 tools, frontends (xmlui): add Widget.setInternalCallback:
souliane <souliane@mailoo.org>
parents: 975
diff changeset
499
d2e612a45e76 tools, frontends (xmlui): add Widget.setInternalCallback:
souliane <souliane@mailoo.org>
parents: 975
diff changeset
500 @param action (string): a value from the one that can be passed to the
d2e612a45e76 tools, frontends (xmlui): add Widget.setInternalCallback:
souliane <souliane@mailoo.org>
parents: 975
diff changeset
501 'callback' parameter of sat.tools.xml_tools.Widget.setInternalCallback
d2e612a45e76 tools, frontends (xmlui): add Widget.setInternalCallback:
souliane <souliane@mailoo.org>
parents: 975
diff changeset
502 @param node (DOM Element): the node of the widget that triggers the callback
d2e612a45e76 tools, frontends (xmlui): add Widget.setInternalCallback:
souliane <souliane@mailoo.org>
parents: 975
diff changeset
503 """
d2e612a45e76 tools, frontends (xmlui): add Widget.setInternalCallback:
souliane <souliane@mailoo.org>
parents: 975
diff changeset
504 try: # data is stored in the first 'internal_data' element of the node
d2e612a45e76 tools, frontends (xmlui): add Widget.setInternalCallback:
souliane <souliane@mailoo.org>
parents: 975
diff changeset
505 data_elts = node.getElementsByTagName('internal_data')[0].childNodes
d2e612a45e76 tools, frontends (xmlui): add Widget.setInternalCallback:
souliane <souliane@mailoo.org>
parents: 975
diff changeset
506 except IndexError:
d2e612a45e76 tools, frontends (xmlui): add Widget.setInternalCallback:
souliane <souliane@mailoo.org>
parents: 975
diff changeset
507 return None
d2e612a45e76 tools, frontends (xmlui): add Widget.setInternalCallback:
souliane <souliane@mailoo.org>
parents: 975
diff changeset
508 data = {}
d2e612a45e76 tools, frontends (xmlui): add Widget.setInternalCallback:
souliane <souliane@mailoo.org>
parents: 975
diff changeset
509 if action == 'groups_of_contact': # return a dict(key: string, value: list[string])
d2e612a45e76 tools, frontends (xmlui): add Widget.setInternalCallback:
souliane <souliane@mailoo.org>
parents: 975
diff changeset
510 for elt in data_elts:
d2e612a45e76 tools, frontends (xmlui): add Widget.setInternalCallback:
souliane <souliane@mailoo.org>
parents: 975
diff changeset
511 jid_s = elt.getAttribute('name')
d2e612a45e76 tools, frontends (xmlui): add Widget.setInternalCallback:
souliane <souliane@mailoo.org>
parents: 975
diff changeset
512 data[jid_s] = []
d2e612a45e76 tools, frontends (xmlui): add Widget.setInternalCallback:
souliane <souliane@mailoo.org>
parents: 975
diff changeset
513 for value_elt in elt.childNodes:
d2e612a45e76 tools, frontends (xmlui): add Widget.setInternalCallback:
souliane <souliane@mailoo.org>
parents: 975
diff changeset
514 data[jid_s].append(value_elt.getAttribute('name'))
d2e612a45e76 tools, frontends (xmlui): add Widget.setInternalCallback:
souliane <souliane@mailoo.org>
parents: 975
diff changeset
515 return data
d2e612a45e76 tools, frontends (xmlui): add Widget.setInternalCallback:
souliane <souliane@mailoo.org>
parents: 975
diff changeset
516
796
46aa5ada61bf core, frontends: XMLUI refactoring:
Goffi <goffi@goffi.org>
parents: 771
diff changeset
517 def onFormSubmitted(self, ignore=None):
46aa5ada61bf core, frontends: XMLUI refactoring:
Goffi <goffi@goffi.org>
parents: 771
diff changeset
518 """ An XMLUI form has been submited
46aa5ada61bf core, frontends: XMLUI refactoring:
Goffi <goffi@goffi.org>
parents: 771
diff changeset
519 call the submit action associated with this form
166
b318d2b58887 Primitivus: parameters management via XMLUI
Goffi <goffi@goffi.org>
parents: 162
diff changeset
520
796
46aa5ada61bf core, frontends: XMLUI refactoring:
Goffi <goffi@goffi.org>
parents: 771
diff changeset
521 """
760
73a0077f80cc backend, frontends: XMLUI refactoring:
Goffi <goffi@goffi.org>
parents: 759
diff changeset
522 selected_values = []
144
80661755ea8d Primitivus: Tarot card game implementation
Goffi <goffi@goffi.org>
parents:
diff changeset
523 for ctrl_name in self.ctrl_list:
805
7c05c39156a2 core (XMLUI), frontends: advancedListContainer part 2:
Goffi <goffi@goffi.org>
parents: 804
diff changeset
524 escaped = self.escape(ctrl_name)
144
80661755ea8d Primitivus: Tarot card game implementation
Goffi <goffi@goffi.org>
parents:
diff changeset
525 ctrl = self.ctrl_list[ctrl_name]
796
46aa5ada61bf core, frontends: XMLUI refactoring:
Goffi <goffi@goffi.org>
parents: 771
diff changeset
526 if isinstance(ctrl['control'], ListWidget):
46aa5ada61bf core, frontends: XMLUI refactoring:
Goffi <goffi@goffi.org>
parents: 771
diff changeset
527 selected_values.append((escaped, u'\t'.join(ctrl['control']._xmluiGetSelectedValues())))
144
80661755ea8d Primitivus: Tarot card game implementation
Goffi <goffi@goffi.org>
parents:
diff changeset
528 else:
796
46aa5ada61bf core, frontends: XMLUI refactoring:
Goffi <goffi@goffi.org>
parents: 771
diff changeset
529 selected_values.append((escaped, ctrl['control']._xmluiGetValue()))
46aa5ada61bf core, frontends: XMLUI refactoring:
Goffi <goffi@goffi.org>
parents: 771
diff changeset
530 if self.submit_id is not None:
760
73a0077f80cc backend, frontends: XMLUI refactoring:
Goffi <goffi@goffi.org>
parents: 759
diff changeset
531 data = dict(selected_values)
73a0077f80cc backend, frontends: XMLUI refactoring:
Goffi <goffi@goffi.org>
parents: 759
diff changeset
532 if self.session_id is not None:
73a0077f80cc backend, frontends: XMLUI refactoring:
Goffi <goffi@goffi.org>
parents: 759
diff changeset
533 data["session_id"] = self.session_id
808
d035c662b357 frontends: some modifications to ease the the use of the new sat_frontends.tools.xmlui.XMLUI class in Libervia
Goffi <goffi@goffi.org>
parents: 805
diff changeset
534 self._xmluiLaunchAction(self.submit_id, data)
632
06f44f797a1b primitivus: really basic implementation of advanced list.
Goffi <goffi@goffi.org>
parents: 610
diff changeset
535
144
80661755ea8d Primitivus: Tarot card game implementation
Goffi <goffi@goffi.org>
parents:
diff changeset
536 else:
864
241f6baa6687 frontends: fix typos, do not use logging in the xmlui tools:
souliane <souliane@mailoo.org>
parents: 811
diff changeset
537 print(_("The form data is not sent back, the type is not managed properly"))
796
46aa5ada61bf core, frontends: XMLUI refactoring:
Goffi <goffi@goffi.org>
parents: 771
diff changeset
538 self._xmluiClose()
587
952322b1d490 Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 572
diff changeset
539
796
46aa5ada61bf core, frontends: XMLUI refactoring:
Goffi <goffi@goffi.org>
parents: 771
diff changeset
540 def onFormCancelled(self, ignore=None):
46aa5ada61bf core, frontends: XMLUI refactoring:
Goffi <goffi@goffi.org>
parents: 771
diff changeset
541 """ Called when a form is cancelled """
864
241f6baa6687 frontends: fix typos, do not use logging in the xmlui tools:
souliane <souliane@mailoo.org>
parents: 811
diff changeset
542 print(_("Cancelling form"))
796
46aa5ada61bf core, frontends: XMLUI refactoring:
Goffi <goffi@goffi.org>
parents: 771
diff changeset
543 self._xmluiClose()
46aa5ada61bf core, frontends: XMLUI refactoring:
Goffi <goffi@goffi.org>
parents: 771
diff changeset
544
46aa5ada61bf core, frontends: XMLUI refactoring:
Goffi <goffi@goffi.org>
parents: 771
diff changeset
545 def onSaveParams(self, ignore=None):
46aa5ada61bf core, frontends: XMLUI refactoring:
Goffi <goffi@goffi.org>
parents: 771
diff changeset
546 """ Params are saved, we send them to backend
46aa5ada61bf core, frontends: XMLUI refactoring:
Goffi <goffi@goffi.org>
parents: 771
diff changeset
547 self.type must be param
46aa5ada61bf core, frontends: XMLUI refactoring:
Goffi <goffi@goffi.org>
parents: 771
diff changeset
548
46aa5ada61bf core, frontends: XMLUI refactoring:
Goffi <goffi@goffi.org>
parents: 771
diff changeset
549 """
46aa5ada61bf core, frontends: XMLUI refactoring:
Goffi <goffi@goffi.org>
parents: 771
diff changeset
550 assert(self.type == 'param')
166
b318d2b58887 Primitivus: parameters management via XMLUI
Goffi <goffi@goffi.org>
parents: 162
diff changeset
551 for ctrl in self.param_changed:
796
46aa5ada61bf core, frontends: XMLUI refactoring:
Goffi <goffi@goffi.org>
parents: 771
diff changeset
552 if isinstance(ctrl, ListWidget):
46aa5ada61bf core, frontends: XMLUI refactoring:
Goffi <goffi@goffi.org>
parents: 771
diff changeset
553 value = u'\t'.join(ctrl._xmluiGetSelectedValues())
183
9ee4a1d0d7fb Added auto(dis)connect params + misc
Goffi <goffi@goffi.org>
parents: 170
diff changeset
554 else:
796
46aa5ada61bf core, frontends: XMLUI refactoring:
Goffi <goffi@goffi.org>
parents: 771
diff changeset
555 value = ctrl._xmluiGetValue()
808
d035c662b357 frontends: some modifications to ease the the use of the new sat_frontends.tools.xmlui.XMLUI class in Libervia
Goffi <goffi@goffi.org>
parents: 805
diff changeset
556 param_name = ctrl._xmlui_name.split(Const.SAT_PARAM_SEPARATOR)[1]
d035c662b357 frontends: some modifications to ease the the use of the new sat_frontends.tools.xmlui.XMLUI class in Libervia
Goffi <goffi@goffi.org>
parents: 805
diff changeset
557 self._xmluiSetParam(param_name, value, ctrl._param_category)
d035c662b357 frontends: some modifications to ease the the use of the new sat_frontends.tools.xmlui.XMLUI class in Libervia
Goffi <goffi@goffi.org>
parents: 805
diff changeset
558
796
46aa5ada61bf core, frontends: XMLUI refactoring:
Goffi <goffi@goffi.org>
parents: 771
diff changeset
559 self._xmluiClose()