xemonity 5.0__tar.gz → 6.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {xemonity-5.0 → xemonity-6.0}/LICENSE +21 -21
- {xemonity-5.0 → xemonity-6.0}/PKG-INFO +36 -36
- {xemonity-5.0 → xemonity-6.0}/README.md +9 -9
- {xemonity-5.0 → xemonity-6.0}/Xemonity/__init__.py +5 -5
- {xemonity-5.0 → xemonity-6.0}/Xemonity/classes.py +248 -208
- {xemonity-5.0 → xemonity-6.0}/Xemonity/methods.py +78 -65
- {xemonity-5.0 → xemonity-6.0}/pyproject.toml +2 -2
- {xemonity-5.0 → xemonity-6.0}/setup.cfg +4 -4
- {xemonity-5.0 → xemonity-6.0}/setup.py +29 -29
- {xemonity-5.0 → xemonity-6.0}/xemonity.egg-info/PKG-INFO +36 -36
- {xemonity-5.0 → xemonity-6.0}/xemonity.egg-info/SOURCES.txt +0 -0
- {xemonity-5.0 → xemonity-6.0}/xemonity.egg-info/dependency_links.txt +0 -0
- {xemonity-5.0 → xemonity-6.0}/xemonity.egg-info/top_level.txt +0 -0
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2026 murzik_kukushnik(PyPI)
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 murzik_kukushnik(PyPI)
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -1,36 +1,36 @@
|
|
|
1
|
-
Metadata-Version: 2.2
|
|
2
|
-
Name: xemonity
|
|
3
|
-
Version:
|
|
4
|
-
Summary: Libraly for simple terminal ui
|
|
5
|
-
Home-page: https://github.com/MurzikYEET/Xemonity
|
|
6
|
-
Author: murzik_kukushnik
|
|
7
|
-
Author-email: siniykoshara@gmail.com
|
|
8
|
-
Project-URL: GitHub, https://github.com/MurzikYEET/Xemonity
|
|
9
|
-
Keywords: menu ui gui tui
|
|
10
|
-
Classifier: Programming Language :: Python :: 3.11
|
|
11
|
-
Classifier: License :: OSI Approved :: MIT License
|
|
12
|
-
Classifier: Operating System :: OS Independent
|
|
13
|
-
Requires-Python: >=3.6
|
|
14
|
-
Description-Content-Type: text/markdown
|
|
15
|
-
License-File: LICENSE
|
|
16
|
-
Dynamic: author
|
|
17
|
-
Dynamic: author-email
|
|
18
|
-
Dynamic: classifier
|
|
19
|
-
Dynamic: description
|
|
20
|
-
Dynamic: description-content-type
|
|
21
|
-
Dynamic: home-page
|
|
22
|
-
Dynamic: keywords
|
|
23
|
-
Dynamic: project-url
|
|
24
|
-
Dynamic: requires-python
|
|
25
|
-
Dynamic: summary
|
|
26
|
-
|
|
27
|
-
# Xemonity
|
|
28
|
-
Xemonity - Python3 lib for terminal interfaces ~~mained on pynput~~
|
|
29
|
-
## Classes and methods
|
|
30
|
-
Retranslated in DOCS.md in GitHub page\
|
|
31
|
-
Examples also in GItHub page\
|
|
32
|
-
Also you can write your own `XmntUIList` elemenets, watch how methods and vars has `XUIL_Element` in DOCS.md
|
|
33
|
-
## Credits
|
|
34
|
-
~~[https://pypi.org/user/moses.palmer/] : made pynput lib~~ Pynput not more used
|
|
35
|
-
## License
|
|
36
|
-
Licensed under MIT license
|
|
1
|
+
Metadata-Version: 2.2
|
|
2
|
+
Name: xemonity
|
|
3
|
+
Version: 6.0
|
|
4
|
+
Summary: Libraly for simple terminal ui
|
|
5
|
+
Home-page: https://github.com/MurzikYEET/Xemonity
|
|
6
|
+
Author: murzik_kukushnik
|
|
7
|
+
Author-email: siniykoshara@gmail.com
|
|
8
|
+
Project-URL: GitHub, https://github.com/MurzikYEET/Xemonity
|
|
9
|
+
Keywords: menu ui gui tui
|
|
10
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
11
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
12
|
+
Classifier: Operating System :: OS Independent
|
|
13
|
+
Requires-Python: >=3.6
|
|
14
|
+
Description-Content-Type: text/markdown
|
|
15
|
+
License-File: LICENSE
|
|
16
|
+
Dynamic: author
|
|
17
|
+
Dynamic: author-email
|
|
18
|
+
Dynamic: classifier
|
|
19
|
+
Dynamic: description
|
|
20
|
+
Dynamic: description-content-type
|
|
21
|
+
Dynamic: home-page
|
|
22
|
+
Dynamic: keywords
|
|
23
|
+
Dynamic: project-url
|
|
24
|
+
Dynamic: requires-python
|
|
25
|
+
Dynamic: summary
|
|
26
|
+
|
|
27
|
+
# Xemonity
|
|
28
|
+
Xemonity - Python3 lib for terminal interfaces ~~mained on pynput~~
|
|
29
|
+
## Classes and methods
|
|
30
|
+
Retranslated in DOCS.md in GitHub page\
|
|
31
|
+
Examples also in GItHub page\
|
|
32
|
+
Also you can write your own `XmntUIList` elemenets, watch how methods and vars has `XUIL_Element` in DOCS.md
|
|
33
|
+
## Credits
|
|
34
|
+
~~[https://pypi.org/user/moses.palmer/] : made pynput lib~~ Pynput not more used
|
|
35
|
+
## License
|
|
36
|
+
Licensed under MIT license
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
# Xemonity
|
|
2
|
-
Xemonity - Python3 lib for terminal interfaces ~~mained on pynput~~
|
|
3
|
-
## Classes and methods
|
|
4
|
-
Retranslated in DOCS.md in GitHub page\
|
|
5
|
-
Examples also in GItHub page\
|
|
6
|
-
Also you can write your own `XmntUIList` elemenets, watch how methods and vars has `XUIL_Element` in DOCS.md
|
|
7
|
-
## Credits
|
|
8
|
-
~~[https://pypi.org/user/moses.palmer/] : made pynput lib~~ Pynput not more used
|
|
9
|
-
## License
|
|
1
|
+
# Xemonity
|
|
2
|
+
Xemonity - Python3 lib for terminal interfaces ~~mained on pynput~~
|
|
3
|
+
## Classes and methods
|
|
4
|
+
Retranslated in DOCS.md in GitHub page\
|
|
5
|
+
Examples also in GItHub page\
|
|
6
|
+
Also you can write your own `XmntUIList` elemenets, watch how methods and vars has `XUIL_Element` in DOCS.md
|
|
7
|
+
## Credits
|
|
8
|
+
~~[https://pypi.org/user/moses.palmer/] : made pynput lib~~ Pynput not more used
|
|
9
|
+
## License
|
|
10
10
|
Licensed under MIT license
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
try:
|
|
2
|
-
from .classes import *
|
|
3
|
-
except ImportError:
|
|
4
|
-
from classes import *
|
|
5
|
-
|
|
1
|
+
try:
|
|
2
|
+
from .classes import *
|
|
3
|
+
except ImportError:
|
|
4
|
+
from classes import *
|
|
5
|
+
|
|
6
6
|
print("Hello from Xemonity UI 'framework'\nGitHub : https://github.com/MurzikYEET/Xemonity")
|
|
@@ -1,208 +1,248 @@
|
|
|
1
|
-
from time import sleep as delay
|
|
2
|
-
try:from .methods import *
|
|
3
|
-
except:from methods import *
|
|
4
|
-
|
|
5
|
-
try:
|
|
6
|
-
import colorama
|
|
7
|
-
support_colorama = True
|
|
8
|
-
except:
|
|
9
|
-
support_colorama = False
|
|
10
|
-
|
|
11
|
-
class XemonityAM:
|
|
12
|
-
def __init__(self,elements:list,title:str,append_cancel=True):
|
|
13
|
-
"""
|
|
14
|
-
self.cursor = 0
|
|
15
|
-
self.elements = elements
|
|
16
|
-
if append_cancel:self.elements.append(":Cancel")
|
|
17
|
-
self.title = title
|
|
18
|
-
def update_screen(self,intertime=0.05):
|
|
19
|
-
|
|
20
|
-
print(
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
pressed
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
self.
|
|
41
|
-
|
|
42
|
-
self.
|
|
43
|
-
|
|
44
|
-
self.
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
self.
|
|
57
|
-
self.
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
self.
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
case "
|
|
68
|
-
case "
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
element
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
(self.
|
|
91
|
-
(" " * (terminal_width() - len(self.title))))
|
|
92
|
-
print(colorama.Style.RESET_ALL,end="")
|
|
93
|
-
else:
|
|
94
|
-
print(self.title[:terminal_width()]+
|
|
95
|
-
("
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
if i
|
|
108
|
-
|
|
109
|
-
self.
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
self.elements
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
self.
|
|
132
|
-
|
|
133
|
-
self.elements[self.cursor].when_acted("
|
|
134
|
-
case "
|
|
135
|
-
self.elements[self.cursor].when_acted("
|
|
136
|
-
case "
|
|
137
|
-
self.elements[self.cursor].when_acted("
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
self.
|
|
153
|
-
self.
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
def
|
|
160
|
-
"""Called when
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
def
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
self.
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
def
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
1
|
+
from time import sleep as delay
|
|
2
|
+
try:from .methods import *
|
|
3
|
+
except:from methods import *
|
|
4
|
+
|
|
5
|
+
try:
|
|
6
|
+
import colorama
|
|
7
|
+
support_colorama = True
|
|
8
|
+
except:
|
|
9
|
+
support_colorama = False
|
|
10
|
+
|
|
11
|
+
class XemonityAM:
|
|
12
|
+
def __init__(self,elements:list,title:str,append_cancel=True):
|
|
13
|
+
"""Old class for list of texts"""
|
|
14
|
+
self.cursor = 0
|
|
15
|
+
self.elements = elements
|
|
16
|
+
if append_cancel:self.elements.append(":Cancel")
|
|
17
|
+
self.title = title
|
|
18
|
+
def update_screen(self,intertime=0.05):
|
|
19
|
+
print_title(self.title,support_colorama)
|
|
20
|
+
#if self.cursor > 1:print("...")
|
|
21
|
+
for i in range(self.cursor,len(self.elements)):
|
|
22
|
+
if i == self.cursor:print(">>",end="")
|
|
23
|
+
print(self.elements[i])
|
|
24
|
+
delay(intertime)
|
|
25
|
+
def relist(self,newlist:list):
|
|
26
|
+
self.elements = newlist
|
|
27
|
+
self.cursor = 0
|
|
28
|
+
def show_sync(self):
|
|
29
|
+
try:
|
|
30
|
+
self.cursor = 0
|
|
31
|
+
open_alt_screen()
|
|
32
|
+
while True:
|
|
33
|
+
self.update_screen()
|
|
34
|
+
pressed = get_key()
|
|
35
|
+
|
|
36
|
+
match pressed:
|
|
37
|
+
case "DOWN":
|
|
38
|
+
self.cursor += 1
|
|
39
|
+
if self.cursor >= len(self.elements):self.cursor = 0
|
|
40
|
+
self.update_screen()
|
|
41
|
+
case "UP":
|
|
42
|
+
self.cursor -= 1
|
|
43
|
+
if self.cursor <= -1:self.cursor = len(self.elements)-1
|
|
44
|
+
self.update_screen()
|
|
45
|
+
case "ENTER":
|
|
46
|
+
close_alt_screen()
|
|
47
|
+
return self.elements[self.cursor]
|
|
48
|
+
except:
|
|
49
|
+
close_alt_screen()
|
|
50
|
+
return ":CANCELED"
|
|
51
|
+
XmntLegacyMenu = XemonityAM #alias for XemonityAM legacy class
|
|
52
|
+
|
|
53
|
+
class XmntUIList:
|
|
54
|
+
def __init__(self,title=""):
|
|
55
|
+
self.title = title
|
|
56
|
+
self.elements = []
|
|
57
|
+
self.cursor = 0
|
|
58
|
+
|
|
59
|
+
self._bupdate = None
|
|
60
|
+
self._aupdate = None
|
|
61
|
+
|
|
62
|
+
self._breakme = False
|
|
63
|
+
def bind_action(self,action:str,method):
|
|
64
|
+
"""Adds method for action (name of actions watch in DOCS.md)"""
|
|
65
|
+
match action.lower():
|
|
66
|
+
case "before update":self._bupdate = method
|
|
67
|
+
case "after update":self._aupdate = method
|
|
68
|
+
case _:raise Exception("Undefined action")
|
|
69
|
+
def connect_element(self,element):
|
|
70
|
+
"""Add new element"""
|
|
71
|
+
element.uilist = self
|
|
72
|
+
self.elements.append(element)
|
|
73
|
+
def clear_elements_list(self):
|
|
74
|
+
"""Remove all elements"""
|
|
75
|
+
for i in self.elements:i.uilist = None
|
|
76
|
+
self.elements.clear()
|
|
77
|
+
def connect_element_list(self,elements:list,clear_before=True):
|
|
78
|
+
"""Clears list of elements and add new"""
|
|
79
|
+
if clear_before:self.clear_elements_list()
|
|
80
|
+
for i in elements:
|
|
81
|
+
self.connect_element(i)
|
|
82
|
+
def out_of(self):
|
|
83
|
+
"""Stop XmntUIList.show_sync()"""
|
|
84
|
+
self._breakme = True
|
|
85
|
+
def update_screen(self):
|
|
86
|
+
clear_screen()
|
|
87
|
+
if support_colorama:
|
|
88
|
+
print(colorama.Back.WHITE+colorama.Fore.BLACK+
|
|
89
|
+
(self.title[:terminal_width()])+
|
|
90
|
+
("^^^" if self.cursor > 0 else "")+
|
|
91
|
+
(" " * (terminal_width() - len(self.title) - (3 if self.cursor > 0 else 0))))
|
|
92
|
+
print(colorama.Style.RESET_ALL,end="")
|
|
93
|
+
else:
|
|
94
|
+
print(self.title[:terminal_width()]+
|
|
95
|
+
("^^^" if self.cursor > 0 else "")+
|
|
96
|
+
("_" * min(0,terminal_width() - len(self.title) - (3 if self.cursor > 0 else 0))))
|
|
97
|
+
|
|
98
|
+
#visible_height = terminal_height() - 2
|
|
99
|
+
#if visible_height < 1: visible_height = 1
|
|
100
|
+
#
|
|
101
|
+
#offset = 0
|
|
102
|
+
#if self.cursor >= visible_height:
|
|
103
|
+
# offset = self.cursor - visible_height + 1
|
|
104
|
+
|
|
105
|
+
#for i in range(offset, offset + visible_height):
|
|
106
|
+
for i in range(self.cursor,len(self.elements)):
|
|
107
|
+
if i >= len(self.elements):
|
|
108
|
+
break
|
|
109
|
+
if i == self.cursor:print("::",end="")
|
|
110
|
+
else: print(" ",end="")
|
|
111
|
+
self.elements[i].render()
|
|
112
|
+
def show_sync(self,intertime=0.05):
|
|
113
|
+
"""Show interface"""
|
|
114
|
+
while True:
|
|
115
|
+
if self._bupdate != None:self._bupdate()
|
|
116
|
+
if self._breakme:
|
|
117
|
+
self._breakme = False
|
|
118
|
+
break
|
|
119
|
+
self.update_screen()
|
|
120
|
+
try:pr = get_key()
|
|
121
|
+
except KeyboardInterrupt:
|
|
122
|
+
self._breakme = True
|
|
123
|
+
continue
|
|
124
|
+
|
|
125
|
+
match pr:
|
|
126
|
+
case "DOWN":
|
|
127
|
+
if self.cursor >= len(self.elements)-1:self.cursor = 0
|
|
128
|
+
else:self.cursor += 1
|
|
129
|
+
self.elements[self.cursor].when_acted("DOWN")
|
|
130
|
+
case "UP":
|
|
131
|
+
if self.cursor <= 0:self.cursor = len(self.elements)-1
|
|
132
|
+
else:self.cursor -= 1
|
|
133
|
+
self.elements[self.cursor].when_acted("UP")
|
|
134
|
+
case "ENTER":
|
|
135
|
+
self.elements[self.cursor].when_acted("ENTER")
|
|
136
|
+
case "LEFT":
|
|
137
|
+
self.elements[self.cursor].when_acted("LEFT")
|
|
138
|
+
case "RIGHT":
|
|
139
|
+
self.elements[self.cursor].when_acted("RIGHT")
|
|
140
|
+
if self._aupdate != None:self._aupdate()
|
|
141
|
+
delay(intertime)
|
|
142
|
+
to_out = {}
|
|
143
|
+
for i in self.elements:
|
|
144
|
+
to_out[i.realname] = i.stdout
|
|
145
|
+
clear_screen()
|
|
146
|
+
close_alt_screen()
|
|
147
|
+
return to_out
|
|
148
|
+
|
|
149
|
+
class XUIL_Element:
|
|
150
|
+
def __init__(self,realname,name="XmntUIList template"):
|
|
151
|
+
"""Main class for all UI elements"""
|
|
152
|
+
self.uilist:XmntUIList = None
|
|
153
|
+
self.name = name
|
|
154
|
+
self.realname = realname
|
|
155
|
+
self.stdout = ""
|
|
156
|
+
def is_selected(self):
|
|
157
|
+
"""Return true if cursor in element"""
|
|
158
|
+
return self.uilist.elements.count(self) >= 1
|
|
159
|
+
def when_acted(self,action:str):
|
|
160
|
+
"""Called when user press arrows, enter and other buttons registred in get_key() method"""
|
|
161
|
+
def render(self):
|
|
162
|
+
"""Called when XmntUIList.show_sync() try draw look"""
|
|
163
|
+
print(self.name)
|
|
164
|
+
|
|
165
|
+
class Button(XUIL_Element):
|
|
166
|
+
"""Pressable element"""
|
|
167
|
+
def __init__(self,realname,title="Button",on_click=None):
|
|
168
|
+
super().__init__(realname,title)
|
|
169
|
+
self.on_click = on_click
|
|
170
|
+
self.stdout = False
|
|
171
|
+
def when_acted(self, action):
|
|
172
|
+
if action == "ENTER":
|
|
173
|
+
self.stdout = True
|
|
174
|
+
if self.on_click:self.on_click()
|
|
175
|
+
else:self.uilist.out_of()
|
|
176
|
+
def render(self):
|
|
177
|
+
print("|"+self.name+"|")
|
|
178
|
+
|
|
179
|
+
class Label(XUIL_Element):
|
|
180
|
+
"""Label element"""
|
|
181
|
+
def __init__(self, realname, label="I lable"):
|
|
182
|
+
super().__init__(realname, label)
|
|
183
|
+
self.label = label
|
|
184
|
+
def render(self):
|
|
185
|
+
print(self.label[:terminal_width() - (2 if self.is_selected else 0)])
|
|
186
|
+
|
|
187
|
+
class Checkbox(XUIL_Element):
|
|
188
|
+
"""Checkbox element"""
|
|
189
|
+
def __init__(self, realname, name,default=False):
|
|
190
|
+
super().__init__(realname, name)
|
|
191
|
+
self.stdout = default
|
|
192
|
+
def when_acted(self, action):
|
|
193
|
+
if action == "LEFT" or action == "RIGHT" or action == "ENTER":
|
|
194
|
+
self.stdout = not self.stdout
|
|
195
|
+
def render(self):
|
|
196
|
+
print(self.name + " : " + ("▉▉" if self.stdout else "░░"))
|
|
197
|
+
|
|
198
|
+
class Slider(XUIL_Element):
|
|
199
|
+
"""Slider element"""
|
|
200
|
+
def __init__(self, realname, name, mini=0, default=50, maxi=100, step=1):
|
|
201
|
+
super().__init__(realname, name)
|
|
202
|
+
self.min = mini
|
|
203
|
+
self.max = maxi
|
|
204
|
+
self.stdout = default
|
|
205
|
+
self.step = step
|
|
206
|
+
def when_acted(self, action):
|
|
207
|
+
if action == "LEFT":self.stdout = self.stdout if self.stdout < (self.min + self.step) else self.stdout - self.step
|
|
208
|
+
if action == "RIGHT":self.stdout = self.stdout if self.stdout > (self.max - self.step) else self.stdout + self.step
|
|
209
|
+
def render(self):
|
|
210
|
+
normalized = (self.stdout - self.min) / (self.max - self.min)
|
|
211
|
+
bar_width = terminal_width() - len(self.name) - len(str(self.stdout)) - 7
|
|
212
|
+
to_fill = int(normalized * bar_width)
|
|
213
|
+
to_skip = bar_width - to_fill
|
|
214
|
+
print(self.name + f"({self.stdout})" + ":::" + ("▉" * to_fill) + ("░" * to_skip))
|
|
215
|
+
|
|
216
|
+
class Inputbox(XUIL_Element):
|
|
217
|
+
def __init__(self, realname, name,default="Enter text",desc="Please enter text"):
|
|
218
|
+
"""Text input element"""
|
|
219
|
+
super().__init__(realname, name)
|
|
220
|
+
self.stdout = default
|
|
221
|
+
self.desc = desc
|
|
222
|
+
def when_acted(self, action):
|
|
223
|
+
if action == "ENTER":
|
|
224
|
+
print_title(self.uilist.title+" > "+self.name,support_colorama)
|
|
225
|
+
resized_desc = self.desc.split("\n")[:terminal_height()]
|
|
226
|
+
for i in resized_desc:print(i)
|
|
227
|
+
self.stdout = input(self.name + " >> ")
|
|
228
|
+
def render(self):
|
|
229
|
+
print(self.name + " >> " + self.stdout)
|
|
230
|
+
|
|
231
|
+
class Dropdown(XUIL_Element):
|
|
232
|
+
def __init__(self, realname, name, elements:dict):
|
|
233
|
+
"""Dropdown element"""
|
|
234
|
+
super().__init__(realname, name)
|
|
235
|
+
self.elements = elements
|
|
236
|
+
self._cursor = 0
|
|
237
|
+
self.stdout = list(self.elements.keys())[0]
|
|
238
|
+
def when_acted(self, action):
|
|
239
|
+
if action == "ENTER":
|
|
240
|
+
els = XmntLegacyMenu(list(self.elements.values()),self.uilist.title+" > "+self.name)
|
|
241
|
+
els.show_sync()
|
|
242
|
+
try:self.stdout = list(self.elements.keys())[els.cursor]
|
|
243
|
+
except IndexError:self.stdout = ":CANCELED"
|
|
244
|
+
def render(self):
|
|
245
|
+
if self.stdout == ":CANCELED":
|
|
246
|
+
print(self.name+" :: CANCELED")
|
|
247
|
+
return
|
|
248
|
+
print(self.name+" :: "+self.elements[self.stdout])
|
|
@@ -1,66 +1,79 @@
|
|
|
1
|
-
import os
|
|
2
|
-
import sys
|
|
3
|
-
|
|
4
|
-
import
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
sys.stdout.write("\x1b[?
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
return '
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
if
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
def
|
|
65
|
-
|
|
1
|
+
import os
|
|
2
|
+
import sys
|
|
3
|
+
try:
|
|
4
|
+
import colorama
|
|
5
|
+
support_colorama = True
|
|
6
|
+
except:
|
|
7
|
+
support_colorama = False
|
|
8
|
+
if os.name == "nt":
|
|
9
|
+
import msvcrt
|
|
10
|
+
else:
|
|
11
|
+
import termios
|
|
12
|
+
import tty
|
|
13
|
+
|
|
14
|
+
def open_alt_screen():
|
|
15
|
+
sys.stdout.write("\x1b[?1049h")
|
|
16
|
+
clear_screen()
|
|
17
|
+
|
|
18
|
+
def close_alt_screen():
|
|
19
|
+
#clear_screen()
|
|
20
|
+
sys.stdout.write("\x1b[?1049l")
|
|
21
|
+
|
|
22
|
+
def clear_screen():
|
|
23
|
+
if is_windows():
|
|
24
|
+
os.system('cls')
|
|
25
|
+
else:
|
|
26
|
+
os.system('clear')
|
|
27
|
+
|
|
28
|
+
def get_key_posix(): #for unix-like os (MacOS,Linux,*BSD and other)
|
|
29
|
+
fd = sys.stdin.fileno()
|
|
30
|
+
old_settings = termios.tcgetattr(fd)
|
|
31
|
+
try:
|
|
32
|
+
tty.setraw(fd)
|
|
33
|
+
ch = sys.stdin.read(1)
|
|
34
|
+
if ch == '\x1b': #Arrows
|
|
35
|
+
ch += sys.stdin.read(2)
|
|
36
|
+
if ch == '\x1b[A': return 'UP'
|
|
37
|
+
if ch == '\x1b[B': return 'DOWN'
|
|
38
|
+
if ch == '\x1b[C': return 'RIGHT'
|
|
39
|
+
if ch == '\x1b[D': return 'LEFT'
|
|
40
|
+
return None
|
|
41
|
+
elif ch == '\r': # Enter
|
|
42
|
+
return 'ENTER'
|
|
43
|
+
elif ch == '\x03': # Ctrl+C
|
|
44
|
+
raise KeyboardInterrupt
|
|
45
|
+
return ch
|
|
46
|
+
finally:
|
|
47
|
+
termios.tcsetattr(fd, termios.TCSADRAIN, old_settings)
|
|
48
|
+
|
|
49
|
+
def get_key_nt(): #for NT-like os (Windows)
|
|
50
|
+
ch = msvcrt.getch()
|
|
51
|
+
if ch in (b'\x00', b'\xe0'): #Arrows
|
|
52
|
+
ch = msvcrt.getch()
|
|
53
|
+
if ch == b'H': return 'UP'
|
|
54
|
+
if ch == b'P': return 'DOWN'
|
|
55
|
+
if ch == b'K': return 'LEFT'
|
|
56
|
+
if ch == b'M': return 'RIGHT'
|
|
57
|
+
return None
|
|
58
|
+
|
|
59
|
+
if ch == b'\r': return 'ENTER' #Enter
|
|
60
|
+
if ch == b'\x03': raise KeyboardInterrupt # Ctrl+C
|
|
61
|
+
|
|
62
|
+
return ch.decode('utf-8', errors='ignore')
|
|
63
|
+
|
|
64
|
+
def get_key(): #universal
|
|
65
|
+
if is_windows():return get_key_nt()
|
|
66
|
+
else:return get_key_posix()
|
|
67
|
+
|
|
68
|
+
def print_title(message:str,colorwrite=False,background=colorama.Back.WHITE,foreground=colorama.Fore.BLACK):
|
|
69
|
+
clear_screen()
|
|
70
|
+
if colorwrite:
|
|
71
|
+
print(background,foreground,message," " * (terminal_width() - len(message) - 3),end="",sep="")
|
|
72
|
+
print(colorama.Style.RESET_ALL)
|
|
73
|
+
else:
|
|
74
|
+
print(message)
|
|
75
|
+
|
|
76
|
+
def min(minval,x):return x if x > minval else minval
|
|
77
|
+
def is_windows():return os.name == "nt"
|
|
78
|
+
def terminal_width():return os.get_terminal_size().columns
|
|
66
79
|
def terminal_height():return os.get_terminal_size().lines
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
[build-system]
|
|
2
|
-
requires = ["setuptools==75.8.0"]
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools==75.8.0"]
|
|
3
3
|
build-backend = "setuptools.build_meta"
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
[egg_info]
|
|
2
|
-
tag_build =
|
|
3
|
-
tag_date = 0
|
|
4
|
-
|
|
1
|
+
[egg_info]
|
|
2
|
+
tag_build =
|
|
3
|
+
tag_date = 0
|
|
4
|
+
|
|
@@ -1,30 +1,30 @@
|
|
|
1
|
-
from setuptools import setup, find_packages
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
def readme():
|
|
5
|
-
with open('README.md', 'r') as f:
|
|
6
|
-
return f.read()
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
setup(
|
|
10
|
-
name='xemonity',
|
|
11
|
-
version='
|
|
12
|
-
author='murzik_kukushnik',
|
|
13
|
-
author_email='siniykoshara@gmail.com',
|
|
14
|
-
description='Libraly for simple terminal ui',
|
|
15
|
-
long_description=readme(),
|
|
16
|
-
long_description_content_type='text/markdown',
|
|
17
|
-
url='https://github.com/MurzikYEET/Xemonity',
|
|
18
|
-
packages=find_packages(),
|
|
19
|
-
install_requires=[],
|
|
20
|
-
classifiers=[
|
|
21
|
-
'Programming Language :: Python :: 3.11',
|
|
22
|
-
'License :: OSI Approved :: MIT License',
|
|
23
|
-
'Operating System :: OS Independent'
|
|
24
|
-
],
|
|
25
|
-
keywords='menu ui gui tui',
|
|
26
|
-
project_urls={
|
|
27
|
-
"GitHub" : "https://github.com/MurzikYEET/Xemonity"
|
|
28
|
-
},
|
|
29
|
-
python_requires='>=3.6'
|
|
1
|
+
from setuptools import setup, find_packages
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
def readme():
|
|
5
|
+
with open('README.md', 'r') as f:
|
|
6
|
+
return f.read()
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
setup(
|
|
10
|
+
name='xemonity',
|
|
11
|
+
version='6.0',
|
|
12
|
+
author='murzik_kukushnik',
|
|
13
|
+
author_email='siniykoshara@gmail.com',
|
|
14
|
+
description='Libraly for simple terminal ui',
|
|
15
|
+
long_description=readme(),
|
|
16
|
+
long_description_content_type='text/markdown',
|
|
17
|
+
url='https://github.com/MurzikYEET/Xemonity',
|
|
18
|
+
packages=find_packages(),
|
|
19
|
+
install_requires=[],
|
|
20
|
+
classifiers=[
|
|
21
|
+
'Programming Language :: Python :: 3.11',
|
|
22
|
+
'License :: OSI Approved :: MIT License',
|
|
23
|
+
'Operating System :: OS Independent'
|
|
24
|
+
],
|
|
25
|
+
keywords='menu ui gui tui',
|
|
26
|
+
project_urls={
|
|
27
|
+
"GitHub" : "https://github.com/MurzikYEET/Xemonity"
|
|
28
|
+
},
|
|
29
|
+
python_requires='>=3.6'
|
|
30
30
|
)
|
|
@@ -1,36 +1,36 @@
|
|
|
1
|
-
Metadata-Version: 2.2
|
|
2
|
-
Name: xemonity
|
|
3
|
-
Version:
|
|
4
|
-
Summary: Libraly for simple terminal ui
|
|
5
|
-
Home-page: https://github.com/MurzikYEET/Xemonity
|
|
6
|
-
Author: murzik_kukushnik
|
|
7
|
-
Author-email: siniykoshara@gmail.com
|
|
8
|
-
Project-URL: GitHub, https://github.com/MurzikYEET/Xemonity
|
|
9
|
-
Keywords: menu ui gui tui
|
|
10
|
-
Classifier: Programming Language :: Python :: 3.11
|
|
11
|
-
Classifier: License :: OSI Approved :: MIT License
|
|
12
|
-
Classifier: Operating System :: OS Independent
|
|
13
|
-
Requires-Python: >=3.6
|
|
14
|
-
Description-Content-Type: text/markdown
|
|
15
|
-
License-File: LICENSE
|
|
16
|
-
Dynamic: author
|
|
17
|
-
Dynamic: author-email
|
|
18
|
-
Dynamic: classifier
|
|
19
|
-
Dynamic: description
|
|
20
|
-
Dynamic: description-content-type
|
|
21
|
-
Dynamic: home-page
|
|
22
|
-
Dynamic: keywords
|
|
23
|
-
Dynamic: project-url
|
|
24
|
-
Dynamic: requires-python
|
|
25
|
-
Dynamic: summary
|
|
26
|
-
|
|
27
|
-
# Xemonity
|
|
28
|
-
Xemonity - Python3 lib for terminal interfaces ~~mained on pynput~~
|
|
29
|
-
## Classes and methods
|
|
30
|
-
Retranslated in DOCS.md in GitHub page\
|
|
31
|
-
Examples also in GItHub page\
|
|
32
|
-
Also you can write your own `XmntUIList` elemenets, watch how methods and vars has `XUIL_Element` in DOCS.md
|
|
33
|
-
## Credits
|
|
34
|
-
~~[https://pypi.org/user/moses.palmer/] : made pynput lib~~ Pynput not more used
|
|
35
|
-
## License
|
|
36
|
-
Licensed under MIT license
|
|
1
|
+
Metadata-Version: 2.2
|
|
2
|
+
Name: xemonity
|
|
3
|
+
Version: 6.0
|
|
4
|
+
Summary: Libraly for simple terminal ui
|
|
5
|
+
Home-page: https://github.com/MurzikYEET/Xemonity
|
|
6
|
+
Author: murzik_kukushnik
|
|
7
|
+
Author-email: siniykoshara@gmail.com
|
|
8
|
+
Project-URL: GitHub, https://github.com/MurzikYEET/Xemonity
|
|
9
|
+
Keywords: menu ui gui tui
|
|
10
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
11
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
12
|
+
Classifier: Operating System :: OS Independent
|
|
13
|
+
Requires-Python: >=3.6
|
|
14
|
+
Description-Content-Type: text/markdown
|
|
15
|
+
License-File: LICENSE
|
|
16
|
+
Dynamic: author
|
|
17
|
+
Dynamic: author-email
|
|
18
|
+
Dynamic: classifier
|
|
19
|
+
Dynamic: description
|
|
20
|
+
Dynamic: description-content-type
|
|
21
|
+
Dynamic: home-page
|
|
22
|
+
Dynamic: keywords
|
|
23
|
+
Dynamic: project-url
|
|
24
|
+
Dynamic: requires-python
|
|
25
|
+
Dynamic: summary
|
|
26
|
+
|
|
27
|
+
# Xemonity
|
|
28
|
+
Xemonity - Python3 lib for terminal interfaces ~~mained on pynput~~
|
|
29
|
+
## Classes and methods
|
|
30
|
+
Retranslated in DOCS.md in GitHub page\
|
|
31
|
+
Examples also in GItHub page\
|
|
32
|
+
Also you can write your own `XmntUIList` elemenets, watch how methods and vars has `XUIL_Element` in DOCS.md
|
|
33
|
+
## Credits
|
|
34
|
+
~~[https://pypi.org/user/moses.palmer/] : made pynput lib~~ Pynput not more used
|
|
35
|
+
## License
|
|
36
|
+
Licensed under MIT license
|
|
File without changes
|
|
File without changes
|
|
File without changes
|