Mercurial > libervia-desktop-kivy
annotate cagou/core/xmlui.py @ 241:661b9cf7b4e4
xmlui: scroll/size fixes:
- VerticalContainer and TabsPanelContainer are now put in ScrollView
- the height hack in TabsContainer has been removed has it is not needed anymore (minimum_height is now available)
- remove the empty widget which was added at the end of main panel, it's better to have the UI taking the whole container height
- fixed height for TextWidget,LabelWidget and JidWidget
- better scrollbar for VerticalContainer and TabsPanelContainer
author | Goffi <goffi@goffi.org> |
---|---|
date | Thu, 03 Jan 2019 10:42:43 +0100 |
parents | ca86954b3788 |
children | 50f7c000b4ae |
rev | line source |
---|---|
0 | 1 #!/usr/bin/python |
2 # -*- coding: utf-8 -*- | |
3 | |
4 # Cagou: a SàT frontend | |
126 | 5 # Copyright (C) 2016-2018 Jérôme Poisson (goffi@goffi.org) |
0 | 6 |
7 # This program is free software: you can redistribute it and/or modify | |
8 # it under the terms of the GNU Affero General Public License as published by | |
9 # the Free Software Foundation, either version 3 of the License, or | |
10 # (at your option) any later version. | |
11 | |
12 # This program is distributed in the hope that it will be useful, | |
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
15 # GNU Affero General Public License for more details. | |
16 | |
17 # You should have received a copy of the GNU Affero General Public License | |
18 # along with this program. If not, see <http://www.gnu.org/licenses/>. | |
19 | |
20 from sat.core.i18n import _ | |
55 | 21 from .constants import Const as C |
0 | 22 from sat.core.log import getLogger |
23 log = getLogger(__name__) | |
24 from sat_frontends.tools import xmlui | |
241 | 25 from kivy.uix.scrollview import ScrollView |
99 | 26 from kivy.uix.boxlayout import BoxLayout |
53
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
27 from kivy.uix.gridlayout import GridLayout |
69
a9c6b089070d
xmlui: improvments to prepare parameters:
Goffi <goffi@goffi.org>
parents:
55
diff
changeset
|
28 from kivy.uix.tabbedpanel import TabbedPanel, TabbedPanelItem |
0 | 29 from kivy.uix.textinput import TextInput |
30 from kivy.uix.label import Label | |
31 from kivy.uix.button import Button | |
53
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
32 from kivy.uix.togglebutton import ToggleButton |
0 | 33 from kivy.uix.widget import Widget |
53
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
34 from kivy.uix.dropdown import DropDown |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
35 from kivy.uix.switch import Switch |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
36 from kivy import properties |
29 | 37 from cagou import G |
204
37638765c97b
xmlui: implemented ConfirmDialog using new dialog.ConfirmDialog
Goffi <goffi@goffi.org>
parents:
159
diff
changeset
|
38 from cagou.core import dialog |
235
525527a01439
xmlui: use create with partial and class_map, following change in base class
Goffi <goffi@goffi.org>
parents:
227
diff
changeset
|
39 from functools import partial |
29 | 40 |
41 | |
42 ## Widgets ## | |
0 | 43 |
44 | |
69
a9c6b089070d
xmlui: improvments to prepare parameters:
Goffi <goffi@goffi.org>
parents:
55
diff
changeset
|
45 class TextInputOnChange(object): |
a9c6b089070d
xmlui: improvments to prepare parameters:
Goffi <goffi@goffi.org>
parents:
55
diff
changeset
|
46 |
a9c6b089070d
xmlui: improvments to prepare parameters:
Goffi <goffi@goffi.org>
parents:
55
diff
changeset
|
47 def __init__(self): |
a9c6b089070d
xmlui: improvments to prepare parameters:
Goffi <goffi@goffi.org>
parents:
55
diff
changeset
|
48 self._xmlui_onchange_cb = None |
a9c6b089070d
xmlui: improvments to prepare parameters:
Goffi <goffi@goffi.org>
parents:
55
diff
changeset
|
49 self._got_focus = False |
a9c6b089070d
xmlui: improvments to prepare parameters:
Goffi <goffi@goffi.org>
parents:
55
diff
changeset
|
50 |
a9c6b089070d
xmlui: improvments to prepare parameters:
Goffi <goffi@goffi.org>
parents:
55
diff
changeset
|
51 def _xmluiOnChange(self, callback): |
a9c6b089070d
xmlui: improvments to prepare parameters:
Goffi <goffi@goffi.org>
parents:
55
diff
changeset
|
52 self._xmlui_onchange_cb = callback |
a9c6b089070d
xmlui: improvments to prepare parameters:
Goffi <goffi@goffi.org>
parents:
55
diff
changeset
|
53 |
a9c6b089070d
xmlui: improvments to prepare parameters:
Goffi <goffi@goffi.org>
parents:
55
diff
changeset
|
54 def on_focus(self, instance, focus): |
a9c6b089070d
xmlui: improvments to prepare parameters:
Goffi <goffi@goffi.org>
parents:
55
diff
changeset
|
55 # we need to wait for first focus, else initial value |
a9c6b089070d
xmlui: improvments to prepare parameters:
Goffi <goffi@goffi.org>
parents:
55
diff
changeset
|
56 # will trigger a on_text |
a9c6b089070d
xmlui: improvments to prepare parameters:
Goffi <goffi@goffi.org>
parents:
55
diff
changeset
|
57 if not self._got_focus and focus: |
a9c6b089070d
xmlui: improvments to prepare parameters:
Goffi <goffi@goffi.org>
parents:
55
diff
changeset
|
58 self._got_focus = True |
a9c6b089070d
xmlui: improvments to prepare parameters:
Goffi <goffi@goffi.org>
parents:
55
diff
changeset
|
59 |
a9c6b089070d
xmlui: improvments to prepare parameters:
Goffi <goffi@goffi.org>
parents:
55
diff
changeset
|
60 def on_text(self, instance, new_text): |
a9c6b089070d
xmlui: improvments to prepare parameters:
Goffi <goffi@goffi.org>
parents:
55
diff
changeset
|
61 if self._xmlui_onchange_cb is not None and self._got_focus: |
a9c6b089070d
xmlui: improvments to prepare parameters:
Goffi <goffi@goffi.org>
parents:
55
diff
changeset
|
62 self._xmlui_onchange_cb(self) |
a9c6b089070d
xmlui: improvments to prepare parameters:
Goffi <goffi@goffi.org>
parents:
55
diff
changeset
|
63 |
a9c6b089070d
xmlui: improvments to prepare parameters:
Goffi <goffi@goffi.org>
parents:
55
diff
changeset
|
64 |
53
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
65 class EmptyWidget(xmlui.EmptyWidget, Widget): |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
66 |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
67 def __init__(self, _xmlui_parent): |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
68 Widget.__init__(self) |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
69 |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
70 |
0 | 71 class TextWidget(xmlui.TextWidget, Label): |
72 | |
73 def __init__(self, xmlui_parent, value): | |
74 Label.__init__(self, text=value) | |
75 | |
76 | |
53
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
77 class LabelWidget(xmlui.LabelWidget, TextWidget): |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
78 pass |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
79 |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
80 |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
81 class JidWidget(xmlui.JidWidget, TextWidget): |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
82 pass |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
83 |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
84 |
69
a9c6b089070d
xmlui: improvments to prepare parameters:
Goffi <goffi@goffi.org>
parents:
55
diff
changeset
|
85 class StringWidget(xmlui.StringWidget, TextInput, TextInputOnChange): |
53
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
86 |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
87 def __init__(self, xmlui_parent, value, read_only=False): |
236
ca86954b3788
xmlui: implemented TextBoxWidget + set height for XMLUIPanel
Goffi <goffi@goffi.org>
parents:
235
diff
changeset
|
88 TextInput.__init__(self, text=value) |
69
a9c6b089070d
xmlui: improvments to prepare parameters:
Goffi <goffi@goffi.org>
parents:
55
diff
changeset
|
89 TextInputOnChange.__init__(self) |
53
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
90 self.readonly = read_only |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
91 |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
92 def _xmluiSetValue(self, value): |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
93 self.text = value |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
94 |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
95 def _xmluiGetValue(self): |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
96 return self.text |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
97 |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
98 |
236
ca86954b3788
xmlui: implemented TextBoxWidget + set height for XMLUIPanel
Goffi <goffi@goffi.org>
parents:
235
diff
changeset
|
99 class TextBoxWidget(xmlui.TextBoxWidget, StringWidget): |
ca86954b3788
xmlui: implemented TextBoxWidget + set height for XMLUIPanel
Goffi <goffi@goffi.org>
parents:
235
diff
changeset
|
100 pass |
ca86954b3788
xmlui: implemented TextBoxWidget + set height for XMLUIPanel
Goffi <goffi@goffi.org>
parents:
235
diff
changeset
|
101 |
ca86954b3788
xmlui: implemented TextBoxWidget + set height for XMLUIPanel
Goffi <goffi@goffi.org>
parents:
235
diff
changeset
|
102 |
53
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
103 class JidInputWidget(xmlui.JidInputWidget, StringWidget): |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
104 pass |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
105 |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
106 |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
107 class ButtonWidget(xmlui.ButtonWidget, Button): |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
108 |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
109 def __init__(self, _xmlui_parent, value, click_callback): |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
110 Button.__init__(self) |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
111 self.text = value |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
112 self.callback = click_callback |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
113 |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
114 def _xmluiOnClick(self, callback): |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
115 self.callback = callback |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
116 |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
117 def on_release(self): |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
118 self.callback(self) |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
119 |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
120 |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
121 class DividerWidget(xmlui.DividerWidget, Widget): |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
122 # FIXME: not working properly + only 'line' is handled |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
123 style = properties.OptionProperty('line', |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
124 options=['line', 'dot', 'dash', 'plain', 'blank']) |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
125 |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
126 def __init__(self, _xmlui_parent, style="line"): |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
127 Widget.__init__(self, style=style) |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
128 |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
129 |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
130 class ListWidgetItem(ToggleButton): |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
131 value = properties.StringProperty() |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
132 |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
133 def on_release(self): |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
134 super(ListWidgetItem, self).on_release() |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
135 parent = self.parent |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
136 while parent is not None and not isinstance(parent, DropDown): |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
137 parent = parent.parent |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
138 |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
139 if parent is not None and parent.attach_to is not None: |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
140 parent.select(self) |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
141 |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
142 @property |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
143 def selected(self): |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
144 return self.state == 'down' |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
145 |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
146 @selected.setter |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
147 def selected(self, value): |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
148 self.state = 'down' if value else 'normal' |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
149 |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
150 |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
151 class ListWidget(xmlui.ListWidget, Button): |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
152 |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
153 def __init__(self, _xmlui_parent, options, selected, flags): |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
154 Button.__init__(self) |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
155 self.text = _(u"open list") |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
156 self._dropdown = DropDown() |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
157 self._dropdown.auto_dismiss = False |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
158 self._dropdown.bind(on_select = self.on_select) |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
159 self.multi = 'single' not in flags |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
160 self._dropdown.dismiss_on_select = not self.multi |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
161 self._values = [] |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
162 for option in options: |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
163 self.addValue(option) |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
164 self._xmluiSelectValues(selected) |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
165 self._on_change = None |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
166 |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
167 @property |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
168 def items(self): |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
169 return self._dropdown.children[0].children |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
170 |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
171 def on_touch_down(self, touch): |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
172 # we simulate auto-dismiss ourself because dropdown |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
173 # will dismiss even if attached button is touched |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
174 # resulting in a dismiss just before a toggle in on_release |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
175 # so the dropbox would always be opened, we don't want that! |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
176 if super(ListWidget, self).on_touch_down(touch): |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
177 return True |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
178 if self._dropdown.parent: |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
179 self._dropdown.dismiss() |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
180 |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
181 def on_release(self): |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
182 if self._dropdown.parent is not None: |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
183 # we want to close a list already opened |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
184 self._dropdown.dismiss() |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
185 else: |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
186 self._dropdown.open(self) |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
187 |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
188 def on_select(self, drop_down, item): |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
189 if not self.multi: |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
190 self._xmluiSelectValues([item.value]) |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
191 if self._on_change is not None: |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
192 self._on_change(self) |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
193 |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
194 def addValue(self, option, selected=False): |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
195 """add a value in the list |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
196 |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
197 @param option(tuple): value, label in a tuple |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
198 """ |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
199 self._values.append(option) |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
200 item = ListWidgetItem() |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
201 item.value, item.text = option |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
202 item.selected = selected |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
203 self._dropdown.add_widget(item) |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
204 |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
205 def _xmluiSelectValue(self, value): |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
206 self._xmluiSelectValues([value]) |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
207 |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
208 def _xmluiSelectValues(self, values): |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
209 for item in self.items: |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
210 item.selected = item.value in values |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
211 if item.selected and not self.multi: |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
212 self.text = item.text |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
213 |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
214 def _xmluiGetSelectedValues(self): |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
215 return [item.value for item in self.items if item.selected] |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
216 |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
217 def _xmluiAddValues(self, values, select=True): |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
218 values = set(values).difference([c.value for c in self.items]) |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
219 for v in values: |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
220 self.addValue(v, select) |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
221 |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
222 def _xmluiOnChange(self, callback): |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
223 self._on_change = callback |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
224 |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
225 |
69
a9c6b089070d
xmlui: improvments to prepare parameters:
Goffi <goffi@goffi.org>
parents:
55
diff
changeset
|
226 class JidsListWidget(ListWidget): |
a9c6b089070d
xmlui: improvments to prepare parameters:
Goffi <goffi@goffi.org>
parents:
55
diff
changeset
|
227 # TODO: real list dedicated to jids |
a9c6b089070d
xmlui: improvments to prepare parameters:
Goffi <goffi@goffi.org>
parents:
55
diff
changeset
|
228 |
a9c6b089070d
xmlui: improvments to prepare parameters:
Goffi <goffi@goffi.org>
parents:
55
diff
changeset
|
229 def __init__(self, _xmlui_parent, jids, flags): |
a9c6b089070d
xmlui: improvments to prepare parameters:
Goffi <goffi@goffi.org>
parents:
55
diff
changeset
|
230 ListWidget.__init__(self, _xmlui_parent, [(j,j) for j in jids], [], flags) |
a9c6b089070d
xmlui: improvments to prepare parameters:
Goffi <goffi@goffi.org>
parents:
55
diff
changeset
|
231 |
a9c6b089070d
xmlui: improvments to prepare parameters:
Goffi <goffi@goffi.org>
parents:
55
diff
changeset
|
232 |
a9c6b089070d
xmlui: improvments to prepare parameters:
Goffi <goffi@goffi.org>
parents:
55
diff
changeset
|
233 class PasswordWidget(xmlui.PasswordWidget, TextInput, TextInputOnChange): |
0 | 234 |
235 def __init__(self, _xmlui_parent, value, read_only=False): | |
236 TextInput.__init__(self, password=True, multiline=False, | |
237 text=value, readonly=read_only, size=(100,25), size_hint=(1,None)) | |
69
a9c6b089070d
xmlui: improvments to prepare parameters:
Goffi <goffi@goffi.org>
parents:
55
diff
changeset
|
238 TextInputOnChange.__init__(self) |
0 | 239 |
240 def _xmluiSetValue(self, value): | |
241 self.text = value | |
242 | |
243 def _xmluiGetValue(self): | |
244 return self.text | |
245 | |
246 | |
53
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
247 class BoolWidget(xmlui.BoolWidget, Switch): |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
248 |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
249 def __init__(self, _xmlui_parent, state, read_only=False): |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
250 Switch.__init__(self, active=state) |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
251 if read_only: |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
252 self.disabled = True |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
253 |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
254 def _xmluiSetValue(self, value): |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
255 self.active = value |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
256 |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
257 def _xmluiGetValue(self): |
76
a766c278b640
xmlui: fixed BoolWidget _xmluiGetValue:
Goffi <goffi@goffi.org>
parents:
71
diff
changeset
|
258 return C.BOOL_TRUE if self.active else C.BOOL_FALSE |
53
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
259 |
69
a9c6b089070d
xmlui: improvments to prepare parameters:
Goffi <goffi@goffi.org>
parents:
55
diff
changeset
|
260 def _xmluiOnChange(self, callback): |
a9c6b089070d
xmlui: improvments to prepare parameters:
Goffi <goffi@goffi.org>
parents:
55
diff
changeset
|
261 self.bind(active=lambda instance, value: callback(instance)) |
a9c6b089070d
xmlui: improvments to prepare parameters:
Goffi <goffi@goffi.org>
parents:
55
diff
changeset
|
262 |
a9c6b089070d
xmlui: improvments to prepare parameters:
Goffi <goffi@goffi.org>
parents:
55
diff
changeset
|
263 |
a9c6b089070d
xmlui: improvments to prepare parameters:
Goffi <goffi@goffi.org>
parents:
55
diff
changeset
|
264 class IntWidget(xmlui.IntWidget, TextInput, TextInputOnChange): |
a9c6b089070d
xmlui: improvments to prepare parameters:
Goffi <goffi@goffi.org>
parents:
55
diff
changeset
|
265 |
a9c6b089070d
xmlui: improvments to prepare parameters:
Goffi <goffi@goffi.org>
parents:
55
diff
changeset
|
266 def __init__(self, _xmlui_parent, value, read_only=False): |
a9c6b089070d
xmlui: improvments to prepare parameters:
Goffi <goffi@goffi.org>
parents:
55
diff
changeset
|
267 TextInput.__init__(self, text=value, input_filter='int', multiline=False) |
a9c6b089070d
xmlui: improvments to prepare parameters:
Goffi <goffi@goffi.org>
parents:
55
diff
changeset
|
268 TextInputOnChange.__init__(self) |
a9c6b089070d
xmlui: improvments to prepare parameters:
Goffi <goffi@goffi.org>
parents:
55
diff
changeset
|
269 if read_only: |
a9c6b089070d
xmlui: improvments to prepare parameters:
Goffi <goffi@goffi.org>
parents:
55
diff
changeset
|
270 self.disabled = True |
a9c6b089070d
xmlui: improvments to prepare parameters:
Goffi <goffi@goffi.org>
parents:
55
diff
changeset
|
271 |
a9c6b089070d
xmlui: improvments to prepare parameters:
Goffi <goffi@goffi.org>
parents:
55
diff
changeset
|
272 def _xmluiSetValue(self, value): |
a9c6b089070d
xmlui: improvments to prepare parameters:
Goffi <goffi@goffi.org>
parents:
55
diff
changeset
|
273 self.text = value |
a9c6b089070d
xmlui: improvments to prepare parameters:
Goffi <goffi@goffi.org>
parents:
55
diff
changeset
|
274 |
a9c6b089070d
xmlui: improvments to prepare parameters:
Goffi <goffi@goffi.org>
parents:
55
diff
changeset
|
275 def _xmluiGetValue(self): |
a9c6b089070d
xmlui: improvments to prepare parameters:
Goffi <goffi@goffi.org>
parents:
55
diff
changeset
|
276 return self.text |
a9c6b089070d
xmlui: improvments to prepare parameters:
Goffi <goffi@goffi.org>
parents:
55
diff
changeset
|
277 |
53
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
278 |
29 | 279 ## Containers ## |
280 | |
281 | |
241 | 282 class VerticalContainer(xmlui.VerticalContainer, ScrollView): |
283 layout = properties.ObjectProperty(None) | |
0 | 284 |
285 def __init__(self, xmlui_parent): | |
69
a9c6b089070d
xmlui: improvments to prepare parameters:
Goffi <goffi@goffi.org>
parents:
55
diff
changeset
|
286 self.xmlui_parent = xmlui_parent |
241 | 287 ScrollView.__init__(self) |
53
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
288 |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
289 def _xmluiAppend(self, widget): |
241 | 290 self.layout.add_widget(widget) |
53
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
291 |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
292 |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
293 class PairsContainer(xmlui.PairsContainer, GridLayout): |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
294 |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
295 def __init__(self, xmlui_parent): |
69
a9c6b089070d
xmlui: improvments to prepare parameters:
Goffi <goffi@goffi.org>
parents:
55
diff
changeset
|
296 self.xmlui_parent = xmlui_parent |
53
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
297 GridLayout.__init__(self) |
0 | 298 |
299 def _xmluiAppend(self, widget): | |
300 self.add_widget(widget) | |
301 | |
302 | |
125
b6e6afb0dc46
xmlui: added LabelContainer and updated XMLUIPanel following changes in main class
Goffi <goffi@goffi.org>
parents:
99
diff
changeset
|
303 class LabelContainer(PairsContainer, xmlui.LabelContainer): |
b6e6afb0dc46
xmlui: added LabelContainer and updated XMLUIPanel following changes in main class
Goffi <goffi@goffi.org>
parents:
99
diff
changeset
|
304 pass |
b6e6afb0dc46
xmlui: added LabelContainer and updated XMLUIPanel following changes in main class
Goffi <goffi@goffi.org>
parents:
99
diff
changeset
|
305 |
b6e6afb0dc46
xmlui: added LabelContainer and updated XMLUIPanel following changes in main class
Goffi <goffi@goffi.org>
parents:
99
diff
changeset
|
306 |
69
a9c6b089070d
xmlui: improvments to prepare parameters:
Goffi <goffi@goffi.org>
parents:
55
diff
changeset
|
307 class TabsPanelContainer(TabbedPanelItem): |
241 | 308 layout = properties.ObjectProperty(None) |
69
a9c6b089070d
xmlui: improvments to prepare parameters:
Goffi <goffi@goffi.org>
parents:
55
diff
changeset
|
309 |
a9c6b089070d
xmlui: improvments to prepare parameters:
Goffi <goffi@goffi.org>
parents:
55
diff
changeset
|
310 def _xmluiAppend(self, widget): |
241 | 311 self.layout.add_widget(widget) |
69
a9c6b089070d
xmlui: improvments to prepare parameters:
Goffi <goffi@goffi.org>
parents:
55
diff
changeset
|
312 |
a9c6b089070d
xmlui: improvments to prepare parameters:
Goffi <goffi@goffi.org>
parents:
55
diff
changeset
|
313 |
a9c6b089070d
xmlui: improvments to prepare parameters:
Goffi <goffi@goffi.org>
parents:
55
diff
changeset
|
314 class TabsContainer(xmlui.TabsContainer, TabbedPanel): |
a9c6b089070d
xmlui: improvments to prepare parameters:
Goffi <goffi@goffi.org>
parents:
55
diff
changeset
|
315 |
a9c6b089070d
xmlui: improvments to prepare parameters:
Goffi <goffi@goffi.org>
parents:
55
diff
changeset
|
316 def __init__(self, xmlui_parent): |
a9c6b089070d
xmlui: improvments to prepare parameters:
Goffi <goffi@goffi.org>
parents:
55
diff
changeset
|
317 self.xmlui_parent = xmlui_parent |
a9c6b089070d
xmlui: improvments to prepare parameters:
Goffi <goffi@goffi.org>
parents:
55
diff
changeset
|
318 TabbedPanel.__init__(self, do_default_tab=False) |
a9c6b089070d
xmlui: improvments to prepare parameters:
Goffi <goffi@goffi.org>
parents:
55
diff
changeset
|
319 |
a9c6b089070d
xmlui: improvments to prepare parameters:
Goffi <goffi@goffi.org>
parents:
55
diff
changeset
|
320 def _xmluiAddTab(self, label, selected): |
a9c6b089070d
xmlui: improvments to prepare parameters:
Goffi <goffi@goffi.org>
parents:
55
diff
changeset
|
321 tab = TabsPanelContainer(text=label) |
a9c6b089070d
xmlui: improvments to prepare parameters:
Goffi <goffi@goffi.org>
parents:
55
diff
changeset
|
322 self.add_widget(tab) |
a9c6b089070d
xmlui: improvments to prepare parameters:
Goffi <goffi@goffi.org>
parents:
55
diff
changeset
|
323 return tab |
a9c6b089070d
xmlui: improvments to prepare parameters:
Goffi <goffi@goffi.org>
parents:
55
diff
changeset
|
324 |
a9c6b089070d
xmlui: improvments to prepare parameters:
Goffi <goffi@goffi.org>
parents:
55
diff
changeset
|
325 |
53
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
326 class AdvancedListRow(GridLayout): |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
327 global_index = 0 |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
328 index = properties.ObjectProperty() |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
329 selected = properties.BooleanProperty(False) |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
330 |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
331 def __init__(self, **kwargs): |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
332 self.global_index = AdvancedListRow.global_index |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
333 AdvancedListRow.global_index += 1 |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
334 super(AdvancedListRow, self).__init__(**kwargs) |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
335 |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
336 def on_touch_down(self, touch): |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
337 if self.collide_point(*touch.pos): |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
338 parent = self.parent |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
339 while parent is not None and not isinstance(parent, AdvancedListContainer): |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
340 parent = parent.parent |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
341 if parent is None: |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
342 log.error(u"Can't find parent AdvancedListContainer") |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
343 else: |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
344 if parent.selectable: |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
345 self.selected = parent._xmluiToggleSelected(self) |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
346 |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
347 return super(AdvancedListRow, self).on_touch_down(touch) |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
348 |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
349 |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
350 class AdvancedListContainer(xmlui.AdvancedListContainer, GridLayout): |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
351 |
69
a9c6b089070d
xmlui: improvments to prepare parameters:
Goffi <goffi@goffi.org>
parents:
55
diff
changeset
|
352 def __init__(self, xmlui_parent, columns, selectable='no'): |
a9c6b089070d
xmlui: improvments to prepare parameters:
Goffi <goffi@goffi.org>
parents:
55
diff
changeset
|
353 self.xmlui_parent = xmlui_parent |
53
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
354 GridLayout.__init__(self) |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
355 self._columns = columns |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
356 self.selectable = selectable != 'no' |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
357 self._current_row = None |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
358 self._selected = [] |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
359 self._xmlui_select_cb = None |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
360 |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
361 def _xmluiToggleSelected(self, row): |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
362 """inverse selection status of an AdvancedListRow |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
363 |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
364 @param row(AdvancedListRow): row to (un)select |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
365 @return (bool): True if row is selected |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
366 """ |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
367 try: |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
368 self._selected.remove(row) |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
369 except ValueError: |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
370 self._selected.append(row) |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
371 if self._xmlui_select_cb is not None: |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
372 self._xmlui_select_cb(self) |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
373 return True |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
374 else: |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
375 return False |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
376 |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
377 def _xmluiAppend(self, widget): |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
378 if self._current_row is None: |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
379 log.error(u"No row set, ignoring append") |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
380 return |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
381 self._current_row.add_widget(widget) |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
382 |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
383 def _xmluiAddRow(self, idx): |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
384 self._current_row = AdvancedListRow() |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
385 self._current_row.cols = self._columns |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
386 self._current_row.index = idx |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
387 self.add_widget(self._current_row) |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
388 |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
389 def _xmluiGetSelectedWidgets(self): |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
390 return self._selected |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
391 |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
392 def _xmluiGetSelectedIndex(self): |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
393 if not self._selected: |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
394 return None |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
395 return self._selected[0].index |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
396 |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
397 def _xmluiOnSelect(self, callback): |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
398 """ Call callback with widget as only argument """ |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
399 self._xmlui_select_cb = callback |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
400 |
29 | 401 ## Dialogs ## |
402 | |
403 | |
404 class NoteDialog(xmlui.NoteDialog): | |
405 | |
406 def __init__(self, _xmlui_parent, title, message, level): | |
407 xmlui.NoteDialog.__init__(self, _xmlui_parent) | |
408 self.title, self.message, self.level = title, message, level | |
409 | |
410 def _xmluiShow(self): | |
411 G.host.addNote(self.title, self.message, self.level) | |
412 | |
413 | |
204
37638765c97b
xmlui: implemented ConfirmDialog using new dialog.ConfirmDialog
Goffi <goffi@goffi.org>
parents:
159
diff
changeset
|
414 class ConfirmDialog(xmlui.ConfirmDialog, dialog.ConfirmDialog): |
37638765c97b
xmlui: implemented ConfirmDialog using new dialog.ConfirmDialog
Goffi <goffi@goffi.org>
parents:
159
diff
changeset
|
415 |
37638765c97b
xmlui: implemented ConfirmDialog using new dialog.ConfirmDialog
Goffi <goffi@goffi.org>
parents:
159
diff
changeset
|
416 def __init__(self, _xmlui_parent, title, message, level, buttons_set): |
37638765c97b
xmlui: implemented ConfirmDialog using new dialog.ConfirmDialog
Goffi <goffi@goffi.org>
parents:
159
diff
changeset
|
417 dialog.ConfirmDialog.__init__(self, |
37638765c97b
xmlui: implemented ConfirmDialog using new dialog.ConfirmDialog
Goffi <goffi@goffi.org>
parents:
159
diff
changeset
|
418 title=title, |
37638765c97b
xmlui: implemented ConfirmDialog using new dialog.ConfirmDialog
Goffi <goffi@goffi.org>
parents:
159
diff
changeset
|
419 message=message, |
37638765c97b
xmlui: implemented ConfirmDialog using new dialog.ConfirmDialog
Goffi <goffi@goffi.org>
parents:
159
diff
changeset
|
420 no_cb = self.no_cb, |
37638765c97b
xmlui: implemented ConfirmDialog using new dialog.ConfirmDialog
Goffi <goffi@goffi.org>
parents:
159
diff
changeset
|
421 yes_cb = self.yes_cb) |
37638765c97b
xmlui: implemented ConfirmDialog using new dialog.ConfirmDialog
Goffi <goffi@goffi.org>
parents:
159
diff
changeset
|
422 xmlui.ConfirmDialog.__init__(self, _xmlui_parent) |
37638765c97b
xmlui: implemented ConfirmDialog using new dialog.ConfirmDialog
Goffi <goffi@goffi.org>
parents:
159
diff
changeset
|
423 |
37638765c97b
xmlui: implemented ConfirmDialog using new dialog.ConfirmDialog
Goffi <goffi@goffi.org>
parents:
159
diff
changeset
|
424 def no_cb(self): |
37638765c97b
xmlui: implemented ConfirmDialog using new dialog.ConfirmDialog
Goffi <goffi@goffi.org>
parents:
159
diff
changeset
|
425 G.host.closeUI() |
37638765c97b
xmlui: implemented ConfirmDialog using new dialog.ConfirmDialog
Goffi <goffi@goffi.org>
parents:
159
diff
changeset
|
426 self._xmluiCancelled() |
37638765c97b
xmlui: implemented ConfirmDialog using new dialog.ConfirmDialog
Goffi <goffi@goffi.org>
parents:
159
diff
changeset
|
427 |
37638765c97b
xmlui: implemented ConfirmDialog using new dialog.ConfirmDialog
Goffi <goffi@goffi.org>
parents:
159
diff
changeset
|
428 def yes_cb(self): |
37638765c97b
xmlui: implemented ConfirmDialog using new dialog.ConfirmDialog
Goffi <goffi@goffi.org>
parents:
159
diff
changeset
|
429 G.host.closeUI() |
37638765c97b
xmlui: implemented ConfirmDialog using new dialog.ConfirmDialog
Goffi <goffi@goffi.org>
parents:
159
diff
changeset
|
430 self._xmluiValidated() |
37638765c97b
xmlui: implemented ConfirmDialog using new dialog.ConfirmDialog
Goffi <goffi@goffi.org>
parents:
159
diff
changeset
|
431 |
37638765c97b
xmlui: implemented ConfirmDialog using new dialog.ConfirmDialog
Goffi <goffi@goffi.org>
parents:
159
diff
changeset
|
432 def _xmluiShow(self): |
37638765c97b
xmlui: implemented ConfirmDialog using new dialog.ConfirmDialog
Goffi <goffi@goffi.org>
parents:
159
diff
changeset
|
433 G.host.addNotifUI(self) |
37638765c97b
xmlui: implemented ConfirmDialog using new dialog.ConfirmDialog
Goffi <goffi@goffi.org>
parents:
159
diff
changeset
|
434 |
37638765c97b
xmlui: implemented ConfirmDialog using new dialog.ConfirmDialog
Goffi <goffi@goffi.org>
parents:
159
diff
changeset
|
435 def _xmluiClose(self): |
37638765c97b
xmlui: implemented ConfirmDialog using new dialog.ConfirmDialog
Goffi <goffi@goffi.org>
parents:
159
diff
changeset
|
436 G.host.closeUI() |
37638765c97b
xmlui: implemented ConfirmDialog using new dialog.ConfirmDialog
Goffi <goffi@goffi.org>
parents:
159
diff
changeset
|
437 |
37638765c97b
xmlui: implemented ConfirmDialog using new dialog.ConfirmDialog
Goffi <goffi@goffi.org>
parents:
159
diff
changeset
|
438 def show(self, *args, **kwargs): |
37638765c97b
xmlui: implemented ConfirmDialog using new dialog.ConfirmDialog
Goffi <goffi@goffi.org>
parents:
159
diff
changeset
|
439 assert kwargs["force"] |
37638765c97b
xmlui: implemented ConfirmDialog using new dialog.ConfirmDialog
Goffi <goffi@goffi.org>
parents:
159
diff
changeset
|
440 G.host.showUI(self) |
37638765c97b
xmlui: implemented ConfirmDialog using new dialog.ConfirmDialog
Goffi <goffi@goffi.org>
parents:
159
diff
changeset
|
441 |
37638765c97b
xmlui: implemented ConfirmDialog using new dialog.ConfirmDialog
Goffi <goffi@goffi.org>
parents:
159
diff
changeset
|
442 |
99 | 443 class FileDialog(xmlui.FileDialog, BoxLayout): |
444 message = properties.ObjectProperty() | |
445 | |
446 def __init__(self, _xmlui_parent, title, message, level, filetype): | |
447 xmlui.FileDialog.__init__(self, _xmlui_parent) | |
448 BoxLayout.__init__(self) | |
449 self.message.text = message | |
450 if filetype == C.XMLUI_DATA_FILETYPE_DIR: | |
451 self.file_chooser.dirselect = True | |
452 | |
453 def _xmluiShow(self): | |
454 G.host.addNotifUI(self) | |
455 | |
456 def _xmluiClose(self): | |
457 # FIXME: notif UI is not removed if dialog is not shown yet | |
458 G.host.closeUI() | |
459 | |
460 def onSelect(self, path): | |
461 try: | |
462 path = path[0] | |
463 except IndexError: | |
464 path = None | |
465 if not path: | |
466 self._xmluiCancelled() | |
467 else: | |
468 self._xmluiValidated({'path': path}) | |
469 | |
470 def show(self, *args, **kwargs): | |
471 assert kwargs["force"] | |
472 G.host.showUI(self) | |
473 | |
474 | |
29 | 475 ## Factory ## |
476 | |
477 | |
0 | 478 class WidgetFactory(object): |
479 | |
480 def __getattr__(self, attr): | |
481 if attr.startswith("create"): | |
482 cls = globals()[attr[6:]] | |
483 return cls | |
484 | |
485 | |
29 | 486 ## Core ## |
487 | |
488 | |
0 | 489 class Title(Label): |
490 | |
491 def __init__(self, *args, **kwargs): | |
492 kwargs['size'] = (100, 25) | |
493 kwargs['size_hint'] = (1,None) | |
494 super(Title, self).__init__(*args, **kwargs) | |
495 | |
496 | |
53
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
497 class FormButton(Button): |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
498 pass |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
499 |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
500 |
159 | 501 class XMLUIPanel(xmlui.XMLUIPanel, BoxLayout): |
0 | 502 widget_factory = WidgetFactory() |
503 | |
129
0704f3be65cb
xmlui: fixed missing whitelist argument
Goffi <goffi@goffi.org>
parents:
126
diff
changeset
|
504 def __init__(self, host, parsed_xml, title=None, flags=None, callback=None, ignore=None, whitelist=None, profile=C.PROF_KEY_NONE): |
241 | 505 BoxLayout.__init__(self) |
0 | 506 self.close_cb = None |
69
a9c6b089070d
xmlui: improvments to prepare parameters:
Goffi <goffi@goffi.org>
parents:
55
diff
changeset
|
507 self._post_treats = [] # list of callback to call after UI is constructed |
125
b6e6afb0dc46
xmlui: added LabelContainer and updated XMLUIPanel following changes in main class
Goffi <goffi@goffi.org>
parents:
99
diff
changeset
|
508 xmlui.XMLUIPanel.__init__(self, |
b6e6afb0dc46
xmlui: added LabelContainer and updated XMLUIPanel following changes in main class
Goffi <goffi@goffi.org>
parents:
99
diff
changeset
|
509 host, |
b6e6afb0dc46
xmlui: added LabelContainer and updated XMLUIPanel following changes in main class
Goffi <goffi@goffi.org>
parents:
99
diff
changeset
|
510 parsed_xml, |
b6e6afb0dc46
xmlui: added LabelContainer and updated XMLUIPanel following changes in main class
Goffi <goffi@goffi.org>
parents:
99
diff
changeset
|
511 title=title, |
b6e6afb0dc46
xmlui: added LabelContainer and updated XMLUIPanel following changes in main class
Goffi <goffi@goffi.org>
parents:
99
diff
changeset
|
512 flags=flags, |
b6e6afb0dc46
xmlui: added LabelContainer and updated XMLUIPanel following changes in main class
Goffi <goffi@goffi.org>
parents:
99
diff
changeset
|
513 callback=callback, |
b6e6afb0dc46
xmlui: added LabelContainer and updated XMLUIPanel following changes in main class
Goffi <goffi@goffi.org>
parents:
99
diff
changeset
|
514 ignore=ignore, |
129
0704f3be65cb
xmlui: fixed missing whitelist argument
Goffi <goffi@goffi.org>
parents:
126
diff
changeset
|
515 whitelist=whitelist, |
125
b6e6afb0dc46
xmlui: added LabelContainer and updated XMLUIPanel following changes in main class
Goffi <goffi@goffi.org>
parents:
99
diff
changeset
|
516 profile=profile) |
0 | 517 |
518 def setCloseCb(self, close_cb): | |
519 self.close_cb = close_cb | |
520 | |
521 def _xmluiClose(self): | |
522 if self.close_cb is not None: | |
523 self.close_cb(self) | |
524 else: | |
33
c21d1be2e54c
core: XMLUI notifications coming from backend are handled:
Goffi <goffi@goffi.org>
parents:
29
diff
changeset
|
525 G.host.closeUI() |
0 | 526 |
71
8c9fe2c5aacc
settings: save button is now disabled when there is nothing to save
Goffi <goffi@goffi.org>
parents:
69
diff
changeset
|
527 def onParamChange(self, ctrl): |
8c9fe2c5aacc
settings: save button is now disabled when there is nothing to save
Goffi <goffi@goffi.org>
parents:
69
diff
changeset
|
528 super(XMLUIPanel, self).onParamChange(ctrl) |
8c9fe2c5aacc
settings: save button is now disabled when there is nothing to save
Goffi <goffi@goffi.org>
parents:
69
diff
changeset
|
529 self.save_btn.disabled = False |
8c9fe2c5aacc
settings: save button is now disabled when there is nothing to save
Goffi <goffi@goffi.org>
parents:
69
diff
changeset
|
530 |
69
a9c6b089070d
xmlui: improvments to prepare parameters:
Goffi <goffi@goffi.org>
parents:
55
diff
changeset
|
531 def addPostTreat(self, callback): |
a9c6b089070d
xmlui: improvments to prepare parameters:
Goffi <goffi@goffi.org>
parents:
55
diff
changeset
|
532 self._post_treats.append(callback) |
a9c6b089070d
xmlui: improvments to prepare parameters:
Goffi <goffi@goffi.org>
parents:
55
diff
changeset
|
533 |
a9c6b089070d
xmlui: improvments to prepare parameters:
Goffi <goffi@goffi.org>
parents:
55
diff
changeset
|
534 def _postTreatCb(self): |
a9c6b089070d
xmlui: improvments to prepare parameters:
Goffi <goffi@goffi.org>
parents:
55
diff
changeset
|
535 for cb in self._post_treats: |
a9c6b089070d
xmlui: improvments to prepare parameters:
Goffi <goffi@goffi.org>
parents:
55
diff
changeset
|
536 cb() |
a9c6b089070d
xmlui: improvments to prepare parameters:
Goffi <goffi@goffi.org>
parents:
55
diff
changeset
|
537 del self._post_treats |
a9c6b089070d
xmlui: improvments to prepare parameters:
Goffi <goffi@goffi.org>
parents:
55
diff
changeset
|
538 |
71
8c9fe2c5aacc
settings: save button is now disabled when there is nothing to save
Goffi <goffi@goffi.org>
parents:
69
diff
changeset
|
539 def _saveButtonCb(self, button): |
8c9fe2c5aacc
settings: save button is now disabled when there is nothing to save
Goffi <goffi@goffi.org>
parents:
69
diff
changeset
|
540 button.disabled = True |
8c9fe2c5aacc
settings: save button is now disabled when there is nothing to save
Goffi <goffi@goffi.org>
parents:
69
diff
changeset
|
541 self.onSaveParams(button) |
8c9fe2c5aacc
settings: save button is now disabled when there is nothing to save
Goffi <goffi@goffi.org>
parents:
69
diff
changeset
|
542 |
0 | 543 def constructUI(self, parsed_dom): |
69
a9c6b089070d
xmlui: improvments to prepare parameters:
Goffi <goffi@goffi.org>
parents:
55
diff
changeset
|
544 xmlui.XMLUIPanel.constructUI(self, parsed_dom, self._postTreatCb) |
0 | 545 if self.xmlui_title: |
546 self.add_widget(Title(text=self.xmlui_title)) | |
547 self.add_widget(self.main_cont) | |
548 if self.type == 'form': | |
53
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
549 submit_btn = FormButton(text=_(u"Submit")) |
0 | 550 submit_btn.bind(on_press=self.onFormSubmitted) |
551 self.add_widget(submit_btn) | |
552 if not 'NO_CANCEL' in self.flags: | |
53
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
553 cancel_btn = FormButton(text=_(u"Cancel")) |
0 | 554 cancel_btn.bind(on_press=self.onFormCancelled) |
555 self.add_widget(cancel_btn) | |
69
a9c6b089070d
xmlui: improvments to prepare parameters:
Goffi <goffi@goffi.org>
parents:
55
diff
changeset
|
556 elif self.type == 'param': |
71
8c9fe2c5aacc
settings: save button is now disabled when there is nothing to save
Goffi <goffi@goffi.org>
parents:
69
diff
changeset
|
557 self.save_btn = FormButton(text=_(u"Save"), disabled=True) |
8c9fe2c5aacc
settings: save button is now disabled when there is nothing to save
Goffi <goffi@goffi.org>
parents:
69
diff
changeset
|
558 self.save_btn.bind(on_press=self._saveButtonCb) |
8c9fe2c5aacc
settings: save button is now disabled when there is nothing to save
Goffi <goffi@goffi.org>
parents:
69
diff
changeset
|
559 self.add_widget(self.save_btn) |
0 | 560 |
33
c21d1be2e54c
core: XMLUI notifications coming from backend are handled:
Goffi <goffi@goffi.org>
parents:
29
diff
changeset
|
561 def show(self, *args, **kwargs): |
c21d1be2e54c
core: XMLUI notifications coming from backend are handled:
Goffi <goffi@goffi.org>
parents:
29
diff
changeset
|
562 if not self.user_action and not kwargs.get("force", False): |
c21d1be2e54c
core: XMLUI notifications coming from backend are handled:
Goffi <goffi@goffi.org>
parents:
29
diff
changeset
|
563 G.host.addNotifUI(self) |
c21d1be2e54c
core: XMLUI notifications coming from backend are handled:
Goffi <goffi@goffi.org>
parents:
29
diff
changeset
|
564 else: |
c21d1be2e54c
core: XMLUI notifications coming from backend are handled:
Goffi <goffi@goffi.org>
parents:
29
diff
changeset
|
565 G.host.showUI(self) |
c21d1be2e54c
core: XMLUI notifications coming from backend are handled:
Goffi <goffi@goffi.org>
parents:
29
diff
changeset
|
566 |
0 | 567 |
29 | 568 class XMLUIDialog(xmlui.XMLUIDialog): |
569 dialog_factory = WidgetFactory() | |
570 | |
571 | |
235
525527a01439
xmlui: use create with partial and class_map, following change in base class
Goffi <goffi@goffi.org>
parents:
227
diff
changeset
|
572 create = partial(xmlui.create, class_map={ |
525527a01439
xmlui: use create with partial and class_map, following change in base class
Goffi <goffi@goffi.org>
parents:
227
diff
changeset
|
573 xmlui.CLASS_PANEL: XMLUIPanel, |
525527a01439
xmlui: use create with partial and class_map, following change in base class
Goffi <goffi@goffi.org>
parents:
227
diff
changeset
|
574 xmlui.CLASS_DIALOG: XMLUIDialog}) |