xemonity 2.0__tar.gz → 3.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-2.0 → xemonity-3.0}/PKG-INFO +4 -6
- {xemonity-2.0 → xemonity-3.0}/README.md +3 -3
- xemonity-3.0/Xemonity/classes.py +100 -0
- {xemonity-2.0 → xemonity-3.0}/setup.py +2 -2
- {xemonity-2.0 → xemonity-3.0}/xemonity.egg-info/PKG-INFO +4 -6
- {xemonity-2.0 → xemonity-3.0}/xemonity.egg-info/SOURCES.txt +0 -1
- xemonity-2.0/Xemonity/classes.py +0 -72
- xemonity-2.0/xemonity.egg-info/requires.txt +0 -1
- {xemonity-2.0 → xemonity-3.0}/LICENSE +0 -0
- {xemonity-2.0 → xemonity-3.0}/Xemonity/__init__.py +0 -0
- {xemonity-2.0 → xemonity-3.0}/pyproject.toml +0 -0
- {xemonity-2.0 → xemonity-3.0}/setup.cfg +0 -0
- {xemonity-2.0 → xemonity-3.0}/xemonity.egg-info/dependency_links.txt +0 -0
- {xemonity-2.0 → xemonity-3.0}/xemonity.egg-info/top_level.txt +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.2
|
|
2
2
|
Name: xemonity
|
|
3
|
-
Version:
|
|
3
|
+
Version: 3.0
|
|
4
4
|
Summary: Libraly for simple menu with chosing
|
|
5
5
|
Home-page: https://github.com/MurzikYEET/Xemonity
|
|
6
6
|
Author: murzik_kukushnik
|
|
@@ -13,7 +13,6 @@ Classifier: Operating System :: OS Independent
|
|
|
13
13
|
Requires-Python: >=3.6
|
|
14
14
|
Description-Content-Type: text/markdown
|
|
15
15
|
License-File: LICENSE
|
|
16
|
-
Requires-Dist: pynput
|
|
17
16
|
Dynamic: author
|
|
18
17
|
Dynamic: author-email
|
|
19
18
|
Dynamic: classifier
|
|
@@ -22,12 +21,11 @@ Dynamic: description-content-type
|
|
|
22
21
|
Dynamic: home-page
|
|
23
22
|
Dynamic: keywords
|
|
24
23
|
Dynamic: project-url
|
|
25
|
-
Dynamic: requires-dist
|
|
26
24
|
Dynamic: requires-python
|
|
27
25
|
Dynamic: summary
|
|
28
26
|
|
|
29
27
|
# Xemonity
|
|
30
|
-
Xemonity - Python3 lib for simple menu
|
|
28
|
+
Xemonity - Python3 lib for simple choose menu ~~mained on pynput ~~
|
|
31
29
|
## How to use?
|
|
32
30
|
Code look as
|
|
33
31
|
```python
|
|
@@ -49,12 +47,12 @@ Three
|
|
|
49
47
|
`Xemonity.XemonityAM(elements:list,title:str)`
|
|
50
48
|
Main class for menu
|
|
51
49
|
1. `XemonityAM.cursor` : int var : return a current selected element index
|
|
52
|
-
2. `XemonityAM.title` : str var : just a title, shows
|
|
50
|
+
2. `XemonityAM.title` : str var : just a title, shows before elements
|
|
53
51
|
3. `XemonityAM.elements` : list var : list of elements (this is not recommended for modification)
|
|
54
52
|
4. `XemonityAM.relist(newlist:list)` : None func : change list of elements
|
|
55
53
|
5. `XemonityAM.show_sync()` : str func : show menu and return choosed element, if choosen ":Cancel" then method returns ":CANCELED"
|
|
56
54
|
Other methods not for you
|
|
57
55
|
## Credits
|
|
58
|
-
[https://pypi.org/user/moses.palmer/] : made pynput lib
|
|
56
|
+
~~[https://pypi.org/user/moses.palmer/] : made pynput lib~~ Pynput not more used
|
|
59
57
|
## License
|
|
60
58
|
Licensed under MIT license
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
# Xemonity
|
|
2
|
-
Xemonity - Python3 lib for simple menu
|
|
2
|
+
Xemonity - Python3 lib for simple choose menu ~~mained on pynput ~~
|
|
3
3
|
## How to use?
|
|
4
4
|
Code look as
|
|
5
5
|
```python
|
|
@@ -21,12 +21,12 @@ Three
|
|
|
21
21
|
`Xemonity.XemonityAM(elements:list,title:str)`
|
|
22
22
|
Main class for menu
|
|
23
23
|
1. `XemonityAM.cursor` : int var : return a current selected element index
|
|
24
|
-
2. `XemonityAM.title` : str var : just a title, shows
|
|
24
|
+
2. `XemonityAM.title` : str var : just a title, shows before elements
|
|
25
25
|
3. `XemonityAM.elements` : list var : list of elements (this is not recommended for modification)
|
|
26
26
|
4. `XemonityAM.relist(newlist:list)` : None func : change list of elements
|
|
27
27
|
5. `XemonityAM.show_sync()` : str func : show menu and return choosed element, if choosen ":Cancel" then method returns ":CANCELED"
|
|
28
28
|
Other methods not for you
|
|
29
29
|
## Credits
|
|
30
|
-
[https://pypi.org/user/moses.palmer/] : made pynput lib
|
|
30
|
+
~~[https://pypi.org/user/moses.palmer/] : made pynput lib~~ Pynput not more used
|
|
31
31
|
## License
|
|
32
32
|
Licensed under MIT license
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
from time import sleep as delay
|
|
2
|
+
import sys
|
|
3
|
+
import os
|
|
4
|
+
if os.name == "nt":
|
|
5
|
+
import msvcrt
|
|
6
|
+
else:
|
|
7
|
+
import termios
|
|
8
|
+
import tty
|
|
9
|
+
|
|
10
|
+
def open_alt_screen():
|
|
11
|
+
sys.stdout.write("\x1b[?1049h")
|
|
12
|
+
clear_screen()
|
|
13
|
+
|
|
14
|
+
def close_alt_screen():
|
|
15
|
+
#clear_screen()
|
|
16
|
+
sys.stdout.write("\x1b[?1049l")
|
|
17
|
+
|
|
18
|
+
def clear_screen():
|
|
19
|
+
if is_windows():
|
|
20
|
+
os.system('cls')
|
|
21
|
+
else:
|
|
22
|
+
os.system('clear')
|
|
23
|
+
|
|
24
|
+
def get_key_posix(): #for unix-like os (MacOS,Linux,*BSD and other)
|
|
25
|
+
fd = sys.stdin.fileno()
|
|
26
|
+
old_settings = termios.tcgetattr(fd)
|
|
27
|
+
try:
|
|
28
|
+
tty.setraw(fd)
|
|
29
|
+
ch = sys.stdin.read(1)
|
|
30
|
+
if ch == '\x1b': #Up or down
|
|
31
|
+
ch += sys.stdin.read(2)
|
|
32
|
+
if ch == '\x1b[A': return 'UP'
|
|
33
|
+
if ch == '\x1b[B': return 'DOWN'
|
|
34
|
+
return None
|
|
35
|
+
elif ch == '\r': # Enter
|
|
36
|
+
return 'ENTER'
|
|
37
|
+
elif ch == '\x03': # Ctrl+C
|
|
38
|
+
raise KeyboardInterrupt
|
|
39
|
+
return ch
|
|
40
|
+
finally:
|
|
41
|
+
termios.tcsetattr(fd, termios.TCSADRAIN, old_settings)
|
|
42
|
+
|
|
43
|
+
def get_key_nt(): #for NT-like os (Windows)
|
|
44
|
+
ch = msvcrt.getch()
|
|
45
|
+
if ch in (b'\x00', b'\xe0'): #Up or down
|
|
46
|
+
ch = msvcrt.getch()
|
|
47
|
+
if ch == b'H': return 'UP'
|
|
48
|
+
if ch == b'P': return 'DOWN'
|
|
49
|
+
return None
|
|
50
|
+
|
|
51
|
+
if ch == b'\r': return 'ENTER' #Enter
|
|
52
|
+
if ch == b'\x03': raise KeyboardInterrupt # Ctrl+C
|
|
53
|
+
|
|
54
|
+
return ch.decode('utf-8', errors='ignore')
|
|
55
|
+
|
|
56
|
+
def is_windows():return os.name == "nt"
|
|
57
|
+
|
|
58
|
+
class XemonityAM:
|
|
59
|
+
def __init__(self,elements:list,title:str):
|
|
60
|
+
self.cursor = 0
|
|
61
|
+
self.elements = elements
|
|
62
|
+
self.elements.append(":Cancel")
|
|
63
|
+
self.title = title
|
|
64
|
+
def update_screen(self,intertime=0.05):
|
|
65
|
+
clear_screen()
|
|
66
|
+
print(self.title)
|
|
67
|
+
if self.cursor >= 4:print("...")
|
|
68
|
+
for i in range(0,len(self.elements)):
|
|
69
|
+
if i+3 < self.cursor:
|
|
70
|
+
continue
|
|
71
|
+
if i == self.cursor: print(">>",end="")
|
|
72
|
+
print(self.elements[i])
|
|
73
|
+
delay(intertime)
|
|
74
|
+
def relist(self,newlist:list):
|
|
75
|
+
self.elements = newlist
|
|
76
|
+
self.cursor = 0
|
|
77
|
+
def show_sync(self):
|
|
78
|
+
try:
|
|
79
|
+
self.cursor = 0
|
|
80
|
+
open_alt_screen()
|
|
81
|
+
while True:
|
|
82
|
+
self.update_screen()
|
|
83
|
+
|
|
84
|
+
if is_windows():pressed = get_key_nt()
|
|
85
|
+
else:pressed = get_key_posix()
|
|
86
|
+
|
|
87
|
+
if pressed == "DOWN":
|
|
88
|
+
self.cursor += 1
|
|
89
|
+
if self.cursor >= len(self.elements):self.cursor = 0
|
|
90
|
+
self.update_screen()
|
|
91
|
+
elif pressed == "UP":
|
|
92
|
+
self.cursor -= 1
|
|
93
|
+
if self.cursor <= -1:self.cursor = len(self.elements)-1
|
|
94
|
+
self.update_screen()
|
|
95
|
+
elif pressed == "ENTER":
|
|
96
|
+
close_alt_screen()
|
|
97
|
+
return self.elements[self.cursor]
|
|
98
|
+
except:
|
|
99
|
+
close_alt_screen()
|
|
100
|
+
return ":CANCELED"
|
|
@@ -8,7 +8,7 @@ def readme():
|
|
|
8
8
|
|
|
9
9
|
setup(
|
|
10
10
|
name='xemonity',
|
|
11
|
-
version='
|
|
11
|
+
version='3.0',
|
|
12
12
|
author='murzik_kukushnik',
|
|
13
13
|
author_email='siniykoshara@gmail.com',
|
|
14
14
|
description='Libraly for simple menu with chosing',
|
|
@@ -16,7 +16,7 @@ setup(
|
|
|
16
16
|
long_description_content_type='text/markdown',
|
|
17
17
|
url='https://github.com/MurzikYEET/Xemonity',
|
|
18
18
|
packages=find_packages(),
|
|
19
|
-
install_requires=[
|
|
19
|
+
install_requires=[],
|
|
20
20
|
classifiers=[
|
|
21
21
|
'Programming Language :: Python :: 3.11',
|
|
22
22
|
'License :: OSI Approved :: MIT License',
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.2
|
|
2
2
|
Name: xemonity
|
|
3
|
-
Version:
|
|
3
|
+
Version: 3.0
|
|
4
4
|
Summary: Libraly for simple menu with chosing
|
|
5
5
|
Home-page: https://github.com/MurzikYEET/Xemonity
|
|
6
6
|
Author: murzik_kukushnik
|
|
@@ -13,7 +13,6 @@ Classifier: Operating System :: OS Independent
|
|
|
13
13
|
Requires-Python: >=3.6
|
|
14
14
|
Description-Content-Type: text/markdown
|
|
15
15
|
License-File: LICENSE
|
|
16
|
-
Requires-Dist: pynput
|
|
17
16
|
Dynamic: author
|
|
18
17
|
Dynamic: author-email
|
|
19
18
|
Dynamic: classifier
|
|
@@ -22,12 +21,11 @@ Dynamic: description-content-type
|
|
|
22
21
|
Dynamic: home-page
|
|
23
22
|
Dynamic: keywords
|
|
24
23
|
Dynamic: project-url
|
|
25
|
-
Dynamic: requires-dist
|
|
26
24
|
Dynamic: requires-python
|
|
27
25
|
Dynamic: summary
|
|
28
26
|
|
|
29
27
|
# Xemonity
|
|
30
|
-
Xemonity - Python3 lib for simple menu
|
|
28
|
+
Xemonity - Python3 lib for simple choose menu ~~mained on pynput ~~
|
|
31
29
|
## How to use?
|
|
32
30
|
Code look as
|
|
33
31
|
```python
|
|
@@ -49,12 +47,12 @@ Three
|
|
|
49
47
|
`Xemonity.XemonityAM(elements:list,title:str)`
|
|
50
48
|
Main class for menu
|
|
51
49
|
1. `XemonityAM.cursor` : int var : return a current selected element index
|
|
52
|
-
2. `XemonityAM.title` : str var : just a title, shows
|
|
50
|
+
2. `XemonityAM.title` : str var : just a title, shows before elements
|
|
53
51
|
3. `XemonityAM.elements` : list var : list of elements (this is not recommended for modification)
|
|
54
52
|
4. `XemonityAM.relist(newlist:list)` : None func : change list of elements
|
|
55
53
|
5. `XemonityAM.show_sync()` : str func : show menu and return choosed element, if choosen ":Cancel" then method returns ":CANCELED"
|
|
56
54
|
Other methods not for you
|
|
57
55
|
## Credits
|
|
58
|
-
[https://pypi.org/user/moses.palmer/] : made pynput lib
|
|
56
|
+
~~[https://pypi.org/user/moses.palmer/] : made pynput lib~~ Pynput not more used
|
|
59
57
|
## License
|
|
60
58
|
Licensed under MIT license
|
xemonity-2.0/Xemonity/classes.py
DELETED
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
from pynput import keyboard
|
|
2
|
-
from time import sleep as delay
|
|
3
|
-
import sys
|
|
4
|
-
import os
|
|
5
|
-
import termios
|
|
6
|
-
|
|
7
|
-
def open_alt_screen():
|
|
8
|
-
sys.stdout.write("\x1b[?1049h")
|
|
9
|
-
clear_screen()
|
|
10
|
-
|
|
11
|
-
def close_alt_screen():
|
|
12
|
-
#clear_screen()
|
|
13
|
-
sys.stdout.write("\x1b[?1049l")
|
|
14
|
-
|
|
15
|
-
def clear_screen():
|
|
16
|
-
if os.name == 'nt':
|
|
17
|
-
os.system('cls')
|
|
18
|
-
else:
|
|
19
|
-
os.system('clear')
|
|
20
|
-
|
|
21
|
-
class XemonityAM:
|
|
22
|
-
def __init__(self,elements:list,title:str):
|
|
23
|
-
self.cursor = 0
|
|
24
|
-
self.elements = elements
|
|
25
|
-
self.elements.append(":Cancel")
|
|
26
|
-
self.title = title
|
|
27
|
-
def update_screen(self,intertime=0.05):
|
|
28
|
-
clear_screen()
|
|
29
|
-
print(self.title)
|
|
30
|
-
if self.cursor >= 4:print("...")
|
|
31
|
-
for i in range(0,len(self.elements)):
|
|
32
|
-
if i+3 < self.cursor:
|
|
33
|
-
continue
|
|
34
|
-
if i == self.cursor: print(">>",end="")
|
|
35
|
-
print(self.elements[i])
|
|
36
|
-
delay(intertime)
|
|
37
|
-
|
|
38
|
-
def on_press(self,key:keyboard.Key):
|
|
39
|
-
try:
|
|
40
|
-
if key == keyboard.Key.down:
|
|
41
|
-
self.cursor += 1
|
|
42
|
-
if self.cursor >= len(self.elements):
|
|
43
|
-
self.cursor = 0
|
|
44
|
-
self.update_screen()
|
|
45
|
-
elif key == keyboard.Key.up:
|
|
46
|
-
self.cursor -= 1
|
|
47
|
-
if self.cursor <= -1:
|
|
48
|
-
self.cursor = len(self.elements)-1
|
|
49
|
-
self.update_screen()
|
|
50
|
-
elif key == keyboard.Key.enter:
|
|
51
|
-
self.returned = self.elements[self.cursor]
|
|
52
|
-
return False
|
|
53
|
-
except AttributeError:
|
|
54
|
-
pass
|
|
55
|
-
def on_release(self,key):
|
|
56
|
-
if key == keyboard.Key.esc:
|
|
57
|
-
return False
|
|
58
|
-
|
|
59
|
-
def relist(self,newlist:list):
|
|
60
|
-
self.elements = newlist
|
|
61
|
-
self.cursor = 0
|
|
62
|
-
def show_sync(self):
|
|
63
|
-
try:
|
|
64
|
-
self.cursor = 0
|
|
65
|
-
open_alt_screen()
|
|
66
|
-
self.update_screen()
|
|
67
|
-
with keyboard.Listener(on_press=self.on_press, on_release=self.on_release) as listener:listener.join()
|
|
68
|
-
if os.name != "nt":termios.tcflush(sys.stdin.fileno(), termios.TCIFLUSH)
|
|
69
|
-
if self.elements[self.cursor] == ":Cancel":return ":CANCELED"
|
|
70
|
-
else:return self.elements[self.cursor]
|
|
71
|
-
finally:
|
|
72
|
-
close_alt_screen()
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
pynput
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|