xemonity 1.1__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-1.1 → xemonity-3.0}/PKG-INFO +16 -8
- xemonity-3.0/README.md +32 -0
- xemonity-3.0/Xemonity/__init__.py +12 -0
- xemonity-3.0/Xemonity/classes.py +100 -0
- {xemonity-1.1 → xemonity-3.0}/setup.py +2 -2
- {xemonity-1.1 → xemonity-3.0}/xemonity.egg-info/PKG-INFO +16 -8
- {xemonity-1.1 → xemonity-3.0}/xemonity.egg-info/SOURCES.txt +0 -1
- xemonity-1.1/README.md +0 -22
- xemonity-1.1/Xemonity/__init__.py +0 -6
- xemonity-1.1/Xemonity/classes.py +0 -64
- xemonity-1.1/xemonity.egg-info/requires.txt +0 -1
- {xemonity-1.1 → xemonity-3.0}/LICENSE +0 -0
- {xemonity-1.1 → xemonity-3.0}/pyproject.toml +0 -0
- {xemonity-1.1 → xemonity-3.0}/setup.cfg +0 -0
- {xemonity-1.1 → xemonity-3.0}/xemonity.egg-info/dependency_links.txt +0 -0
- {xemonity-1.1 → 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
|
|
@@ -36,15 +34,25 @@ am = Xemonity.XemonityAM(elements=['one','two','three'],'Its a title') #make cla
|
|
|
36
34
|
result = am.show_sync() #show menu (only sync) and return choosed string as str()
|
|
37
35
|
print(result) #print result to screen
|
|
38
36
|
```
|
|
37
|
+
If you run this code, then you see next:
|
|
38
|
+
```
|
|
39
|
+
Test menu
|
|
40
|
+
>>One
|
|
41
|
+
Two
|
|
42
|
+
Three
|
|
43
|
+
:Cancel
|
|
44
|
+
```
|
|
45
|
+
`Test menu` is title. `>>` is choosen element. `:Cancel` for exit with output `:CANCELED`
|
|
39
46
|
## Classes and methods
|
|
40
47
|
`Xemonity.XemonityAM(elements:list,title:str)`
|
|
41
48
|
Main class for menu
|
|
42
49
|
1. `XemonityAM.cursor` : int var : return a current selected element index
|
|
43
|
-
2. `XemonityAM.title` : str var : just a title, shows
|
|
44
|
-
3. `XemonityAM.elements` : list var : list of elements
|
|
45
|
-
4. `XemonityAM.
|
|
50
|
+
2. `XemonityAM.title` : str var : just a title, shows before elements
|
|
51
|
+
3. `XemonityAM.elements` : list var : list of elements (this is not recommended for modification)
|
|
52
|
+
4. `XemonityAM.relist(newlist:list)` : None func : change list of elements
|
|
53
|
+
5. `XemonityAM.show_sync()` : str func : show menu and return choosed element, if choosen ":Cancel" then method returns ":CANCELED"
|
|
46
54
|
Other methods not for you
|
|
47
55
|
## Credits
|
|
48
|
-
[https://pypi.org/user/moses.palmer/]
|
|
56
|
+
~~[https://pypi.org/user/moses.palmer/] : made pynput lib~~ Pynput not more used
|
|
49
57
|
## License
|
|
50
58
|
Licensed under MIT license
|
xemonity-3.0/README.md
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
# Xemonity
|
|
2
|
+
Xemonity - Python3 lib for simple choose menu ~~mained on pynput ~~
|
|
3
|
+
## How to use?
|
|
4
|
+
Code look as
|
|
5
|
+
```python
|
|
6
|
+
import Xemonity #import lib
|
|
7
|
+
am = Xemonity.XemonityAM(elements=['one','two','three'],'Its a title') #make class with elements and title
|
|
8
|
+
result = am.show_sync() #show menu (only sync) and return choosed string as str()
|
|
9
|
+
print(result) #print result to screen
|
|
10
|
+
```
|
|
11
|
+
If you run this code, then you see next:
|
|
12
|
+
```
|
|
13
|
+
Test menu
|
|
14
|
+
>>One
|
|
15
|
+
Two
|
|
16
|
+
Three
|
|
17
|
+
:Cancel
|
|
18
|
+
```
|
|
19
|
+
`Test menu` is title. `>>` is choosen element. `:Cancel` for exit with output `:CANCELED`
|
|
20
|
+
## Classes and methods
|
|
21
|
+
`Xemonity.XemonityAM(elements:list,title:str)`
|
|
22
|
+
Main class for menu
|
|
23
|
+
1. `XemonityAM.cursor` : int var : return a current selected element index
|
|
24
|
+
2. `XemonityAM.title` : str var : just a title, shows before elements
|
|
25
|
+
3. `XemonityAM.elements` : list var : list of elements (this is not recommended for modification)
|
|
26
|
+
4. `XemonityAM.relist(newlist:list)` : None func : change list of elements
|
|
27
|
+
5. `XemonityAM.show_sync()` : str func : show menu and return choosed element, if choosen ":Cancel" then method returns ":CANCELED"
|
|
28
|
+
Other methods not for you
|
|
29
|
+
## Credits
|
|
30
|
+
~~[https://pypi.org/user/moses.palmer/] : made pynput lib~~ Pynput not more used
|
|
31
|
+
## License
|
|
32
|
+
Licensed under MIT license
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
try:
|
|
2
|
+
from .classes import *
|
|
3
|
+
except ImportError:
|
|
4
|
+
from classes import *
|
|
5
|
+
|
|
6
|
+
if __name__ == "__main__":
|
|
7
|
+
menu = XemonityAM(["One","Two","Three","Four","Five","Six","Seven"],"Test menu")
|
|
8
|
+
answer = menu.show_sync()
|
|
9
|
+
print(answer)
|
|
10
|
+
menu.elements = ["Yes","No"]
|
|
11
|
+
answer = menu.show_sync()
|
|
12
|
+
print(answer)
|
|
@@ -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
|
|
@@ -36,15 +34,25 @@ am = Xemonity.XemonityAM(elements=['one','two','three'],'Its a title') #make cla
|
|
|
36
34
|
result = am.show_sync() #show menu (only sync) and return choosed string as str()
|
|
37
35
|
print(result) #print result to screen
|
|
38
36
|
```
|
|
37
|
+
If you run this code, then you see next:
|
|
38
|
+
```
|
|
39
|
+
Test menu
|
|
40
|
+
>>One
|
|
41
|
+
Two
|
|
42
|
+
Three
|
|
43
|
+
:Cancel
|
|
44
|
+
```
|
|
45
|
+
`Test menu` is title. `>>` is choosen element. `:Cancel` for exit with output `:CANCELED`
|
|
39
46
|
## Classes and methods
|
|
40
47
|
`Xemonity.XemonityAM(elements:list,title:str)`
|
|
41
48
|
Main class for menu
|
|
42
49
|
1. `XemonityAM.cursor` : int var : return a current selected element index
|
|
43
|
-
2. `XemonityAM.title` : str var : just a title, shows
|
|
44
|
-
3. `XemonityAM.elements` : list var : list of elements
|
|
45
|
-
4. `XemonityAM.
|
|
50
|
+
2. `XemonityAM.title` : str var : just a title, shows before elements
|
|
51
|
+
3. `XemonityAM.elements` : list var : list of elements (this is not recommended for modification)
|
|
52
|
+
4. `XemonityAM.relist(newlist:list)` : None func : change list of elements
|
|
53
|
+
5. `XemonityAM.show_sync()` : str func : show menu and return choosed element, if choosen ":Cancel" then method returns ":CANCELED"
|
|
46
54
|
Other methods not for you
|
|
47
55
|
## Credits
|
|
48
|
-
[https://pypi.org/user/moses.palmer/]
|
|
56
|
+
~~[https://pypi.org/user/moses.palmer/] : made pynput lib~~ Pynput not more used
|
|
49
57
|
## License
|
|
50
58
|
Licensed under MIT license
|
xemonity-1.1/README.md
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
# Xemonity
|
|
2
|
-
Xemonity - Python3 lib for simple menu with choose mained on pynput
|
|
3
|
-
## How to use?
|
|
4
|
-
Code look as
|
|
5
|
-
```python
|
|
6
|
-
import Xemonity #import lib
|
|
7
|
-
am = Xemonity.XemonityAM(elements=['one','two','three'],'Its a title') #make class with elements and title
|
|
8
|
-
result = am.show_sync() #show menu (only sync) and return choosed string as str()
|
|
9
|
-
print(result) #print result to screen
|
|
10
|
-
```
|
|
11
|
-
## Classes and methods
|
|
12
|
-
`Xemonity.XemonityAM(elements:list,title:str)`
|
|
13
|
-
Main class for menu
|
|
14
|
-
1. `XemonityAM.cursor` : int var : return a current selected element index
|
|
15
|
-
2. `XemonityAM.title` : str var : just a title, shows over elements
|
|
16
|
-
3. `XemonityAM.elements` : list var : list of elements
|
|
17
|
-
4. `XemonityAM.show_sync()` : str func : show menu and return choosed element
|
|
18
|
-
Other methods not for you
|
|
19
|
-
## Credits
|
|
20
|
-
[https://pypi.org/user/moses.palmer/](moses.palmer) : made pynput lib
|
|
21
|
-
## License
|
|
22
|
-
Licensed under MIT license
|
xemonity-1.1/Xemonity/classes.py
DELETED
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
from pynput import keyboard
|
|
2
|
-
from time import sleep as delay
|
|
3
|
-
import sys
|
|
4
|
-
import os
|
|
5
|
-
|
|
6
|
-
#def on_next():return pynput.keyboard.Listener.
|
|
7
|
-
#def on_prev():return keyboard.is_pressed("up")
|
|
8
|
-
#def on_enter():return keyboard.is_pressed("enter")
|
|
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
|
-
# Для Windows
|
|
20
|
-
if os.name == 'nt':
|
|
21
|
-
os.system('cls')
|
|
22
|
-
# Для Linux и macOS
|
|
23
|
-
else:
|
|
24
|
-
os.system('clear')
|
|
25
|
-
|
|
26
|
-
class XemonityAM:
|
|
27
|
-
def __init__(self,elements:list,title:str):
|
|
28
|
-
self.cursor = 0
|
|
29
|
-
self.elements = elements
|
|
30
|
-
self.title = title
|
|
31
|
-
def update_screen(self,intertime=0.25):
|
|
32
|
-
clear_screen()
|
|
33
|
-
print(self.title)
|
|
34
|
-
for i in range(0,len(self.elements)):
|
|
35
|
-
if i == self.cursor: print(">>",end="")
|
|
36
|
-
print(self.elements[i])
|
|
37
|
-
delay(intertime)
|
|
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
|
-
close_alt_screen()
|
|
52
|
-
self.returned = self.elements[self.cursor]
|
|
53
|
-
return False
|
|
54
|
-
except AttributeError:
|
|
55
|
-
pass#print(f'Нажата спецклавиша: {key}')
|
|
56
|
-
def on_release(self,key):
|
|
57
|
-
if key == keyboard.Key.esc:
|
|
58
|
-
return False
|
|
59
|
-
def show_sync(self):
|
|
60
|
-
open_alt_screen()
|
|
61
|
-
self.update_screen()
|
|
62
|
-
with keyboard.Listener(on_press=self.on_press, on_release=self.on_release) as listener:
|
|
63
|
-
listener.join()
|
|
64
|
-
return self.elements[self.cursor]
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
pynput
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|