xemonity 1.0__tar.gz → 2.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.0 → xemonity-2.0}/PKG-INFO +14 -4
- {xemonity-1.0 → xemonity-2.0}/README.md +13 -3
- xemonity-2.0/Xemonity/__init__.py +12 -0
- {xemonity-1.0 → xemonity-2.0}/Xemonity/classes.py +22 -14
- {xemonity-1.0 → xemonity-2.0}/setup.py +1 -1
- {xemonity-1.0 → xemonity-2.0}/xemonity.egg-info/PKG-INFO +14 -4
- xemonity-1.0/Xemonity/__init__.py +0 -6
- {xemonity-1.0 → xemonity-2.0}/LICENSE +0 -0
- {xemonity-1.0 → xemonity-2.0}/pyproject.toml +0 -0
- {xemonity-1.0 → xemonity-2.0}/setup.cfg +0 -0
- {xemonity-1.0 → xemonity-2.0}/xemonity.egg-info/SOURCES.txt +0 -0
- {xemonity-1.0 → xemonity-2.0}/xemonity.egg-info/dependency_links.txt +0 -0
- {xemonity-1.0 → xemonity-2.0}/xemonity.egg-info/requires.txt +0 -0
- {xemonity-1.0 → xemonity-2.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: 2.0
|
|
4
4
|
Summary: Libraly for simple menu with chosing
|
|
5
5
|
Home-page: https://github.com/MurzikYEET/Xemonity
|
|
6
6
|
Author: murzik_kukushnik
|
|
@@ -36,15 +36,25 @@ am = Xemonity.XemonityAM(elements=['one','two','three'],'Its a title') #make cla
|
|
|
36
36
|
result = am.show_sync() #show menu (only sync) and return choosed string as str()
|
|
37
37
|
print(result) #print result to screen
|
|
38
38
|
```
|
|
39
|
+
If you run this code, then you see next:
|
|
40
|
+
```
|
|
41
|
+
Test menu
|
|
42
|
+
>>One
|
|
43
|
+
Two
|
|
44
|
+
Three
|
|
45
|
+
:Cancel
|
|
46
|
+
```
|
|
47
|
+
`Test menu` is title. `>>` is choosen element. `:Cancel` for exit with output `:CANCELED`
|
|
39
48
|
## Classes and methods
|
|
40
49
|
`Xemonity.XemonityAM(elements:list,title:str)`
|
|
41
50
|
Main class for menu
|
|
42
51
|
1. `XemonityAM.cursor` : int var : return a current selected element index
|
|
43
52
|
2. `XemonityAM.title` : str var : just a title, shows over elements
|
|
44
|
-
3. `XemonityAM.elements` : list var : list of elements
|
|
45
|
-
4. `XemonityAM.
|
|
53
|
+
3. `XemonityAM.elements` : list var : list of elements (this is not recommended for modification)
|
|
54
|
+
4. `XemonityAM.relist(newlist:list)` : None func : change list of elements
|
|
55
|
+
5. `XemonityAM.show_sync()` : str func : show menu and return choosed element, if choosen ":Cancel" then method returns ":CANCELED"
|
|
46
56
|
Other methods not for you
|
|
47
57
|
## Credits
|
|
48
|
-
[https://pypi.org/user/moses.palmer/]
|
|
58
|
+
[https://pypi.org/user/moses.palmer/] : made pynput lib
|
|
49
59
|
## License
|
|
50
60
|
Licensed under MIT license
|
|
@@ -8,15 +8,25 @@ am = Xemonity.XemonityAM(elements=['one','two','three'],'Its a title') #make cla
|
|
|
8
8
|
result = am.show_sync() #show menu (only sync) and return choosed string as str()
|
|
9
9
|
print(result) #print result to screen
|
|
10
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`
|
|
11
20
|
## Classes and methods
|
|
12
21
|
`Xemonity.XemonityAM(elements:list,title:str)`
|
|
13
22
|
Main class for menu
|
|
14
23
|
1. `XemonityAM.cursor` : int var : return a current selected element index
|
|
15
24
|
2. `XemonityAM.title` : str var : just a title, shows over elements
|
|
16
|
-
3. `XemonityAM.elements` : list var : list of elements
|
|
17
|
-
4. `XemonityAM.
|
|
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"
|
|
18
28
|
Other methods not for you
|
|
19
29
|
## Credits
|
|
20
|
-
[https://pypi.org/user/moses.palmer/]
|
|
30
|
+
[https://pypi.org/user/moses.palmer/] : made pynput lib
|
|
21
31
|
## License
|
|
22
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)
|
|
@@ -2,10 +2,7 @@ from pynput import keyboard
|
|
|
2
2
|
from time import sleep as delay
|
|
3
3
|
import sys
|
|
4
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")
|
|
5
|
+
import termios
|
|
9
6
|
|
|
10
7
|
def open_alt_screen():
|
|
11
8
|
sys.stdout.write("\x1b[?1049h")
|
|
@@ -16,10 +13,8 @@ def close_alt_screen():
|
|
|
16
13
|
sys.stdout.write("\x1b[?1049l")
|
|
17
14
|
|
|
18
15
|
def clear_screen():
|
|
19
|
-
# Для Windows
|
|
20
16
|
if os.name == 'nt':
|
|
21
17
|
os.system('cls')
|
|
22
|
-
# Для Linux и macOS
|
|
23
18
|
else:
|
|
24
19
|
os.system('clear')
|
|
25
20
|
|
|
@@ -27,14 +22,19 @@ class XemonityAM:
|
|
|
27
22
|
def __init__(self,elements:list,title:str):
|
|
28
23
|
self.cursor = 0
|
|
29
24
|
self.elements = elements
|
|
25
|
+
self.elements.append(":Cancel")
|
|
30
26
|
self.title = title
|
|
31
|
-
def update_screen(self,intertime=0.
|
|
27
|
+
def update_screen(self,intertime=0.05):
|
|
32
28
|
clear_screen()
|
|
33
29
|
print(self.title)
|
|
30
|
+
if self.cursor >= 4:print("...")
|
|
34
31
|
for i in range(0,len(self.elements)):
|
|
32
|
+
if i+3 < self.cursor:
|
|
33
|
+
continue
|
|
35
34
|
if i == self.cursor: print(">>",end="")
|
|
36
35
|
print(self.elements[i])
|
|
37
36
|
delay(intertime)
|
|
37
|
+
|
|
38
38
|
def on_press(self,key:keyboard.Key):
|
|
39
39
|
try:
|
|
40
40
|
if key == keyboard.Key.down:
|
|
@@ -48,17 +48,25 @@ class XemonityAM:
|
|
|
48
48
|
self.cursor = len(self.elements)-1
|
|
49
49
|
self.update_screen()
|
|
50
50
|
elif key == keyboard.Key.enter:
|
|
51
|
-
close_alt_screen()
|
|
52
51
|
self.returned = self.elements[self.cursor]
|
|
53
52
|
return False
|
|
54
53
|
except AttributeError:
|
|
55
|
-
pass
|
|
54
|
+
pass
|
|
56
55
|
def on_release(self,key):
|
|
57
56
|
if key == keyboard.Key.esc:
|
|
58
57
|
return False
|
|
58
|
+
|
|
59
|
+
def relist(self,newlist:list):
|
|
60
|
+
self.elements = newlist
|
|
61
|
+
self.cursor = 0
|
|
59
62
|
def show_sync(self):
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
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,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.2
|
|
2
2
|
Name: xemonity
|
|
3
|
-
Version:
|
|
3
|
+
Version: 2.0
|
|
4
4
|
Summary: Libraly for simple menu with chosing
|
|
5
5
|
Home-page: https://github.com/MurzikYEET/Xemonity
|
|
6
6
|
Author: murzik_kukushnik
|
|
@@ -36,15 +36,25 @@ am = Xemonity.XemonityAM(elements=['one','two','three'],'Its a title') #make cla
|
|
|
36
36
|
result = am.show_sync() #show menu (only sync) and return choosed string as str()
|
|
37
37
|
print(result) #print result to screen
|
|
38
38
|
```
|
|
39
|
+
If you run this code, then you see next:
|
|
40
|
+
```
|
|
41
|
+
Test menu
|
|
42
|
+
>>One
|
|
43
|
+
Two
|
|
44
|
+
Three
|
|
45
|
+
:Cancel
|
|
46
|
+
```
|
|
47
|
+
`Test menu` is title. `>>` is choosen element. `:Cancel` for exit with output `:CANCELED`
|
|
39
48
|
## Classes and methods
|
|
40
49
|
`Xemonity.XemonityAM(elements:list,title:str)`
|
|
41
50
|
Main class for menu
|
|
42
51
|
1. `XemonityAM.cursor` : int var : return a current selected element index
|
|
43
52
|
2. `XemonityAM.title` : str var : just a title, shows over elements
|
|
44
|
-
3. `XemonityAM.elements` : list var : list of elements
|
|
45
|
-
4. `XemonityAM.
|
|
53
|
+
3. `XemonityAM.elements` : list var : list of elements (this is not recommended for modification)
|
|
54
|
+
4. `XemonityAM.relist(newlist:list)` : None func : change list of elements
|
|
55
|
+
5. `XemonityAM.show_sync()` : str func : show menu and return choosed element, if choosen ":Cancel" then method returns ":CANCELED"
|
|
46
56
|
Other methods not for you
|
|
47
57
|
## Credits
|
|
48
|
-
[https://pypi.org/user/moses.palmer/]
|
|
58
|
+
[https://pypi.org/user/moses.palmer/] : made pynput lib
|
|
49
59
|
## License
|
|
50
60
|
Licensed under MIT license
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|