aboutsummaryrefslogtreecommitdiffstats
path: root/tagit
diff options
context:
space:
mode:
authorMatthias Baumgartner <dev@igsor.net>2023-01-13 10:38:21 +0100
committerMatthias Baumgartner <dev@igsor.net>2023-01-13 10:38:21 +0100
commitf59878447c8367b50fe3eebefb80484b2a380394 (patch)
tree04cf85b803fb20d51ce4006066884661eb6801ae /tagit
parent17a0fbed3d4aaa2371c822a376ab06f0bc78e3fd (diff)
downloadtagit-f59878447c8367b50fe3eebefb80484b2a380394.tar.gz
tagit-f59878447c8367b50fe3eebefb80484b2a380394.tar.bz2
tagit-f59878447c8367b50fe3eebefb80484b2a380394.zip
status dialogues port: numeric input and console
Diffstat (limited to 'tagit')
-rw-r--r--tagit/dialogues/__init__.py8
-rw-r--r--tagit/dialogues/console.kv30
-rw-r--r--tagit/dialogues/console.py37
-rw-r--r--tagit/dialogues/numeric_input.py72
4 files changed, 143 insertions, 4 deletions
diff --git a/tagit/dialogues/__init__.py b/tagit/dialogues/__init__.py
index d7792cb..f63ec87 100644
--- a/tagit/dialogues/__init__.py
+++ b/tagit/dialogues/__init__.py
@@ -19,7 +19,7 @@ import typing
# inner-module imports
##from .spash import Splash
from .autoinput import AutoTextInput
-#from .console import Console
+from .console import Console
#from .dir_creator import DirCreator
#from .dir_picker import DirPicker
from .error import Error
@@ -27,7 +27,7 @@ from .error import Error
#from .file_creator import FileCreator
#from .file_picker import FilePicker
#from .message import Message
-#from .numeric_input import NumericInput
+from .numeric_input import NumericInput
#from .path_creator import PathCreator
#from .path_picker import PathPicker
#from .progress import Progress
@@ -38,7 +38,7 @@ from .stoken import TokenEdit
# exports
__all__: typing.Sequence[str] = (
- #'Console',
+ 'Console',
#'DirCreator',
#'DirPicker',
'Error',
@@ -46,7 +46,7 @@ __all__: typing.Sequence[str] = (
#'FileCreator',
#'FilePicker',
#'Message',
- #'NumericInput',
+ 'NumericInput',
#'PathCreator',
#'PathPicker',
#'Progress',
diff --git a/tagit/dialogues/console.kv b/tagit/dialogues/console.kv
new file mode 100644
index 0000000..b68227d
--- /dev/null
+++ b/tagit/dialogues/console.kv
@@ -0,0 +1,30 @@
+
+<Console>:
+ text: ''
+ title: 'tagit log console'
+ ok_on_enter: False
+ init_at_bottom: True
+
+ DialogueContentTitle:
+ title: root.title
+ size_hint_y: 0.6
+
+ ScrollView:
+ scroll_y: 0 if root.init_at_bottom else 1
+
+ Label:
+ text: root.text
+ size_hint_y: None
+ height: self.texture_size[1]
+ text_size: self.width, None
+ bold: True
+ font_name: resource_find('DejaVuSansMono.ttf') # monospace font
+ markup: True
+ multiline: True
+ halign: 'left'
+
+ DialogueButtons_One:
+ ok_text: "close"
+ # FIXME: Inform that this action will not terminate the underlying process
+
+## EOF ##
diff --git a/tagit/dialogues/console.py b/tagit/dialogues/console.py
new file mode 100644
index 0000000..282b378
--- /dev/null
+++ b/tagit/dialogues/console.py
@@ -0,0 +1,37 @@
+"""
+
+Part of the tagit module.
+A copy of the license is provided with the project.
+Author: Matthias Baumgartner, 2022
+"""
+# standard imports
+import os
+
+# kivy imports
+from kivy.clock import mainthread
+from kivy.lang import Builder
+import kivy.properties as kp
+
+# inner-module imports
+from .dialogue import Dialogue
+
+# exports
+__all__ = ('Console', )
+
+
+## code ##
+
+# load kv
+Builder.load_file(os.path.join(os.path.dirname(__file__), 'console.kv'))
+
+# classes
+class Console(Dialogue):
+ """Dialogue with console output."""
+
+ text = kp.StringProperty('')
+
+ @mainthread
+ def update(self, sender, text):
+ self.text = '\n'.join(text)
+
+## EOF ##
diff --git a/tagit/dialogues/numeric_input.py b/tagit/dialogues/numeric_input.py
new file mode 100644
index 0000000..63491d2
--- /dev/null
+++ b/tagit/dialogues/numeric_input.py
@@ -0,0 +1,72 @@
+"""Dialogue with a slider.
+
+Part of the tagit module.
+A copy of the license is provided with the project.
+Author: Matthias Baumgartner, 2022
+"""
+# kivy imports
+from kivy.lang import Builder
+import kivy.properties as kp
+
+# inner-module imports
+from .dialogue import Dialogue
+
+# exports
+__all__ = ('NumericInput', )
+
+
+## code ##
+
+# load kv
+Builder.load_string('''
+
+<NumericInput>:
+ value: int(slider.value)
+ init_value: 0
+
+ DialogueContentNoTitle:
+
+ BoxLayout:
+ orientation: 'horizontal'
+ size_hint_y: None
+ height: 50
+
+ Label:
+ text: str(root.lo)
+ size_hint_x: None
+ width: self.texture_size[0]
+
+ Slider:
+ id: slider
+ orientation: 'horizontal'
+ min: root.lo
+ max: root.hi
+ step: 1
+ value: root.init_value
+
+ Label:
+ text: str(root.hi)
+ size_hint_x: None
+ width: self.texture_size[0]
+
+ Label:
+ text: str(root.value)
+ size_hint: 1, None
+ height: self.texture_size[1]
+ halign: 'center'
+
+ DialogueButtons_Two:
+
+''')
+
+# classes
+class NumericInput(Dialogue):
+ """Dialogue with a slider."""
+
+ lo = kp.NumericProperty(0)
+ hi = kp.NumericProperty(100)
+ value = kp.NumericProperty(0)
+ init_value = kp.NumericProperty(0)
+
+
+## EOF ##