annotate cagou/core/xmlui.py @ 466:cd448b877d1d

install: update requirements with alabaster==0.7.12 alembic==1.4.3 anki @ file:///build/anki/src/anki/dist/anki-2.1.35-py3-none-any.whl ankirspy @ file:///build/anki/src/anki/dist/ankirspy-2.1.35-cp39-cp39-manylinux1_x86_64.whl ansi2html==1.6.0 anytree==2.8.0 apipkg==1.5 apparmor==3.0.1 appdirs==1.4.4 appimage-builder==0.8.5 aqt @ file:///build/anki/src/anki/dist/aqt-2.1.35-py3-none-any.whl argcomplete==1.12.1 argon2-cffi==20.1.0 asn1crypto==1.4.0 async-generator==1.10 attrs==20.3.0 autobahn==21.3.1 Automat==20.2.0 autopep8==1.5.5 Babel==2.9.0 backcall==0.2.0 bcrypt==3.2.0 Beaker==1.11.0 beautifulsoup4==4.9.3 black==20.8b1 bleach==3.3.0 blinker==1.4 bmap-tools==3.5 breezy==3.1.0 Brlapi==0.8.2 btrfsutil==5.11 CacheControl==0.12.6 cached-property==1.5.2 cagou==0.8.0.dev0+83c67b093350.153 cairocffi==1.2.0 CairoSVG==2.5.2 certifi==2020.6.20 cffi==1.14.5 chardet==3.0.4 click==7.1.2 colorama==0.4.4 commonmark==0.9.1 configobj==5.1.0.dev0 constantly==15.1.0 contextlib2==0.6.0.post1 coverage==5.5 cryptography==3.4.6 css-parser==1.0.6 cssselect2==0.4.1 cycler==0.10.0 Cython==0.29.22 decorator==4.4.2 defusedxml==0.6.0 diffoscope==169 distlib==0.3.1 distro==1.5.0 docker==4.4.4 docker-compose==1.28.5 docker-pycreds==0.4.0 dockerpty==0.4.1 docopt==0.6.2 docutils==0.16 dulwich==0.20.20 emrichen==0.2.3 entrypoints==0.3 extras==1.0.0 fastimport==0.9.8 file-magic==0.4.0 filelock==3.0.12 fixtures==3.0.0 flake8==3.8.4 Flask==1.1.2 Flask-BabelEx==0.9.4 Flask-Compress==1.8.0 Flask-Cors==3.0.9 Flask-Gravatar==0.5.0 Flask-Login==0.5.0 Flask-Mail==0.9.1 Flask-Migrate==2.7.0 Flask-Paranoid==0.2.0 Flask-Principal==0.4.0 Flask-Script==2.0.6 Flask-Security-Too==3.3.3 Flask-SQLAlchemy==2.4.4 Flask-WTF==0.14.3 future==0.18.2 gajim==1.2.2 gssapi==1.6.12 html2text==2020.1.16 html5lib==1.1 httpie==2.4.0 httplib2==0.19.0 hyperlink==21.0.0 idna==2.10 imagesize==1.2.0 img2pdf==0.4.0 importlib-metadata==3.4.0 incremental==17.5.0 inflect==5.3.0 iniconfig==1.1.1 ipdb==0.13.6 ipykernel==5.4.2 ipython==7.19.0 ipython-genutils==0.2.0 ipywidgets==7.6.2 isc==2.0 itsdangerous==1.1.0 jedi==0.17.2 jeepney==0.6.0 Jinja2==2.11.3 joblib==1.0.0 jsonpath-rw==1.4.0 jsonpickle==1.5.1 jsonschema==3.2.0 jupyter-client==6.1.7 jupyter-console==6.2.0 jupyter-core==4.6.3 jupyterlab-pygments==0.1.2 keyring==23.0.0 Kivy==2.0.0 kiwisolver==1.3.1 langdetect==1.0.8 ldap3==2.9.dev0 lensfun==0.3.95 LibAppArmor==3.0.1 libarchive-c==2.9 libfdt==1.6.0 libnacl==1.7.2 lockfile==0.12.2 louis==3.17.0 lxml==4.6.2 Mako==1.1.4 Markdown==3.3.3 MarkupSafe==1.1.1 matplotlib==3.3.4 mccabe==0.6.1 meld==3.20.3 mercurial==5.7.1 meson==0.57.1 miniupnpc==2.1 mistune==0.8.4 more-itertools==8.6.0 msgpack==1.0.2 mypy==0.812 mypy-extensions==0.4.3 natsort==7.1.1 nbclient==0.5.1 nbconvert==6.0.7 nbformat==5.0.8 nbxmpp==1.0.2 nest-asyncio==1.4.3 netifaces==0.10.9 netsnmp-python==1.0a1 networkx==2.5 nltk==3.5 nose==1.3.7 notebook==6.2.0 Nuitka==0.6.12.3 numpy==1.20.1 openshot-qt==2.5.1 ordered-set==4.0.2 orjson @ file:///build/python-orjson/src/python-orjson-3.5.1/target/wheels/orjson-3.5.1-cp39-cp39-manylinux2010_x86_64.whl packaging==20.9 pandas==1.2.3 pandocfilters==1.4.3 paramiko==2.7.2 parso==0.7.1 passlib==1.7.4 path==15.1.2 pathspec==0.8.1 patiencediff==0.2.1 pbr==5.5.1 pdfarranger==1.7.0 pep517==0.9.1 pexpect==4.8.0 pickleshare==0.7.5 pikepdf==2.8.0.post2 Pillow==8.1.0 pluggy==0.13.1 ply==3.11 precis-i18n==1.0.3 progress==1.5 progressbar2==3.53.1 prometheus-client==0.9.0 prompt-toolkit==3.0.17 protobuf==3.12.4 psutil==5.8.0 psycopg2==2.8.6 ptyprocess==0.7.0 pudb==2020.1 pwquality==1.4.4 py==1.10.0 pyaml==20.4.0 pyasn1==0.4.8 pyasn1-modules==0.2.8 PyAudio==0.2.11 pybind11==2.6.2 pycairo==1.20.0 pycodestyle==2.6.0 pycountry==20.7.3 pycparser==2.20 pydocstyle==5.1.1 pyenchant==3.2.0 pyflakes==2.2.0 Pygments==2.8.1 PyGObject==3.38.0 PyHamcrest==1.9.0 pyinotify==0.9.6 pymediainfo==5.0.3 PyNaCl==1.4.0 PyOpenGL==3.1.5 pyOpenSSL==20.0.1 pyparsing==2.4.7 pyPEG2==2.15.2 PyQt5==5.15.4 PyQt5-sip==12.8.1 PyQtWebEngine==5.15.4 pyrsistent==0.17.3 PySocks==1.7.1 pytest==6.2.2 python-dateutil==2.8.1 python-dotenv==0.15.0 python-editor==1.0.4 python-Levenshtein==0.12.2 python-mimeparse==1.6.0 python-utils==2.5.6 python-xlib==0.29 pytoml==0.1.21 pytz==2021.1 pyxdg==0.26 PyYAML==5.3.1 pyzmq==20.0.0 questionary==1.9.0 qutebrowser==2.1.0 Reflector==2021.1.10.0.6.34 regex==2020.11.13 requests==2.25.1 requests-toolbelt==0.9.1 requirements-parser==0.2.0 resolvelib==0.5.4 retrying==1.3.3 s3cmd==2.1.0 schema==0.7.4 scikit-learn==0.24.1 scipy==1.6.1 scons==3.1.2 screenkey==1.4 SecretStorage==3.3.1 Send2Trash==1.5.0 service-identity==18.1.0 sh==1.14.1 shortuuid==1.0.1 simplejson==3.17.2 sip==4.19.25 six==1.15.0 snowballstemmer==2.1.0 soupsieve==2.2 speaklater==1.3 Sphinx==3.5.2 sphinx-rtd-theme==0.5.1 sphinxcontrib-applehelp==1.0.2 sphinxcontrib-devhelp==1.0.2 sphinxcontrib-htmlhelp==1.0.3 sphinxcontrib-jsmath==1.0.1 sphinxcontrib-qthelp==1.0.3 sphinxcontrib-serializinghtml==1.1.4 sqlacodegen==2.3.0 SQLAlchemy==1.3.23 sqlparse==0.4.1 sshtunnel==0.1.5 subdownloader==2.1.0 systemd-python==234 team==1.0 termcolor==1.1.0 terminado==0.9.2 terminator==2.1.0 testpath==0.4.4 testtools==2.4.0 texttable==1.6.3 threadpoolctl==2.1.0 tinycss2==1.1.0 tlsh==0.2.0 toml==0.10.2 tornado==6.1 traitlets==5.0.5 treq==21.1.0 Twisted==20.3.0 txaio==21.2.1 typed-ast==1.4.2 typing-extensions==3.7.4.3 tzlocal==2.1 urllib3==1.26.3 urwid==2.1.1 validate==5.1.0.dev0 virtualenv==20.4.2 waitress==1.4.4 wcwidth==0.2.5 webencodings==0.5.1 websocket-client==0.58.0 Werkzeug==1.0.1 Whoosh==2.7.4 widgetsnbextension==3.5.1 wsaccel==0.6.3 WTForms==2.2.1 xcffib==0.11.1 youtube-dl==2021.3.3 zipp==3.4.1 zope.interface==5.2.0
author Goffi <goffi@goffi.org>
date Sat, 20 Mar 2021 14:26:33 +0100
parents 3c9ba4a694ef
children 203755bbe0fe
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
379
1da3c379205b fixed shebangs
Goffi <goffi@goffi.org>
parents: 378
diff changeset
1 #!/usr/bin/env python3
1da3c379205b fixed shebangs
Goffi <goffi@goffi.org>
parents: 378
diff changeset
2
0
160cc95ad7ea initial commit:
Goffi <goffi@goffi.org>
parents:
diff changeset
3
160cc95ad7ea initial commit:
Goffi <goffi@goffi.org>
parents:
diff changeset
4 # Cagou: a SàT frontend
461
3c9ba4a694ef dates update
Goffi <goffi@goffi.org>
parents: 379
diff changeset
5 # Copyright (C) 2016-2021 Jérôme Poisson (goffi@goffi.org)
0
160cc95ad7ea initial commit:
Goffi <goffi@goffi.org>
parents:
diff changeset
6
160cc95ad7ea initial commit:
Goffi <goffi@goffi.org>
parents:
diff changeset
7 # This program is free software: you can redistribute it and/or modify
160cc95ad7ea initial commit:
Goffi <goffi@goffi.org>
parents:
diff changeset
8 # it under the terms of the GNU Affero General Public License as published by
160cc95ad7ea initial commit:
Goffi <goffi@goffi.org>
parents:
diff changeset
9 # the Free Software Foundation, either version 3 of the License, or
160cc95ad7ea initial commit:
Goffi <goffi@goffi.org>
parents:
diff changeset
10 # (at your option) any later version.
160cc95ad7ea initial commit:
Goffi <goffi@goffi.org>
parents:
diff changeset
11
160cc95ad7ea initial commit:
Goffi <goffi@goffi.org>
parents:
diff changeset
12 # This program is distributed in the hope that it will be useful,
160cc95ad7ea initial commit:
Goffi <goffi@goffi.org>
parents:
diff changeset
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
160cc95ad7ea initial commit:
Goffi <goffi@goffi.org>
parents:
diff changeset
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
160cc95ad7ea initial commit:
Goffi <goffi@goffi.org>
parents:
diff changeset
15 # GNU Affero General Public License for more details.
160cc95ad7ea initial commit:
Goffi <goffi@goffi.org>
parents:
diff changeset
16
160cc95ad7ea initial commit:
Goffi <goffi@goffi.org>
parents:
diff changeset
17 # You should have received a copy of the GNU Affero General Public License
160cc95ad7ea initial commit:
Goffi <goffi@goffi.org>
parents:
diff changeset
18 # along with this program. If not, see <http://www.gnu.org/licenses/>.
160cc95ad7ea initial commit:
Goffi <goffi@goffi.org>
parents:
diff changeset
19
160cc95ad7ea initial commit:
Goffi <goffi@goffi.org>
parents:
diff changeset
20 from sat.core.i18n import _
55
b0011c6dc7dc core (xmlui): fixed bad import
Goffi <goffi@goffi.org>
parents: 53
diff changeset
21 from .constants import Const as C
0
160cc95ad7ea initial commit:
Goffi <goffi@goffi.org>
parents:
diff changeset
22 from sat.core.log import getLogger
160cc95ad7ea initial commit:
Goffi <goffi@goffi.org>
parents:
diff changeset
23 from sat_frontends.tools import xmlui
241
661b9cf7b4e4 xmlui: scroll/size fixes:
Goffi <goffi@goffi.org>
parents: 236
diff changeset
24 from kivy.uix.scrollview import ScrollView
99
f67b9baa81f0 xmlui: FileDialog first draft
Goffi <goffi@goffi.org>
parents: 76
diff changeset
25 from kivy.uix.boxlayout import BoxLayout
53
65775152aac1 xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents: 33
diff changeset
26 from kivy.uix.gridlayout import GridLayout
69
a9c6b089070d xmlui: improvments to prepare parameters:
Goffi <goffi@goffi.org>
parents: 55
diff changeset
27 from kivy.uix.tabbedpanel import TabbedPanel, TabbedPanelItem
0
160cc95ad7ea initial commit:
Goffi <goffi@goffi.org>
parents:
diff changeset
28 from kivy.uix.textinput import TextInput
160cc95ad7ea initial commit:
Goffi <goffi@goffi.org>
parents:
diff changeset
29 from kivy.uix.label import Label
160cc95ad7ea initial commit:
Goffi <goffi@goffi.org>
parents:
diff changeset
30 from kivy.uix.button import Button
53
65775152aac1 xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents: 33
diff changeset
31 from kivy.uix.togglebutton import ToggleButton
0
160cc95ad7ea initial commit:
Goffi <goffi@goffi.org>
parents:
diff changeset
32 from kivy.uix.widget import Widget
53
65775152aac1 xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents: 33
diff changeset
33 from kivy.uix.switch import Switch
65775152aac1 xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents: 33
diff changeset
34 from kivy import properties
29
8b5827c43155 notes first draft:
Goffi <goffi@goffi.org>
parents: 15
diff changeset
35 from cagou import G
204
37638765c97b xmlui: implemented ConfirmDialog using new dialog.ConfirmDialog
Goffi <goffi@goffi.org>
parents: 159
diff changeset
36 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
37 from functools import partial
29
8b5827c43155 notes first draft:
Goffi <goffi@goffi.org>
parents: 15
diff changeset
38
305
b2727877bad4 remote: fixed workflow and size for XMLUI panel used with Ad-Hoc commands:
Goffi <goffi@goffi.org>
parents: 286
diff changeset
39 log = getLogger(__name__)
29
8b5827c43155 notes first draft:
Goffi <goffi@goffi.org>
parents: 15
diff changeset
40
8b5827c43155 notes first draft:
Goffi <goffi@goffi.org>
parents: 15
diff changeset
41 ## Widgets ##
0
160cc95ad7ea initial commit:
Goffi <goffi@goffi.org>
parents:
diff changeset
42
160cc95ad7ea initial commit:
Goffi <goffi@goffi.org>
parents:
diff changeset
43
69
a9c6b089070d xmlui: improvments to prepare parameters:
Goffi <goffi@goffi.org>
parents: 55
diff changeset
44 class TextInputOnChange(object):
a9c6b089070d xmlui: improvments to prepare parameters:
Goffi <goffi@goffi.org>
parents: 55
diff changeset
45
a9c6b089070d xmlui: improvments to prepare parameters:
Goffi <goffi@goffi.org>
parents: 55
diff changeset
46 def __init__(self):
a9c6b089070d xmlui: improvments to prepare parameters:
Goffi <goffi@goffi.org>
parents: 55
diff changeset
47 self._xmlui_onchange_cb = None
a9c6b089070d xmlui: improvments to prepare parameters:
Goffi <goffi@goffi.org>
parents: 55
diff changeset
48 self._got_focus = False
a9c6b089070d xmlui: improvments to prepare parameters:
Goffi <goffi@goffi.org>
parents: 55
diff changeset
49
a9c6b089070d xmlui: improvments to prepare parameters:
Goffi <goffi@goffi.org>
parents: 55
diff changeset
50 def _xmluiOnChange(self, callback):
a9c6b089070d xmlui: improvments to prepare parameters:
Goffi <goffi@goffi.org>
parents: 55
diff changeset
51 self._xmlui_onchange_cb = callback
a9c6b089070d xmlui: improvments to prepare parameters:
Goffi <goffi@goffi.org>
parents: 55
diff changeset
52
a9c6b089070d xmlui: improvments to prepare parameters:
Goffi <goffi@goffi.org>
parents: 55
diff changeset
53 def on_focus(self, instance, focus):
a9c6b089070d xmlui: improvments to prepare parameters:
Goffi <goffi@goffi.org>
parents: 55
diff changeset
54 # we need to wait for first focus, else initial value
a9c6b089070d xmlui: improvments to prepare parameters:
Goffi <goffi@goffi.org>
parents: 55
diff changeset
55 # will trigger a on_text
a9c6b089070d xmlui: improvments to prepare parameters:
Goffi <goffi@goffi.org>
parents: 55
diff changeset
56 if not self._got_focus and focus:
a9c6b089070d xmlui: improvments to prepare parameters:
Goffi <goffi@goffi.org>
parents: 55
diff changeset
57 self._got_focus = True
a9c6b089070d xmlui: improvments to prepare parameters:
Goffi <goffi@goffi.org>
parents: 55
diff changeset
58
a9c6b089070d xmlui: improvments to prepare parameters:
Goffi <goffi@goffi.org>
parents: 55
diff changeset
59 def on_text(self, instance, new_text):
a9c6b089070d xmlui: improvments to prepare parameters:
Goffi <goffi@goffi.org>
parents: 55
diff changeset
60 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
61 self._xmlui_onchange_cb(self)
a9c6b089070d xmlui: improvments to prepare parameters:
Goffi <goffi@goffi.org>
parents: 55
diff changeset
62
a9c6b089070d xmlui: improvments to prepare parameters:
Goffi <goffi@goffi.org>
parents: 55
diff changeset
63
53
65775152aac1 xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents: 33
diff changeset
64 class EmptyWidget(xmlui.EmptyWidget, Widget):
65775152aac1 xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents: 33
diff changeset
65
65775152aac1 xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents: 33
diff changeset
66 def __init__(self, _xmlui_parent):
65775152aac1 xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents: 33
diff changeset
67 Widget.__init__(self)
65775152aac1 xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents: 33
diff changeset
68
65775152aac1 xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents: 33
diff changeset
69
0
160cc95ad7ea initial commit:
Goffi <goffi@goffi.org>
parents:
diff changeset
70 class TextWidget(xmlui.TextWidget, Label):
160cc95ad7ea initial commit:
Goffi <goffi@goffi.org>
parents:
diff changeset
71
160cc95ad7ea initial commit:
Goffi <goffi@goffi.org>
parents:
diff changeset
72 def __init__(self, xmlui_parent, value):
160cc95ad7ea initial commit:
Goffi <goffi@goffi.org>
parents:
diff changeset
73 Label.__init__(self, text=value)
160cc95ad7ea initial commit:
Goffi <goffi@goffi.org>
parents:
diff changeset
74
160cc95ad7ea initial commit:
Goffi <goffi@goffi.org>
parents:
diff changeset
75
53
65775152aac1 xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents: 33
diff changeset
76 class LabelWidget(xmlui.LabelWidget, TextWidget):
65775152aac1 xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents: 33
diff changeset
77 pass
65775152aac1 xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents: 33
diff changeset
78
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 class JidWidget(xmlui.JidWidget, TextWidget):
65775152aac1 xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents: 33
diff changeset
81 pass
65775152aac1 xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents: 33
diff changeset
82
65775152aac1 xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents: 33
diff changeset
83
69
a9c6b089070d xmlui: improvments to prepare parameters:
Goffi <goffi@goffi.org>
parents: 55
diff changeset
84 class StringWidget(xmlui.StringWidget, TextInput, TextInputOnChange):
53
65775152aac1 xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents: 33
diff changeset
85
65775152aac1 xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents: 33
diff changeset
86 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
87 TextInput.__init__(self, text=value)
69
a9c6b089070d xmlui: improvments to prepare parameters:
Goffi <goffi@goffi.org>
parents: 55
diff changeset
88 TextInputOnChange.__init__(self)
53
65775152aac1 xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents: 33
diff changeset
89 self.readonly = read_only
65775152aac1 xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents: 33
diff changeset
90
65775152aac1 xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents: 33
diff changeset
91 def _xmluiSetValue(self, value):
65775152aac1 xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents: 33
diff changeset
92 self.text = value
65775152aac1 xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents: 33
diff changeset
93
65775152aac1 xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents: 33
diff changeset
94 def _xmluiGetValue(self):
65775152aac1 xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents: 33
diff changeset
95 return self.text
65775152aac1 xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents: 33
diff changeset
96
65775152aac1 xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents: 33
diff changeset
97
236
ca86954b3788 xmlui: implemented TextBoxWidget + set height for XMLUIPanel
Goffi <goffi@goffi.org>
parents: 235
diff changeset
98 class TextBoxWidget(xmlui.TextBoxWidget, StringWidget):
ca86954b3788 xmlui: implemented TextBoxWidget + set height for XMLUIPanel
Goffi <goffi@goffi.org>
parents: 235
diff changeset
99 pass
ca86954b3788 xmlui: implemented TextBoxWidget + set height for XMLUIPanel
Goffi <goffi@goffi.org>
parents: 235
diff changeset
100
ca86954b3788 xmlui: implemented TextBoxWidget + set height for XMLUIPanel
Goffi <goffi@goffi.org>
parents: 235
diff changeset
101
53
65775152aac1 xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents: 33
diff changeset
102 class JidInputWidget(xmlui.JidInputWidget, StringWidget):
65775152aac1 xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents: 33
diff changeset
103 pass
65775152aac1 xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents: 33
diff changeset
104
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 class ButtonWidget(xmlui.ButtonWidget, Button):
65775152aac1 xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents: 33
diff changeset
107
65775152aac1 xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents: 33
diff changeset
108 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
109 Button.__init__(self)
65775152aac1 xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents: 33
diff changeset
110 self.text = value
65775152aac1 xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents: 33
diff changeset
111 self.callback = click_callback
65775152aac1 xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents: 33
diff changeset
112
65775152aac1 xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents: 33
diff changeset
113 def _xmluiOnClick(self, callback):
65775152aac1 xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents: 33
diff changeset
114 self.callback = callback
65775152aac1 xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents: 33
diff changeset
115
65775152aac1 xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents: 33
diff changeset
116 def on_release(self):
65775152aac1 xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents: 33
diff changeset
117 self.callback(self)
65775152aac1 xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents: 33
diff changeset
118
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 class DividerWidget(xmlui.DividerWidget, Widget):
65775152aac1 xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents: 33
diff changeset
121 # 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
122 style = properties.OptionProperty('line',
65775152aac1 xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents: 33
diff changeset
123 options=['line', 'dot', 'dash', 'plain', 'blank'])
65775152aac1 xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents: 33
diff changeset
124
65775152aac1 xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents: 33
diff changeset
125 def __init__(self, _xmlui_parent, style="line"):
65775152aac1 xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents: 33
diff changeset
126 Widget.__init__(self, style=style)
65775152aac1 xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents: 33
diff changeset
127
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 class ListWidgetItem(ToggleButton):
65775152aac1 xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents: 33
diff changeset
130 value = properties.StringProperty()
65775152aac1 xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents: 33
diff changeset
131
65775152aac1 xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents: 33
diff changeset
132 def on_release(self):
65775152aac1 xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents: 33
diff changeset
133 parent = self.parent
251
1f579baf787a xmlui: some design improvments + use ScrollView + BoxLayout instead of DropDown for ListWidget:
Goffi <goffi@goffi.org>
parents: 243
diff changeset
134 while parent is not None and not isinstance(parent, ListWidget):
53
65775152aac1 xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents: 33
diff changeset
135 parent = parent.parent
65775152aac1 xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents: 33
diff changeset
136
251
1f579baf787a xmlui: some design improvments + use ScrollView + BoxLayout instead of DropDown for ListWidget:
Goffi <goffi@goffi.org>
parents: 243
diff changeset
137 if parent is not None:
53
65775152aac1 xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents: 33
diff changeset
138 parent.select(self)
251
1f579baf787a xmlui: some design improvments + use ScrollView + BoxLayout instead of DropDown for ListWidget:
Goffi <goffi@goffi.org>
parents: 243
diff changeset
139 return super(ListWidgetItem, self).on_release()
53
65775152aac1 xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents: 33
diff changeset
140
65775152aac1 xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents: 33
diff changeset
141 @property
65775152aac1 xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents: 33
diff changeset
142 def selected(self):
65775152aac1 xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents: 33
diff changeset
143 return self.state == 'down'
65775152aac1 xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents: 33
diff changeset
144
65775152aac1 xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents: 33
diff changeset
145 @selected.setter
65775152aac1 xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents: 33
diff changeset
146 def selected(self, value):
65775152aac1 xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents: 33
diff changeset
147 self.state = 'down' if value else 'normal'
65775152aac1 xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents: 33
diff changeset
148
65775152aac1 xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents: 33
diff changeset
149
251
1f579baf787a xmlui: some design improvments + use ScrollView + BoxLayout instead of DropDown for ListWidget:
Goffi <goffi@goffi.org>
parents: 243
diff changeset
150 class ListWidget(xmlui.ListWidget, ScrollView):
1f579baf787a xmlui: some design improvments + use ScrollView + BoxLayout instead of DropDown for ListWidget:
Goffi <goffi@goffi.org>
parents: 243
diff changeset
151 layout = properties.ObjectProperty()
53
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):
251
1f579baf787a xmlui: some design improvments + use ScrollView + BoxLayout instead of DropDown for ListWidget:
Goffi <goffi@goffi.org>
parents: 243
diff changeset
154 ScrollView.__init__(self)
53
65775152aac1 xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents: 33
diff changeset
155 self.multi = 'single' not in flags
65775152aac1 xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents: 33
diff changeset
156 self._values = []
65775152aac1 xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents: 33
diff changeset
157 for option in options:
65775152aac1 xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents: 33
diff changeset
158 self.addValue(option)
65775152aac1 xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents: 33
diff changeset
159 self._xmluiSelectValues(selected)
65775152aac1 xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents: 33
diff changeset
160 self._on_change = None
65775152aac1 xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents: 33
diff changeset
161
65775152aac1 xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents: 33
diff changeset
162 @property
65775152aac1 xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents: 33
diff changeset
163 def items(self):
251
1f579baf787a xmlui: some design improvments + use ScrollView + BoxLayout instead of DropDown for ListWidget:
Goffi <goffi@goffi.org>
parents: 243
diff changeset
164 return self.layout.children
53
65775152aac1 xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents: 33
diff changeset
165
251
1f579baf787a xmlui: some design improvments + use ScrollView + BoxLayout instead of DropDown for ListWidget:
Goffi <goffi@goffi.org>
parents: 243
diff changeset
166 def select(self, item):
53
65775152aac1 xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents: 33
diff changeset
167 if not self.multi:
65775152aac1 xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents: 33
diff changeset
168 self._xmluiSelectValues([item.value])
65775152aac1 xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents: 33
diff changeset
169 if self._on_change is not None:
65775152aac1 xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents: 33
diff changeset
170 self._on_change(self)
65775152aac1 xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents: 33
diff changeset
171
65775152aac1 xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents: 33
diff changeset
172 def addValue(self, option, selected=False):
65775152aac1 xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents: 33
diff changeset
173 """add a value in the list
65775152aac1 xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents: 33
diff changeset
174
65775152aac1 xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents: 33
diff changeset
175 @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
176 """
65775152aac1 xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents: 33
diff changeset
177 self._values.append(option)
65775152aac1 xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents: 33
diff changeset
178 item = ListWidgetItem()
65775152aac1 xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents: 33
diff changeset
179 item.value, item.text = option
65775152aac1 xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents: 33
diff changeset
180 item.selected = selected
251
1f579baf787a xmlui: some design improvments + use ScrollView + BoxLayout instead of DropDown for ListWidget:
Goffi <goffi@goffi.org>
parents: 243
diff changeset
181 self.layout.add_widget(item)
53
65775152aac1 xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents: 33
diff changeset
182
65775152aac1 xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents: 33
diff changeset
183 def _xmluiSelectValue(self, value):
65775152aac1 xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents: 33
diff changeset
184 self._xmluiSelectValues([value])
65775152aac1 xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents: 33
diff changeset
185
65775152aac1 xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents: 33
diff changeset
186 def _xmluiSelectValues(self, values):
65775152aac1 xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents: 33
diff changeset
187 for item in self.items:
65775152aac1 xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents: 33
diff changeset
188 item.selected = item.value in values
65775152aac1 xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents: 33
diff changeset
189 if item.selected and not self.multi:
65775152aac1 xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents: 33
diff changeset
190 self.text = item.text
65775152aac1 xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents: 33
diff changeset
191
65775152aac1 xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents: 33
diff changeset
192 def _xmluiGetSelectedValues(self):
65775152aac1 xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents: 33
diff changeset
193 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
194
65775152aac1 xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents: 33
diff changeset
195 def _xmluiAddValues(self, values, select=True):
65775152aac1 xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents: 33
diff changeset
196 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
197 for v in values:
65775152aac1 xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents: 33
diff changeset
198 self.addValue(v, select)
65775152aac1 xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents: 33
diff changeset
199
65775152aac1 xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents: 33
diff changeset
200 def _xmluiOnChange(self, callback):
65775152aac1 xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents: 33
diff changeset
201 self._on_change = callback
65775152aac1 xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents: 33
diff changeset
202
65775152aac1 xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents: 33
diff changeset
203
69
a9c6b089070d xmlui: improvments to prepare parameters:
Goffi <goffi@goffi.org>
parents: 55
diff changeset
204 class JidsListWidget(ListWidget):
a9c6b089070d xmlui: improvments to prepare parameters:
Goffi <goffi@goffi.org>
parents: 55
diff changeset
205 # TODO: real list dedicated to jids
a9c6b089070d xmlui: improvments to prepare parameters:
Goffi <goffi@goffi.org>
parents: 55
diff changeset
206
a9c6b089070d xmlui: improvments to prepare parameters:
Goffi <goffi@goffi.org>
parents: 55
diff changeset
207 def __init__(self, _xmlui_parent, jids, flags):
a9c6b089070d xmlui: improvments to prepare parameters:
Goffi <goffi@goffi.org>
parents: 55
diff changeset
208 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
209
a9c6b089070d xmlui: improvments to prepare parameters:
Goffi <goffi@goffi.org>
parents: 55
diff changeset
210
a9c6b089070d xmlui: improvments to prepare parameters:
Goffi <goffi@goffi.org>
parents: 55
diff changeset
211 class PasswordWidget(xmlui.PasswordWidget, TextInput, TextInputOnChange):
0
160cc95ad7ea initial commit:
Goffi <goffi@goffi.org>
parents:
diff changeset
212
160cc95ad7ea initial commit:
Goffi <goffi@goffi.org>
parents:
diff changeset
213 def __init__(self, _xmlui_parent, value, read_only=False):
160cc95ad7ea initial commit:
Goffi <goffi@goffi.org>
parents:
diff changeset
214 TextInput.__init__(self, password=True, multiline=False,
160cc95ad7ea initial commit:
Goffi <goffi@goffi.org>
parents:
diff changeset
215 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
216 TextInputOnChange.__init__(self)
0
160cc95ad7ea initial commit:
Goffi <goffi@goffi.org>
parents:
diff changeset
217
160cc95ad7ea initial commit:
Goffi <goffi@goffi.org>
parents:
diff changeset
218 def _xmluiSetValue(self, value):
160cc95ad7ea initial commit:
Goffi <goffi@goffi.org>
parents:
diff changeset
219 self.text = value
160cc95ad7ea initial commit:
Goffi <goffi@goffi.org>
parents:
diff changeset
220
160cc95ad7ea initial commit:
Goffi <goffi@goffi.org>
parents:
diff changeset
221 def _xmluiGetValue(self):
160cc95ad7ea initial commit:
Goffi <goffi@goffi.org>
parents:
diff changeset
222 return self.text
160cc95ad7ea initial commit:
Goffi <goffi@goffi.org>
parents:
diff changeset
223
160cc95ad7ea initial commit:
Goffi <goffi@goffi.org>
parents:
diff changeset
224
53
65775152aac1 xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents: 33
diff changeset
225 class BoolWidget(xmlui.BoolWidget, Switch):
65775152aac1 xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents: 33
diff changeset
226
65775152aac1 xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents: 33
diff changeset
227 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
228 Switch.__init__(self, active=state)
65775152aac1 xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents: 33
diff changeset
229 if read_only:
65775152aac1 xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents: 33
diff changeset
230 self.disabled = True
65775152aac1 xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents: 33
diff changeset
231
65775152aac1 xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents: 33
diff changeset
232 def _xmluiSetValue(self, value):
65775152aac1 xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents: 33
diff changeset
233 self.active = value
65775152aac1 xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents: 33
diff changeset
234
65775152aac1 xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents: 33
diff changeset
235 def _xmluiGetValue(self):
76
a766c278b640 xmlui: fixed BoolWidget _xmluiGetValue:
Goffi <goffi@goffi.org>
parents: 71
diff changeset
236 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
237
69
a9c6b089070d xmlui: improvments to prepare parameters:
Goffi <goffi@goffi.org>
parents: 55
diff changeset
238 def _xmluiOnChange(self, callback):
a9c6b089070d xmlui: improvments to prepare parameters:
Goffi <goffi@goffi.org>
parents: 55
diff changeset
239 self.bind(active=lambda instance, value: callback(instance))
a9c6b089070d xmlui: improvments to prepare parameters:
Goffi <goffi@goffi.org>
parents: 55
diff changeset
240
a9c6b089070d xmlui: improvments to prepare parameters:
Goffi <goffi@goffi.org>
parents: 55
diff changeset
241
a9c6b089070d xmlui: improvments to prepare parameters:
Goffi <goffi@goffi.org>
parents: 55
diff changeset
242 class IntWidget(xmlui.IntWidget, TextInput, TextInputOnChange):
a9c6b089070d xmlui: improvments to prepare parameters:
Goffi <goffi@goffi.org>
parents: 55
diff changeset
243
a9c6b089070d xmlui: improvments to prepare parameters:
Goffi <goffi@goffi.org>
parents: 55
diff changeset
244 def __init__(self, _xmlui_parent, value, read_only=False):
a9c6b089070d xmlui: improvments to prepare parameters:
Goffi <goffi@goffi.org>
parents: 55
diff changeset
245 TextInput.__init__(self, text=value, input_filter='int', multiline=False)
a9c6b089070d xmlui: improvments to prepare parameters:
Goffi <goffi@goffi.org>
parents: 55
diff changeset
246 TextInputOnChange.__init__(self)
a9c6b089070d xmlui: improvments to prepare parameters:
Goffi <goffi@goffi.org>
parents: 55
diff changeset
247 if read_only:
a9c6b089070d xmlui: improvments to prepare parameters:
Goffi <goffi@goffi.org>
parents: 55
diff changeset
248 self.disabled = True
a9c6b089070d xmlui: improvments to prepare parameters:
Goffi <goffi@goffi.org>
parents: 55
diff changeset
249
a9c6b089070d xmlui: improvments to prepare parameters:
Goffi <goffi@goffi.org>
parents: 55
diff changeset
250 def _xmluiSetValue(self, value):
a9c6b089070d xmlui: improvments to prepare parameters:
Goffi <goffi@goffi.org>
parents: 55
diff changeset
251 self.text = value
a9c6b089070d xmlui: improvments to prepare parameters:
Goffi <goffi@goffi.org>
parents: 55
diff changeset
252
a9c6b089070d xmlui: improvments to prepare parameters:
Goffi <goffi@goffi.org>
parents: 55
diff changeset
253 def _xmluiGetValue(self):
a9c6b089070d xmlui: improvments to prepare parameters:
Goffi <goffi@goffi.org>
parents: 55
diff changeset
254 return self.text
a9c6b089070d xmlui: improvments to prepare parameters:
Goffi <goffi@goffi.org>
parents: 55
diff changeset
255
53
65775152aac1 xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents: 33
diff changeset
256
29
8b5827c43155 notes first draft:
Goffi <goffi@goffi.org>
parents: 15
diff changeset
257 ## Containers ##
8b5827c43155 notes first draft:
Goffi <goffi@goffi.org>
parents: 15
diff changeset
258
8b5827c43155 notes first draft:
Goffi <goffi@goffi.org>
parents: 15
diff changeset
259
286
4772ba26623f xmlui: many improvments:
Goffi <goffi@goffi.org>
parents: 282
diff changeset
260 class VerticalContainer(xmlui.VerticalContainer, BoxLayout):
0
160cc95ad7ea initial commit:
Goffi <goffi@goffi.org>
parents:
diff changeset
261
160cc95ad7ea initial commit:
Goffi <goffi@goffi.org>
parents:
diff changeset
262 def __init__(self, xmlui_parent):
69
a9c6b089070d xmlui: improvments to prepare parameters:
Goffi <goffi@goffi.org>
parents: 55
diff changeset
263 self.xmlui_parent = xmlui_parent
286
4772ba26623f xmlui: many improvments:
Goffi <goffi@goffi.org>
parents: 282
diff changeset
264 BoxLayout.__init__(self)
53
65775152aac1 xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents: 33
diff changeset
265
65775152aac1 xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents: 33
diff changeset
266 def _xmluiAppend(self, widget):
286
4772ba26623f xmlui: many improvments:
Goffi <goffi@goffi.org>
parents: 282
diff changeset
267 self.add_widget(widget)
53
65775152aac1 xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents: 33
diff changeset
268
65775152aac1 xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents: 33
diff changeset
269
65775152aac1 xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents: 33
diff changeset
270 class PairsContainer(xmlui.PairsContainer, GridLayout):
65775152aac1 xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents: 33
diff changeset
271
65775152aac1 xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents: 33
diff changeset
272 def __init__(self, xmlui_parent):
69
a9c6b089070d xmlui: improvments to prepare parameters:
Goffi <goffi@goffi.org>
parents: 55
diff changeset
273 self.xmlui_parent = xmlui_parent
53
65775152aac1 xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents: 33
diff changeset
274 GridLayout.__init__(self)
0
160cc95ad7ea initial commit:
Goffi <goffi@goffi.org>
parents:
diff changeset
275
160cc95ad7ea initial commit:
Goffi <goffi@goffi.org>
parents:
diff changeset
276 def _xmluiAppend(self, widget):
160cc95ad7ea initial commit:
Goffi <goffi@goffi.org>
parents:
diff changeset
277 self.add_widget(widget)
160cc95ad7ea initial commit:
Goffi <goffi@goffi.org>
parents:
diff changeset
278
160cc95ad7ea initial commit:
Goffi <goffi@goffi.org>
parents:
diff changeset
279
125
b6e6afb0dc46 xmlui: added LabelContainer and updated XMLUIPanel following changes in main class
Goffi <goffi@goffi.org>
parents: 99
diff changeset
280 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
281 pass
b6e6afb0dc46 xmlui: added LabelContainer and updated XMLUIPanel following changes in main class
Goffi <goffi@goffi.org>
parents: 99
diff changeset
282
b6e6afb0dc46 xmlui: added LabelContainer and updated XMLUIPanel following changes in main class
Goffi <goffi@goffi.org>
parents: 99
diff changeset
283
69
a9c6b089070d xmlui: improvments to prepare parameters:
Goffi <goffi@goffi.org>
parents: 55
diff changeset
284 class TabsPanelContainer(TabbedPanelItem):
241
661b9cf7b4e4 xmlui: scroll/size fixes:
Goffi <goffi@goffi.org>
parents: 236
diff changeset
285 layout = properties.ObjectProperty(None)
69
a9c6b089070d xmlui: improvments to prepare parameters:
Goffi <goffi@goffi.org>
parents: 55
diff changeset
286
a9c6b089070d xmlui: improvments to prepare parameters:
Goffi <goffi@goffi.org>
parents: 55
diff changeset
287 def _xmluiAppend(self, widget):
241
661b9cf7b4e4 xmlui: scroll/size fixes:
Goffi <goffi@goffi.org>
parents: 236
diff changeset
288 self.layout.add_widget(widget)
69
a9c6b089070d xmlui: improvments to prepare parameters:
Goffi <goffi@goffi.org>
parents: 55
diff changeset
289
a9c6b089070d xmlui: improvments to prepare parameters:
Goffi <goffi@goffi.org>
parents: 55
diff changeset
290
a9c6b089070d xmlui: improvments to prepare parameters:
Goffi <goffi@goffi.org>
parents: 55
diff changeset
291 class TabsContainer(xmlui.TabsContainer, TabbedPanel):
a9c6b089070d xmlui: improvments to prepare parameters:
Goffi <goffi@goffi.org>
parents: 55
diff changeset
292
a9c6b089070d xmlui: improvments to prepare parameters:
Goffi <goffi@goffi.org>
parents: 55
diff changeset
293 def __init__(self, xmlui_parent):
a9c6b089070d xmlui: improvments to prepare parameters:
Goffi <goffi@goffi.org>
parents: 55
diff changeset
294 self.xmlui_parent = xmlui_parent
a9c6b089070d xmlui: improvments to prepare parameters:
Goffi <goffi@goffi.org>
parents: 55
diff changeset
295 TabbedPanel.__init__(self, do_default_tab=False)
a9c6b089070d xmlui: improvments to prepare parameters:
Goffi <goffi@goffi.org>
parents: 55
diff changeset
296
a9c6b089070d xmlui: improvments to prepare parameters:
Goffi <goffi@goffi.org>
parents: 55
diff changeset
297 def _xmluiAddTab(self, label, selected):
a9c6b089070d xmlui: improvments to prepare parameters:
Goffi <goffi@goffi.org>
parents: 55
diff changeset
298 tab = TabsPanelContainer(text=label)
a9c6b089070d xmlui: improvments to prepare parameters:
Goffi <goffi@goffi.org>
parents: 55
diff changeset
299 self.add_widget(tab)
a9c6b089070d xmlui: improvments to prepare parameters:
Goffi <goffi@goffi.org>
parents: 55
diff changeset
300 return tab
a9c6b089070d xmlui: improvments to prepare parameters:
Goffi <goffi@goffi.org>
parents: 55
diff changeset
301
a9c6b089070d xmlui: improvments to prepare parameters:
Goffi <goffi@goffi.org>
parents: 55
diff changeset
302
286
4772ba26623f xmlui: many improvments:
Goffi <goffi@goffi.org>
parents: 282
diff changeset
303 class AdvancedListRow(BoxLayout):
53
65775152aac1 xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents: 33
diff changeset
304 global_index = 0
65775152aac1 xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents: 33
diff changeset
305 index = properties.ObjectProperty()
65775152aac1 xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents: 33
diff changeset
306 selected = properties.BooleanProperty(False)
65775152aac1 xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents: 33
diff changeset
307
65775152aac1 xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents: 33
diff changeset
308 def __init__(self, **kwargs):
65775152aac1 xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents: 33
diff changeset
309 self.global_index = AdvancedListRow.global_index
65775152aac1 xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents: 33
diff changeset
310 AdvancedListRow.global_index += 1
65775152aac1 xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents: 33
diff changeset
311 super(AdvancedListRow, self).__init__(**kwargs)
65775152aac1 xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents: 33
diff changeset
312
65775152aac1 xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents: 33
diff changeset
313 def on_touch_down(self, touch):
65775152aac1 xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents: 33
diff changeset
314 if self.collide_point(*touch.pos):
65775152aac1 xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents: 33
diff changeset
315 parent = self.parent
65775152aac1 xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents: 33
diff changeset
316 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
317 parent = parent.parent
65775152aac1 xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents: 33
diff changeset
318 if parent is None:
312
772c170b47a9 Python3 port:
Goffi <goffi@goffi.org>
parents: 305
diff changeset
319 log.error("Can't find parent AdvancedListContainer")
53
65775152aac1 xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents: 33
diff changeset
320 else:
65775152aac1 xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents: 33
diff changeset
321 if parent.selectable:
65775152aac1 xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents: 33
diff changeset
322 self.selected = parent._xmluiToggleSelected(self)
65775152aac1 xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents: 33
diff changeset
323
65775152aac1 xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents: 33
diff changeset
324 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
325
65775152aac1 xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents: 33
diff changeset
326
286
4772ba26623f xmlui: many improvments:
Goffi <goffi@goffi.org>
parents: 282
diff changeset
327 class AdvancedListContainer(xmlui.AdvancedListContainer, BoxLayout):
53
65775152aac1 xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents: 33
diff changeset
328
69
a9c6b089070d xmlui: improvments to prepare parameters:
Goffi <goffi@goffi.org>
parents: 55
diff changeset
329 def __init__(self, xmlui_parent, columns, selectable='no'):
a9c6b089070d xmlui: improvments to prepare parameters:
Goffi <goffi@goffi.org>
parents: 55
diff changeset
330 self.xmlui_parent = xmlui_parent
286
4772ba26623f xmlui: many improvments:
Goffi <goffi@goffi.org>
parents: 282
diff changeset
331 BoxLayout.__init__(self)
53
65775152aac1 xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents: 33
diff changeset
332 self._columns = columns
65775152aac1 xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents: 33
diff changeset
333 self.selectable = selectable != 'no'
65775152aac1 xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents: 33
diff changeset
334 self._current_row = None
65775152aac1 xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents: 33
diff changeset
335 self._selected = []
65775152aac1 xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents: 33
diff changeset
336 self._xmlui_select_cb = None
65775152aac1 xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents: 33
diff changeset
337
65775152aac1 xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents: 33
diff changeset
338 def _xmluiToggleSelected(self, row):
65775152aac1 xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents: 33
diff changeset
339 """inverse selection status of an AdvancedListRow
65775152aac1 xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents: 33
diff changeset
340
65775152aac1 xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents: 33
diff changeset
341 @param row(AdvancedListRow): row to (un)select
65775152aac1 xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents: 33
diff changeset
342 @return (bool): True if row is selected
65775152aac1 xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents: 33
diff changeset
343 """
65775152aac1 xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents: 33
diff changeset
344 try:
65775152aac1 xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents: 33
diff changeset
345 self._selected.remove(row)
65775152aac1 xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents: 33
diff changeset
346 except ValueError:
65775152aac1 xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents: 33
diff changeset
347 self._selected.append(row)
65775152aac1 xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents: 33
diff changeset
348 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
349 self._xmlui_select_cb(self)
65775152aac1 xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents: 33
diff changeset
350 return True
65775152aac1 xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents: 33
diff changeset
351 else:
65775152aac1 xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents: 33
diff changeset
352 return False
65775152aac1 xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents: 33
diff changeset
353
65775152aac1 xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents: 33
diff changeset
354 def _xmluiAppend(self, widget):
65775152aac1 xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents: 33
diff changeset
355 if self._current_row is None:
312
772c170b47a9 Python3 port:
Goffi <goffi@goffi.org>
parents: 305
diff changeset
356 log.error("No row set, ignoring append")
53
65775152aac1 xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents: 33
diff changeset
357 return
65775152aac1 xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents: 33
diff changeset
358 self._current_row.add_widget(widget)
65775152aac1 xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents: 33
diff changeset
359
65775152aac1 xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents: 33
diff changeset
360 def _xmluiAddRow(self, idx):
65775152aac1 xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents: 33
diff changeset
361 self._current_row = AdvancedListRow()
65775152aac1 xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents: 33
diff changeset
362 self._current_row.cols = self._columns
65775152aac1 xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents: 33
diff changeset
363 self._current_row.index = idx
65775152aac1 xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents: 33
diff changeset
364 self.add_widget(self._current_row)
65775152aac1 xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents: 33
diff changeset
365
65775152aac1 xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents: 33
diff changeset
366 def _xmluiGetSelectedWidgets(self):
65775152aac1 xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents: 33
diff changeset
367 return self._selected
65775152aac1 xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents: 33
diff changeset
368
65775152aac1 xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents: 33
diff changeset
369 def _xmluiGetSelectedIndex(self):
65775152aac1 xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents: 33
diff changeset
370 if not self._selected:
65775152aac1 xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents: 33
diff changeset
371 return None
65775152aac1 xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents: 33
diff changeset
372 return self._selected[0].index
65775152aac1 xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents: 33
diff changeset
373
65775152aac1 xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents: 33
diff changeset
374 def _xmluiOnSelect(self, callback):
65775152aac1 xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents: 33
diff changeset
375 """ Call callback with widget as only argument """
65775152aac1 xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents: 33
diff changeset
376 self._xmlui_select_cb = callback
65775152aac1 xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents: 33
diff changeset
377
286
4772ba26623f xmlui: many improvments:
Goffi <goffi@goffi.org>
parents: 282
diff changeset
378
29
8b5827c43155 notes first draft:
Goffi <goffi@goffi.org>
parents: 15
diff changeset
379 ## Dialogs ##
8b5827c43155 notes first draft:
Goffi <goffi@goffi.org>
parents: 15
diff changeset
380
8b5827c43155 notes first draft:
Goffi <goffi@goffi.org>
parents: 15
diff changeset
381
8b5827c43155 notes first draft:
Goffi <goffi@goffi.org>
parents: 15
diff changeset
382 class NoteDialog(xmlui.NoteDialog):
8b5827c43155 notes first draft:
Goffi <goffi@goffi.org>
parents: 15
diff changeset
383
8b5827c43155 notes first draft:
Goffi <goffi@goffi.org>
parents: 15
diff changeset
384 def __init__(self, _xmlui_parent, title, message, level):
8b5827c43155 notes first draft:
Goffi <goffi@goffi.org>
parents: 15
diff changeset
385 xmlui.NoteDialog.__init__(self, _xmlui_parent)
8b5827c43155 notes first draft:
Goffi <goffi@goffi.org>
parents: 15
diff changeset
386 self.title, self.message, self.level = title, message, level
8b5827c43155 notes first draft:
Goffi <goffi@goffi.org>
parents: 15
diff changeset
387
8b5827c43155 notes first draft:
Goffi <goffi@goffi.org>
parents: 15
diff changeset
388 def _xmluiShow(self):
8b5827c43155 notes first draft:
Goffi <goffi@goffi.org>
parents: 15
diff changeset
389 G.host.addNote(self.title, self.message, self.level)
8b5827c43155 notes first draft:
Goffi <goffi@goffi.org>
parents: 15
diff changeset
390
8b5827c43155 notes first draft:
Goffi <goffi@goffi.org>
parents: 15
diff changeset
391
243
50f7c000b4ae xmlui: implemented MessageDialog
Goffi <goffi@goffi.org>
parents: 241
diff changeset
392 class MessageDialog(xmlui.MessageDialog, dialog.MessageDialog):
50f7c000b4ae xmlui: implemented MessageDialog
Goffi <goffi@goffi.org>
parents: 241
diff changeset
393
50f7c000b4ae xmlui: implemented MessageDialog
Goffi <goffi@goffi.org>
parents: 241
diff changeset
394 def __init__(self, _xmlui_parent, title, message, level):
50f7c000b4ae xmlui: implemented MessageDialog
Goffi <goffi@goffi.org>
parents: 241
diff changeset
395 dialog.MessageDialog.__init__(self,
50f7c000b4ae xmlui: implemented MessageDialog
Goffi <goffi@goffi.org>
parents: 241
diff changeset
396 title=title,
50f7c000b4ae xmlui: implemented MessageDialog
Goffi <goffi@goffi.org>
parents: 241
diff changeset
397 message=message,
50f7c000b4ae xmlui: implemented MessageDialog
Goffi <goffi@goffi.org>
parents: 241
diff changeset
398 level=level,
50f7c000b4ae xmlui: implemented MessageDialog
Goffi <goffi@goffi.org>
parents: 241
diff changeset
399 close_cb = self.close_cb)
50f7c000b4ae xmlui: implemented MessageDialog
Goffi <goffi@goffi.org>
parents: 241
diff changeset
400 xmlui.MessageDialog.__init__(self, _xmlui_parent)
50f7c000b4ae xmlui: implemented MessageDialog
Goffi <goffi@goffi.org>
parents: 241
diff changeset
401
50f7c000b4ae xmlui: implemented MessageDialog
Goffi <goffi@goffi.org>
parents: 241
diff changeset
402 def close_cb(self):
50f7c000b4ae xmlui: implemented MessageDialog
Goffi <goffi@goffi.org>
parents: 241
diff changeset
403 self._xmluiClose()
50f7c000b4ae xmlui: implemented MessageDialog
Goffi <goffi@goffi.org>
parents: 241
diff changeset
404
50f7c000b4ae xmlui: implemented MessageDialog
Goffi <goffi@goffi.org>
parents: 241
diff changeset
405 def _xmluiShow(self):
50f7c000b4ae xmlui: implemented MessageDialog
Goffi <goffi@goffi.org>
parents: 241
diff changeset
406 G.host.addNotifUI(self)
50f7c000b4ae xmlui: implemented MessageDialog
Goffi <goffi@goffi.org>
parents: 241
diff changeset
407
305
b2727877bad4 remote: fixed workflow and size for XMLUI panel used with Ad-Hoc commands:
Goffi <goffi@goffi.org>
parents: 286
diff changeset
408 def _xmluiClose(self, reason=None):
243
50f7c000b4ae xmlui: implemented MessageDialog
Goffi <goffi@goffi.org>
parents: 241
diff changeset
409 G.host.closeUI()
50f7c000b4ae xmlui: implemented MessageDialog
Goffi <goffi@goffi.org>
parents: 241
diff changeset
410
50f7c000b4ae xmlui: implemented MessageDialog
Goffi <goffi@goffi.org>
parents: 241
diff changeset
411 def show(self, *args, **kwargs):
50f7c000b4ae xmlui: implemented MessageDialog
Goffi <goffi@goffi.org>
parents: 241
diff changeset
412 G.host.showUI(self)
50f7c000b4ae xmlui: implemented MessageDialog
Goffi <goffi@goffi.org>
parents: 241
diff changeset
413
50f7c000b4ae xmlui: implemented MessageDialog
Goffi <goffi@goffi.org>
parents: 241
diff changeset
414
204
37638765c97b xmlui: implemented ConfirmDialog using new dialog.ConfirmDialog
Goffi <goffi@goffi.org>
parents: 159
diff changeset
415 class ConfirmDialog(xmlui.ConfirmDialog, dialog.ConfirmDialog):
37638765c97b xmlui: implemented ConfirmDialog using new dialog.ConfirmDialog
Goffi <goffi@goffi.org>
parents: 159
diff changeset
416
37638765c97b xmlui: implemented ConfirmDialog using new dialog.ConfirmDialog
Goffi <goffi@goffi.org>
parents: 159
diff changeset
417 def __init__(self, _xmlui_parent, title, message, level, buttons_set):
343
7a171d11eab6 xmlui: fixed ConfirmDialog creation:
Goffi <goffi@goffi.org>
parents: 312
diff changeset
418 dialog.ConfirmDialog.__init__(self)
204
37638765c97b xmlui: implemented ConfirmDialog using new dialog.ConfirmDialog
Goffi <goffi@goffi.org>
parents: 159
diff changeset
419 xmlui.ConfirmDialog.__init__(self, _xmlui_parent)
343
7a171d11eab6 xmlui: fixed ConfirmDialog creation:
Goffi <goffi@goffi.org>
parents: 312
diff changeset
420 self.title=title
7a171d11eab6 xmlui: fixed ConfirmDialog creation:
Goffi <goffi@goffi.org>
parents: 312
diff changeset
421 self.message=message
7a171d11eab6 xmlui: fixed ConfirmDialog creation:
Goffi <goffi@goffi.org>
parents: 312
diff changeset
422 self.no_cb = self.no_cb
7a171d11eab6 xmlui: fixed ConfirmDialog creation:
Goffi <goffi@goffi.org>
parents: 312
diff changeset
423 self.yes_cb = self.yes_cb
204
37638765c97b xmlui: implemented ConfirmDialog using new dialog.ConfirmDialog
Goffi <goffi@goffi.org>
parents: 159
diff changeset
424
37638765c97b xmlui: implemented ConfirmDialog using new dialog.ConfirmDialog
Goffi <goffi@goffi.org>
parents: 159
diff changeset
425 def no_cb(self):
37638765c97b xmlui: implemented ConfirmDialog using new dialog.ConfirmDialog
Goffi <goffi@goffi.org>
parents: 159
diff changeset
426 G.host.closeUI()
37638765c97b xmlui: implemented ConfirmDialog using new dialog.ConfirmDialog
Goffi <goffi@goffi.org>
parents: 159
diff changeset
427 self._xmluiCancelled()
37638765c97b xmlui: implemented ConfirmDialog using new dialog.ConfirmDialog
Goffi <goffi@goffi.org>
parents: 159
diff changeset
428
37638765c97b xmlui: implemented ConfirmDialog using new dialog.ConfirmDialog
Goffi <goffi@goffi.org>
parents: 159
diff changeset
429 def yes_cb(self):
37638765c97b xmlui: implemented ConfirmDialog using new dialog.ConfirmDialog
Goffi <goffi@goffi.org>
parents: 159
diff changeset
430 G.host.closeUI()
37638765c97b xmlui: implemented ConfirmDialog using new dialog.ConfirmDialog
Goffi <goffi@goffi.org>
parents: 159
diff changeset
431 self._xmluiValidated()
37638765c97b xmlui: implemented ConfirmDialog using new dialog.ConfirmDialog
Goffi <goffi@goffi.org>
parents: 159
diff changeset
432
37638765c97b xmlui: implemented ConfirmDialog using new dialog.ConfirmDialog
Goffi <goffi@goffi.org>
parents: 159
diff changeset
433 def _xmluiShow(self):
37638765c97b xmlui: implemented ConfirmDialog using new dialog.ConfirmDialog
Goffi <goffi@goffi.org>
parents: 159
diff changeset
434 G.host.addNotifUI(self)
37638765c97b xmlui: implemented ConfirmDialog using new dialog.ConfirmDialog
Goffi <goffi@goffi.org>
parents: 159
diff changeset
435
305
b2727877bad4 remote: fixed workflow and size for XMLUI panel used with Ad-Hoc commands:
Goffi <goffi@goffi.org>
parents: 286
diff changeset
436 def _xmluiClose(self, reason=None):
204
37638765c97b xmlui: implemented ConfirmDialog using new dialog.ConfirmDialog
Goffi <goffi@goffi.org>
parents: 159
diff changeset
437 G.host.closeUI()
37638765c97b xmlui: implemented ConfirmDialog using new dialog.ConfirmDialog
Goffi <goffi@goffi.org>
parents: 159
diff changeset
438
37638765c97b xmlui: implemented ConfirmDialog using new dialog.ConfirmDialog
Goffi <goffi@goffi.org>
parents: 159
diff changeset
439 def show(self, *args, **kwargs):
37638765c97b xmlui: implemented ConfirmDialog using new dialog.ConfirmDialog
Goffi <goffi@goffi.org>
parents: 159
diff changeset
440 assert kwargs["force"]
37638765c97b xmlui: implemented ConfirmDialog using new dialog.ConfirmDialog
Goffi <goffi@goffi.org>
parents: 159
diff changeset
441 G.host.showUI(self)
37638765c97b xmlui: implemented ConfirmDialog using new dialog.ConfirmDialog
Goffi <goffi@goffi.org>
parents: 159
diff changeset
442
37638765c97b xmlui: implemented ConfirmDialog using new dialog.ConfirmDialog
Goffi <goffi@goffi.org>
parents: 159
diff changeset
443
99
f67b9baa81f0 xmlui: FileDialog first draft
Goffi <goffi@goffi.org>
parents: 76
diff changeset
444 class FileDialog(xmlui.FileDialog, BoxLayout):
f67b9baa81f0 xmlui: FileDialog first draft
Goffi <goffi@goffi.org>
parents: 76
diff changeset
445 message = properties.ObjectProperty()
f67b9baa81f0 xmlui: FileDialog first draft
Goffi <goffi@goffi.org>
parents: 76
diff changeset
446
f67b9baa81f0 xmlui: FileDialog first draft
Goffi <goffi@goffi.org>
parents: 76
diff changeset
447 def __init__(self, _xmlui_parent, title, message, level, filetype):
f67b9baa81f0 xmlui: FileDialog first draft
Goffi <goffi@goffi.org>
parents: 76
diff changeset
448 xmlui.FileDialog.__init__(self, _xmlui_parent)
f67b9baa81f0 xmlui: FileDialog first draft
Goffi <goffi@goffi.org>
parents: 76
diff changeset
449 BoxLayout.__init__(self)
f67b9baa81f0 xmlui: FileDialog first draft
Goffi <goffi@goffi.org>
parents: 76
diff changeset
450 self.message.text = message
f67b9baa81f0 xmlui: FileDialog first draft
Goffi <goffi@goffi.org>
parents: 76
diff changeset
451 if filetype == C.XMLUI_DATA_FILETYPE_DIR:
f67b9baa81f0 xmlui: FileDialog first draft
Goffi <goffi@goffi.org>
parents: 76
diff changeset
452 self.file_chooser.dirselect = True
f67b9baa81f0 xmlui: FileDialog first draft
Goffi <goffi@goffi.org>
parents: 76
diff changeset
453
f67b9baa81f0 xmlui: FileDialog first draft
Goffi <goffi@goffi.org>
parents: 76
diff changeset
454 def _xmluiShow(self):
f67b9baa81f0 xmlui: FileDialog first draft
Goffi <goffi@goffi.org>
parents: 76
diff changeset
455 G.host.addNotifUI(self)
f67b9baa81f0 xmlui: FileDialog first draft
Goffi <goffi@goffi.org>
parents: 76
diff changeset
456
305
b2727877bad4 remote: fixed workflow and size for XMLUI panel used with Ad-Hoc commands:
Goffi <goffi@goffi.org>
parents: 286
diff changeset
457 def _xmluiClose(self, reason=None):
99
f67b9baa81f0 xmlui: FileDialog first draft
Goffi <goffi@goffi.org>
parents: 76
diff changeset
458 # FIXME: notif UI is not removed if dialog is not shown yet
f67b9baa81f0 xmlui: FileDialog first draft
Goffi <goffi@goffi.org>
parents: 76
diff changeset
459 G.host.closeUI()
f67b9baa81f0 xmlui: FileDialog first draft
Goffi <goffi@goffi.org>
parents: 76
diff changeset
460
f67b9baa81f0 xmlui: FileDialog first draft
Goffi <goffi@goffi.org>
parents: 76
diff changeset
461 def onSelect(self, path):
f67b9baa81f0 xmlui: FileDialog first draft
Goffi <goffi@goffi.org>
parents: 76
diff changeset
462 try:
f67b9baa81f0 xmlui: FileDialog first draft
Goffi <goffi@goffi.org>
parents: 76
diff changeset
463 path = path[0]
f67b9baa81f0 xmlui: FileDialog first draft
Goffi <goffi@goffi.org>
parents: 76
diff changeset
464 except IndexError:
f67b9baa81f0 xmlui: FileDialog first draft
Goffi <goffi@goffi.org>
parents: 76
diff changeset
465 path = None
f67b9baa81f0 xmlui: FileDialog first draft
Goffi <goffi@goffi.org>
parents: 76
diff changeset
466 if not path:
f67b9baa81f0 xmlui: FileDialog first draft
Goffi <goffi@goffi.org>
parents: 76
diff changeset
467 self._xmluiCancelled()
f67b9baa81f0 xmlui: FileDialog first draft
Goffi <goffi@goffi.org>
parents: 76
diff changeset
468 else:
f67b9baa81f0 xmlui: FileDialog first draft
Goffi <goffi@goffi.org>
parents: 76
diff changeset
469 self._xmluiValidated({'path': path})
f67b9baa81f0 xmlui: FileDialog first draft
Goffi <goffi@goffi.org>
parents: 76
diff changeset
470
f67b9baa81f0 xmlui: FileDialog first draft
Goffi <goffi@goffi.org>
parents: 76
diff changeset
471 def show(self, *args, **kwargs):
f67b9baa81f0 xmlui: FileDialog first draft
Goffi <goffi@goffi.org>
parents: 76
diff changeset
472 assert kwargs["force"]
f67b9baa81f0 xmlui: FileDialog first draft
Goffi <goffi@goffi.org>
parents: 76
diff changeset
473 G.host.showUI(self)
f67b9baa81f0 xmlui: FileDialog first draft
Goffi <goffi@goffi.org>
parents: 76
diff changeset
474
f67b9baa81f0 xmlui: FileDialog first draft
Goffi <goffi@goffi.org>
parents: 76
diff changeset
475
29
8b5827c43155 notes first draft:
Goffi <goffi@goffi.org>
parents: 15
diff changeset
476 ## Factory ##
8b5827c43155 notes first draft:
Goffi <goffi@goffi.org>
parents: 15
diff changeset
477
8b5827c43155 notes first draft:
Goffi <goffi@goffi.org>
parents: 15
diff changeset
478
0
160cc95ad7ea initial commit:
Goffi <goffi@goffi.org>
parents:
diff changeset
479 class WidgetFactory(object):
160cc95ad7ea initial commit:
Goffi <goffi@goffi.org>
parents:
diff changeset
480
160cc95ad7ea initial commit:
Goffi <goffi@goffi.org>
parents:
diff changeset
481 def __getattr__(self, attr):
160cc95ad7ea initial commit:
Goffi <goffi@goffi.org>
parents:
diff changeset
482 if attr.startswith("create"):
160cc95ad7ea initial commit:
Goffi <goffi@goffi.org>
parents:
diff changeset
483 cls = globals()[attr[6:]]
160cc95ad7ea initial commit:
Goffi <goffi@goffi.org>
parents:
diff changeset
484 return cls
160cc95ad7ea initial commit:
Goffi <goffi@goffi.org>
parents:
diff changeset
485
160cc95ad7ea initial commit:
Goffi <goffi@goffi.org>
parents:
diff changeset
486
29
8b5827c43155 notes first draft:
Goffi <goffi@goffi.org>
parents: 15
diff changeset
487 ## Core ##
8b5827c43155 notes first draft:
Goffi <goffi@goffi.org>
parents: 15
diff changeset
488
8b5827c43155 notes first draft:
Goffi <goffi@goffi.org>
parents: 15
diff changeset
489
0
160cc95ad7ea initial commit:
Goffi <goffi@goffi.org>
parents:
diff changeset
490 class Title(Label):
160cc95ad7ea initial commit:
Goffi <goffi@goffi.org>
parents:
diff changeset
491
160cc95ad7ea initial commit:
Goffi <goffi@goffi.org>
parents:
diff changeset
492 def __init__(self, *args, **kwargs):
160cc95ad7ea initial commit:
Goffi <goffi@goffi.org>
parents:
diff changeset
493 kwargs['size'] = (100, 25)
160cc95ad7ea initial commit:
Goffi <goffi@goffi.org>
parents:
diff changeset
494 kwargs['size_hint'] = (1,None)
160cc95ad7ea initial commit:
Goffi <goffi@goffi.org>
parents:
diff changeset
495 super(Title, self).__init__(*args, **kwargs)
160cc95ad7ea initial commit:
Goffi <goffi@goffi.org>
parents:
diff changeset
496
160cc95ad7ea initial commit:
Goffi <goffi@goffi.org>
parents:
diff changeset
497
53
65775152aac1 xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents: 33
diff changeset
498 class FormButton(Button):
65775152aac1 xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents: 33
diff changeset
499 pass
65775152aac1 xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents: 33
diff changeset
500
286
4772ba26623f xmlui: many improvments:
Goffi <goffi@goffi.org>
parents: 282
diff changeset
501 class SubmitButton(FormButton):
4772ba26623f xmlui: many improvments:
Goffi <goffi@goffi.org>
parents: 282
diff changeset
502 pass
53
65775152aac1 xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents: 33
diff changeset
503
286
4772ba26623f xmlui: many improvments:
Goffi <goffi@goffi.org>
parents: 282
diff changeset
504 class CancelButton(FormButton):
4772ba26623f xmlui: many improvments:
Goffi <goffi@goffi.org>
parents: 282
diff changeset
505 pass
4772ba26623f xmlui: many improvments:
Goffi <goffi@goffi.org>
parents: 282
diff changeset
506
4772ba26623f xmlui: many improvments:
Goffi <goffi@goffi.org>
parents: 282
diff changeset
507 class SaveButton(FormButton):
4772ba26623f xmlui: many improvments:
Goffi <goffi@goffi.org>
parents: 282
diff changeset
508 pass
4772ba26623f xmlui: many improvments:
Goffi <goffi@goffi.org>
parents: 282
diff changeset
509
4772ba26623f xmlui: many improvments:
Goffi <goffi@goffi.org>
parents: 282
diff changeset
510
4772ba26623f xmlui: many improvments:
Goffi <goffi@goffi.org>
parents: 282
diff changeset
511 class XMLUIPanel(xmlui.XMLUIPanel, ScrollView):
0
160cc95ad7ea initial commit:
Goffi <goffi@goffi.org>
parents:
diff changeset
512 widget_factory = WidgetFactory()
286
4772ba26623f xmlui: many improvments:
Goffi <goffi@goffi.org>
parents: 282
diff changeset
513 layout = properties.ObjectProperty()
0
160cc95ad7ea initial commit:
Goffi <goffi@goffi.org>
parents:
diff changeset
514
243
50f7c000b4ae xmlui: implemented MessageDialog
Goffi <goffi@goffi.org>
parents: 241
diff changeset
515 def __init__(self, host, parsed_xml, title=None, flags=None, callback=None,
50f7c000b4ae xmlui: implemented MessageDialog
Goffi <goffi@goffi.org>
parents: 241
diff changeset
516 ignore=None, whitelist=None, profile=C.PROF_KEY_NONE):
286
4772ba26623f xmlui: many improvments:
Goffi <goffi@goffi.org>
parents: 282
diff changeset
517 ScrollView.__init__(self)
0
160cc95ad7ea initial commit:
Goffi <goffi@goffi.org>
parents:
diff changeset
518 self.close_cb = None
69
a9c6b089070d xmlui: improvments to prepare parameters:
Goffi <goffi@goffi.org>
parents: 55
diff changeset
519 self._post_treats = [] # list of callback to call after UI is constructed
286
4772ba26623f xmlui: many improvments:
Goffi <goffi@goffi.org>
parents: 282
diff changeset
520
4772ba26623f xmlui: many improvments:
Goffi <goffi@goffi.org>
parents: 282
diff changeset
521 # used to workaround touch issues when a ScrollView is used inside this
4772ba26623f xmlui: many improvments:
Goffi <goffi@goffi.org>
parents: 282
diff changeset
522 # one. This happens notably when a TabsContainer is used as main container
4772ba26623f xmlui: many improvments:
Goffi <goffi@goffi.org>
parents: 282
diff changeset
523 # (this is the case with settings).
4772ba26623f xmlui: many improvments:
Goffi <goffi@goffi.org>
parents: 282
diff changeset
524 self._skip_scroll_events = False
125
b6e6afb0dc46 xmlui: added LabelContainer and updated XMLUIPanel following changes in main class
Goffi <goffi@goffi.org>
parents: 99
diff changeset
525 xmlui.XMLUIPanel.__init__(self,
b6e6afb0dc46 xmlui: added LabelContainer and updated XMLUIPanel following changes in main class
Goffi <goffi@goffi.org>
parents: 99
diff changeset
526 host,
b6e6afb0dc46 xmlui: added LabelContainer and updated XMLUIPanel following changes in main class
Goffi <goffi@goffi.org>
parents: 99
diff changeset
527 parsed_xml,
b6e6afb0dc46 xmlui: added LabelContainer and updated XMLUIPanel following changes in main class
Goffi <goffi@goffi.org>
parents: 99
diff changeset
528 title=title,
b6e6afb0dc46 xmlui: added LabelContainer and updated XMLUIPanel following changes in main class
Goffi <goffi@goffi.org>
parents: 99
diff changeset
529 flags=flags,
b6e6afb0dc46 xmlui: added LabelContainer and updated XMLUIPanel following changes in main class
Goffi <goffi@goffi.org>
parents: 99
diff changeset
530 callback=callback,
b6e6afb0dc46 xmlui: added LabelContainer and updated XMLUIPanel following changes in main class
Goffi <goffi@goffi.org>
parents: 99
diff changeset
531 ignore=ignore,
129
0704f3be65cb xmlui: fixed missing whitelist argument
Goffi <goffi@goffi.org>
parents: 126
diff changeset
532 whitelist=whitelist,
125
b6e6afb0dc46 xmlui: added LabelContainer and updated XMLUIPanel following changes in main class
Goffi <goffi@goffi.org>
parents: 99
diff changeset
533 profile=profile)
286
4772ba26623f xmlui: many improvments:
Goffi <goffi@goffi.org>
parents: 282
diff changeset
534 self.bind(height=self.onHeight)
4772ba26623f xmlui: many improvments:
Goffi <goffi@goffi.org>
parents: 282
diff changeset
535
4772ba26623f xmlui: many improvments:
Goffi <goffi@goffi.org>
parents: 282
diff changeset
536 def on_touch_down(self, touch, after=False):
4772ba26623f xmlui: many improvments:
Goffi <goffi@goffi.org>
parents: 282
diff changeset
537 if self._skip_scroll_events:
4772ba26623f xmlui: many improvments:
Goffi <goffi@goffi.org>
parents: 282
diff changeset
538 return super(ScrollView, self).on_touch_down(touch)
4772ba26623f xmlui: many improvments:
Goffi <goffi@goffi.org>
parents: 282
diff changeset
539 else:
4772ba26623f xmlui: many improvments:
Goffi <goffi@goffi.org>
parents: 282
diff changeset
540 return super(XMLUIPanel, self).on_touch_down(touch)
4772ba26623f xmlui: many improvments:
Goffi <goffi@goffi.org>
parents: 282
diff changeset
541
4772ba26623f xmlui: many improvments:
Goffi <goffi@goffi.org>
parents: 282
diff changeset
542 def on_touch_up(self, touch, after=False):
4772ba26623f xmlui: many improvments:
Goffi <goffi@goffi.org>
parents: 282
diff changeset
543 if self._skip_scroll_events:
4772ba26623f xmlui: many improvments:
Goffi <goffi@goffi.org>
parents: 282
diff changeset
544 return super(ScrollView, self).on_touch_up(touch)
4772ba26623f xmlui: many improvments:
Goffi <goffi@goffi.org>
parents: 282
diff changeset
545 else:
4772ba26623f xmlui: many improvments:
Goffi <goffi@goffi.org>
parents: 282
diff changeset
546 return super(XMLUIPanel, self).on_touch_up(touch)
4772ba26623f xmlui: many improvments:
Goffi <goffi@goffi.org>
parents: 282
diff changeset
547
4772ba26623f xmlui: many improvments:
Goffi <goffi@goffi.org>
parents: 282
diff changeset
548 def on_touch_move(self, touch, after=False):
4772ba26623f xmlui: many improvments:
Goffi <goffi@goffi.org>
parents: 282
diff changeset
549 if self._skip_scroll_events:
4772ba26623f xmlui: many improvments:
Goffi <goffi@goffi.org>
parents: 282
diff changeset
550 return super(ScrollView, self).on_touch_move(touch)
4772ba26623f xmlui: many improvments:
Goffi <goffi@goffi.org>
parents: 282
diff changeset
551 else:
4772ba26623f xmlui: many improvments:
Goffi <goffi@goffi.org>
parents: 282
diff changeset
552 return super(XMLUIPanel, self).on_touch_move(touch)
0
160cc95ad7ea initial commit:
Goffi <goffi@goffi.org>
parents:
diff changeset
553
160cc95ad7ea initial commit:
Goffi <goffi@goffi.org>
parents:
diff changeset
554 def setCloseCb(self, close_cb):
160cc95ad7ea initial commit:
Goffi <goffi@goffi.org>
parents:
diff changeset
555 self.close_cb = close_cb
160cc95ad7ea initial commit:
Goffi <goffi@goffi.org>
parents:
diff changeset
556
305
b2727877bad4 remote: fixed workflow and size for XMLUI panel used with Ad-Hoc commands:
Goffi <goffi@goffi.org>
parents: 286
diff changeset
557 def _xmluiClose(self, __=None, reason=None):
0
160cc95ad7ea initial commit:
Goffi <goffi@goffi.org>
parents:
diff changeset
558 if self.close_cb is not None:
305
b2727877bad4 remote: fixed workflow and size for XMLUI panel used with Ad-Hoc commands:
Goffi <goffi@goffi.org>
parents: 286
diff changeset
559 self.close_cb(self, reason)
0
160cc95ad7ea initial commit:
Goffi <goffi@goffi.org>
parents:
diff changeset
560 else:
33
c21d1be2e54c core: XMLUI notifications coming from backend are handled:
Goffi <goffi@goffi.org>
parents: 29
diff changeset
561 G.host.closeUI()
0
160cc95ad7ea initial commit:
Goffi <goffi@goffi.org>
parents:
diff changeset
562
71
8c9fe2c5aacc settings: save button is now disabled when there is nothing to save
Goffi <goffi@goffi.org>
parents: 69
diff changeset
563 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
564 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
565 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
566
69
a9c6b089070d xmlui: improvments to prepare parameters:
Goffi <goffi@goffi.org>
parents: 55
diff changeset
567 def addPostTreat(self, callback):
a9c6b089070d xmlui: improvments to prepare parameters:
Goffi <goffi@goffi.org>
parents: 55
diff changeset
568 self._post_treats.append(callback)
a9c6b089070d xmlui: improvments to prepare parameters:
Goffi <goffi@goffi.org>
parents: 55
diff changeset
569
a9c6b089070d xmlui: improvments to prepare parameters:
Goffi <goffi@goffi.org>
parents: 55
diff changeset
570 def _postTreatCb(self):
a9c6b089070d xmlui: improvments to prepare parameters:
Goffi <goffi@goffi.org>
parents: 55
diff changeset
571 for cb in self._post_treats:
a9c6b089070d xmlui: improvments to prepare parameters:
Goffi <goffi@goffi.org>
parents: 55
diff changeset
572 cb()
a9c6b089070d xmlui: improvments to prepare parameters:
Goffi <goffi@goffi.org>
parents: 55
diff changeset
573 del self._post_treats
a9c6b089070d xmlui: improvments to prepare parameters:
Goffi <goffi@goffi.org>
parents: 55
diff changeset
574
71
8c9fe2c5aacc settings: save button is now disabled when there is nothing to save
Goffi <goffi@goffi.org>
parents: 69
diff changeset
575 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
576 button.disabled = True
8c9fe2c5aacc settings: save button is now disabled when there is nothing to save
Goffi <goffi@goffi.org>
parents: 69
diff changeset
577 self.onSaveParams(button)
8c9fe2c5aacc settings: save button is now disabled when there is nothing to save
Goffi <goffi@goffi.org>
parents: 69
diff changeset
578
0
160cc95ad7ea initial commit:
Goffi <goffi@goffi.org>
parents:
diff changeset
579 def constructUI(self, parsed_dom):
69
a9c6b089070d xmlui: improvments to prepare parameters:
Goffi <goffi@goffi.org>
parents: 55
diff changeset
580 xmlui.XMLUIPanel.constructUI(self, parsed_dom, self._postTreatCb)
0
160cc95ad7ea initial commit:
Goffi <goffi@goffi.org>
parents:
diff changeset
581 if self.xmlui_title:
286
4772ba26623f xmlui: many improvments:
Goffi <goffi@goffi.org>
parents: 282
diff changeset
582 self.layout.add_widget(Title(text=self.xmlui_title))
4772ba26623f xmlui: many improvments:
Goffi <goffi@goffi.org>
parents: 282
diff changeset
583 if isinstance(self.main_cont, TabsContainer):
4772ba26623f xmlui: many improvments:
Goffi <goffi@goffi.org>
parents: 282
diff changeset
584 # cf. comments above
4772ba26623f xmlui: many improvments:
Goffi <goffi@goffi.org>
parents: 282
diff changeset
585 self._skip_scroll_events = True
4772ba26623f xmlui: many improvments:
Goffi <goffi@goffi.org>
parents: 282
diff changeset
586 self.layout.add_widget(self.main_cont)
0
160cc95ad7ea initial commit:
Goffi <goffi@goffi.org>
parents:
diff changeset
587 if self.type == 'form':
286
4772ba26623f xmlui: many improvments:
Goffi <goffi@goffi.org>
parents: 282
diff changeset
588 submit_btn = SubmitButton()
0
160cc95ad7ea initial commit:
Goffi <goffi@goffi.org>
parents:
diff changeset
589 submit_btn.bind(on_press=self.onFormSubmitted)
286
4772ba26623f xmlui: many improvments:
Goffi <goffi@goffi.org>
parents: 282
diff changeset
590 self.layout.add_widget(submit_btn)
0
160cc95ad7ea initial commit:
Goffi <goffi@goffi.org>
parents:
diff changeset
591 if not 'NO_CANCEL' in self.flags:
312
772c170b47a9 Python3 port:
Goffi <goffi@goffi.org>
parents: 305
diff changeset
592 cancel_btn = CancelButton(text=_("Cancel"))
0
160cc95ad7ea initial commit:
Goffi <goffi@goffi.org>
parents:
diff changeset
593 cancel_btn.bind(on_press=self.onFormCancelled)
286
4772ba26623f xmlui: many improvments:
Goffi <goffi@goffi.org>
parents: 282
diff changeset
594 self.layout.add_widget(cancel_btn)
69
a9c6b089070d xmlui: improvments to prepare parameters:
Goffi <goffi@goffi.org>
parents: 55
diff changeset
595 elif self.type == 'param':
312
772c170b47a9 Python3 port:
Goffi <goffi@goffi.org>
parents: 305
diff changeset
596 self.save_btn = SaveButton(text=_("Save"), disabled=True)
71
8c9fe2c5aacc settings: save button is now disabled when there is nothing to save
Goffi <goffi@goffi.org>
parents: 69
diff changeset
597 self.save_btn.bind(on_press=self._saveButtonCb)
286
4772ba26623f xmlui: many improvments:
Goffi <goffi@goffi.org>
parents: 282
diff changeset
598 self.layout.add_widget(self.save_btn)
4772ba26623f xmlui: many improvments:
Goffi <goffi@goffi.org>
parents: 282
diff changeset
599 elif self.type == 'window':
312
772c170b47a9 Python3 port:
Goffi <goffi@goffi.org>
parents: 305
diff changeset
600 cancel_btn = CancelButton(text=_("Cancel"))
305
b2727877bad4 remote: fixed workflow and size for XMLUI panel used with Ad-Hoc commands:
Goffi <goffi@goffi.org>
parents: 286
diff changeset
601 cancel_btn.bind(
b2727877bad4 remote: fixed workflow and size for XMLUI panel used with Ad-Hoc commands:
Goffi <goffi@goffi.org>
parents: 286
diff changeset
602 on_press=partial(self._xmluiClose, reason=C.XMLUI_DATA_CANCELLED))
286
4772ba26623f xmlui: many improvments:
Goffi <goffi@goffi.org>
parents: 282
diff changeset
603 self.layout.add_widget(cancel_btn)
4772ba26623f xmlui: many improvments:
Goffi <goffi@goffi.org>
parents: 282
diff changeset
604
4772ba26623f xmlui: many improvments:
Goffi <goffi@goffi.org>
parents: 282
diff changeset
605 def onHeight(self, __, height):
4772ba26623f xmlui: many improvments:
Goffi <goffi@goffi.org>
parents: 282
diff changeset
606 if isinstance(self.main_cont, TabsContainer):
4772ba26623f xmlui: many improvments:
Goffi <goffi@goffi.org>
parents: 282
diff changeset
607 other_children_height = sum([c.height for c in self.layout.children
4772ba26623f xmlui: many improvments:
Goffi <goffi@goffi.org>
parents: 282
diff changeset
608 if c is not self.main_cont])
4772ba26623f xmlui: many improvments:
Goffi <goffi@goffi.org>
parents: 282
diff changeset
609 self.main_cont.height = height - other_children_height
0
160cc95ad7ea initial commit:
Goffi <goffi@goffi.org>
parents:
diff changeset
610
33
c21d1be2e54c core: XMLUI notifications coming from backend are handled:
Goffi <goffi@goffi.org>
parents: 29
diff changeset
611 def show(self, *args, **kwargs):
c21d1be2e54c core: XMLUI notifications coming from backend are handled:
Goffi <goffi@goffi.org>
parents: 29
diff changeset
612 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
613 G.host.addNotifUI(self)
c21d1be2e54c core: XMLUI notifications coming from backend are handled:
Goffi <goffi@goffi.org>
parents: 29
diff changeset
614 else:
c21d1be2e54c core: XMLUI notifications coming from backend are handled:
Goffi <goffi@goffi.org>
parents: 29
diff changeset
615 G.host.showUI(self)
c21d1be2e54c core: XMLUI notifications coming from backend are handled:
Goffi <goffi@goffi.org>
parents: 29
diff changeset
616
0
160cc95ad7ea initial commit:
Goffi <goffi@goffi.org>
parents:
diff changeset
617
29
8b5827c43155 notes first draft:
Goffi <goffi@goffi.org>
parents: 15
diff changeset
618 class XMLUIDialog(xmlui.XMLUIDialog):
8b5827c43155 notes first draft:
Goffi <goffi@goffi.org>
parents: 15
diff changeset
619 dialog_factory = WidgetFactory()
8b5827c43155 notes first draft:
Goffi <goffi@goffi.org>
parents: 15
diff changeset
620
8b5827c43155 notes first draft:
Goffi <goffi@goffi.org>
parents: 15
diff changeset
621
235
525527a01439 xmlui: use create with partial and class_map, following change in base class
Goffi <goffi@goffi.org>
parents: 227
diff changeset
622 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
623 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
624 xmlui.CLASS_DIALOG: XMLUIDialog})