xemonity 3.0__tar.gz → 4.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-4.0/PKG-INFO ADDED
@@ -0,0 +1,36 @@
1
+ Metadata-Version: 2.2
2
+ Name: xemonity
3
+ Version: 4.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
xemonity-4.0/README.md ADDED
@@ -0,0 +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
10
+ Licensed under MIT license
@@ -0,0 +1,6 @@
1
+ try:
2
+ from .classes import *
3
+ except ImportError:
4
+ from classes import *
5
+
6
+ print("Hello from Xemonity\nGitHub : https://github.com/MurzikYEET/Xemonity")
@@ -0,0 +1,150 @@
1
+ from time import sleep as delay
2
+ try:
3
+ from .methods import *
4
+ except:
5
+ from methods import *
6
+
7
+ class XemonityAM:
8
+ def __init__(self,elements:list,title:str,append_cancel=True):
9
+ """WARNING : this class deprecated and has been deleted in version 5.0, please use XmntUIList with Button class"""
10
+ self.cursor = 0
11
+ self.elements = elements
12
+ if append_cancel:self.elements.append(":Cancel")
13
+ self.title = title
14
+ def update_screen(self,intertime=0.05):
15
+ clear_screen()
16
+ print(self.title)
17
+ if self.cursor >= 4:print("...")
18
+ for i in range(0,len(self.elements)):
19
+ if i+3 < self.cursor:continue
20
+ if i == self.cursor: print(">>",end="")
21
+ print(self.elements[i])
22
+ delay(intertime)
23
+ def relist(self,newlist:list):
24
+ self.elements = newlist
25
+ self.cursor = 0
26
+ def show_sync(self):
27
+ try:
28
+ self.cursor = 0
29
+ open_alt_screen()
30
+ while True:
31
+ self.update_screen()
32
+ pressed = get_key()
33
+
34
+ match pressed:
35
+ case "DOWN":
36
+ self.cursor += 1
37
+ if self.cursor >= len(self.elements):self.cursor = 0
38
+ self.update_screen()
39
+ case "UP":
40
+ self.cursor -= 1
41
+ if self.cursor <= -1:self.cursor = len(self.elements)-1
42
+ self.update_screen()
43
+ case "ENTER":
44
+ close_alt_screen()
45
+ return self.elements[self.cursor]
46
+ except:
47
+ close_alt_screen()
48
+ return ":CANCELED"
49
+
50
+ class XmntUIList:
51
+ def __init__(self,title=""):
52
+ self.title = title
53
+ self.elements = []
54
+ self.cursor = 0
55
+
56
+ self._breakme = False
57
+ def connect_element(self,element):
58
+ """Add new element"""
59
+ element.uilist = self
60
+ self.elements.append(element)
61
+ def clear_elements_list(self):
62
+ """Remove all elements"""
63
+ for i in self.elements:i.uilist = None
64
+ self.elements.clear()
65
+ def out_of(self):
66
+ """Stop XmntUIList.show_sync()"""
67
+ self._breakme = True
68
+ def update_screen(self):
69
+ clear_screen()
70
+ print(self.title[:terminal_width()]+("_" * min(0,terminal_width() - len(self.title))))
71
+
72
+ visible_height = terminal_height() - 2
73
+ if visible_height < 1: visible_height = 1
74
+
75
+ offset = 0
76
+ if self.cursor >= visible_height:
77
+ offset = self.cursor - visible_height + 1
78
+
79
+ for i in range(offset, offset + visible_height):
80
+ if i >= len(self.elements):
81
+ break
82
+ if i == self.cursor:print("::",end="")
83
+ else: print(" ",end="")
84
+ self.elements[i].render()
85
+ def show_sync(self,intertime=0.05):
86
+ """Show interface"""
87
+ while True:
88
+ if self._breakme:
89
+ self._breakme = True
90
+ break
91
+ self.update_screen()
92
+ try:pr = get_key()
93
+ except KeyboardInterrupt:break
94
+
95
+ match pr:
96
+ case "DOWN":
97
+ if self.cursor >= len(self.elements)-1:self.cursor = 0
98
+ else:self.cursor += 1
99
+ self.elements[self.cursor].when_acted("DOWN")
100
+ case "UP":
101
+ if self.cursor <= 0:self.cursor = len(self.elements)-1
102
+ else:self.cursor -= 1
103
+ self.elements[self.cursor].when_acted("UP")
104
+ case "ENTER":
105
+ self.elements[self.cursor].when_acted("ENTER")
106
+ case "LEFT":
107
+ self.elements[self.cursor].when_acted("LEFT")
108
+ case "RIGHT":
109
+ self.elements[self.cursor].when_acted("RIGHT")
110
+ delay(intertime)
111
+ to_out = {}
112
+ for i in self.elements:
113
+ to_out[i.realname] = i.stdout
114
+ clear_screen()
115
+ close_alt_screen()
116
+ return to_out
117
+
118
+ class XUIL_Element:
119
+ def __init__(self,realname,name="XmntUIList template"):
120
+ """its init"""
121
+ self.uilist:XmntUIList = None
122
+ self.name = name
123
+ self.realname = realname
124
+ self.stdout = ""
125
+ def is_selected(self):
126
+ """Return true if cursor in element"""
127
+ return self.uilist.elements.count(self) >= 1
128
+ def when_acted(self,action:str):
129
+ """Called when user press arrows, enter and other buttons registred in get_key() method"""
130
+ def render(self):
131
+ """Called when XmntUIList.show_sync() try draw look"""
132
+ print(self.name)
133
+
134
+ class Button(XUIL_Element):
135
+ def __init__(self,realname,title="Button"):
136
+ super().__init__(realname,title)
137
+ self.stdout = False
138
+ def when_acted(self, action):
139
+ if action == "ENTER":
140
+ self.stdout = True
141
+ self.uilist.out_of()
142
+ def render(self):
143
+ print("|"+self.name+"|")
144
+
145
+ class Label(XUIL_Element):
146
+ def __init__(self, realname, label="template"):
147
+ super().__init__(realname, label)
148
+ self.label = label
149
+ def render(self):
150
+ print(self.label[:terminal_width() - (2 if self.is_selected else 0)])
@@ -0,0 +1,66 @@
1
+ import os
2
+ import sys
3
+ if os.name == "nt":
4
+ import msvcrt
5
+ else:
6
+ import termios
7
+ import tty
8
+
9
+ def open_alt_screen():
10
+ sys.stdout.write("\x1b[?1049h")
11
+ clear_screen()
12
+
13
+ def close_alt_screen():
14
+ #clear_screen()
15
+ sys.stdout.write("\x1b[?1049l")
16
+
17
+ def clear_screen():
18
+ if is_windows():
19
+ os.system('cls')
20
+ else:
21
+ os.system('clear')
22
+
23
+ def get_key_posix(): #for unix-like os (MacOS,Linux,*BSD and other)
24
+ fd = sys.stdin.fileno()
25
+ old_settings = termios.tcgetattr(fd)
26
+ try:
27
+ tty.setraw(fd)
28
+ ch = sys.stdin.read(1)
29
+ if ch == '\x1b': #Arrows
30
+ ch += sys.stdin.read(2)
31
+ if ch == '\x1b[A': return 'UP'
32
+ if ch == '\x1b[B': return 'DOWN'
33
+ if ch == '\x1b[C': return 'RIGHT'
34
+ if ch == '\x1b[D': return 'LEFT'
35
+ return None
36
+ elif ch == '\r': # Enter
37
+ return 'ENTER'
38
+ elif ch == '\x03': # Ctrl+C
39
+ raise KeyboardInterrupt
40
+ return ch
41
+ finally:
42
+ termios.tcsetattr(fd, termios.TCSADRAIN, old_settings)
43
+
44
+ def get_key_nt(): #for NT-like os (Windows)
45
+ ch = msvcrt.getch()
46
+ if ch in (b'\x00', b'\xe0'): #Arrows
47
+ ch = msvcrt.getch()
48
+ if ch == b'H': return 'UP'
49
+ if ch == b'P': return 'DOWN'
50
+ if ch == b'K': return 'LEFT'
51
+ if ch == b'M': return 'RIGHT'
52
+ return None
53
+
54
+ if ch == b'\r': return 'ENTER' #Enter
55
+ if ch == b'\x03': raise KeyboardInterrupt # Ctrl+C
56
+
57
+ return ch.decode('utf-8', errors='ignore')
58
+
59
+ def get_key(): #universal
60
+ if is_windows():return get_key_nt()
61
+ else:return get_key_posix()
62
+
63
+ def min(minval,x):return x if x > minval else minval
64
+ def is_windows():return os.name == "nt"
65
+ def terminal_width():return os.get_terminal_size().columns
66
+ def terminal_height():return os.get_terminal_size().lines
@@ -8,10 +8,10 @@ def readme():
8
8
 
9
9
  setup(
10
10
  name='xemonity',
11
- version='3.0',
11
+ version='4.0',
12
12
  author='murzik_kukushnik',
13
13
  author_email='siniykoshara@gmail.com',
14
- description='Libraly for simple menu with chosing',
14
+ description='Libraly for simple terminal ui',
15
15
  long_description=readme(),
16
16
  long_description_content_type='text/markdown',
17
17
  url='https://github.com/MurzikYEET/Xemonity',
@@ -22,7 +22,7 @@ setup(
22
22
  'License :: OSI Approved :: MIT License',
23
23
  'Operating System :: OS Independent'
24
24
  ],
25
- keywords='menu choose choice',
25
+ keywords='menu ui gui tui',
26
26
  project_urls={
27
27
  "GitHub" : "https://github.com/MurzikYEET/Xemonity"
28
28
  },
@@ -0,0 +1,36 @@
1
+ Metadata-Version: 2.2
2
+ Name: xemonity
3
+ Version: 4.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
@@ -5,6 +5,7 @@ setup.cfg
5
5
  setup.py
6
6
  Xemonity/__init__.py
7
7
  Xemonity/classes.py
8
+ Xemonity/methods.py
8
9
  xemonity.egg-info/PKG-INFO
9
10
  xemonity.egg-info/SOURCES.txt
10
11
  xemonity.egg-info/dependency_links.txt
xemonity-3.0/PKG-INFO DELETED
@@ -1,58 +0,0 @@
1
- Metadata-Version: 2.2
2
- Name: xemonity
3
- Version: 3.0
4
- Summary: Libraly for simple menu with chosing
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 choose choice
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 simple choose menu ~~mained on pynput ~~
29
- ## How to use?
30
- Code look as
31
- ```python
32
- import Xemonity #import lib
33
- am = Xemonity.XemonityAM(elements=['one','two','three'],'Its a title') #make class with elements and title
34
- result = am.show_sync() #show menu (only sync) and return choosed string as str()
35
- print(result) #print result to screen
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`
46
- ## Classes and methods
47
- `Xemonity.XemonityAM(elements:list,title:str)`
48
- Main class for menu
49
- 1. `XemonityAM.cursor` : int var : return a current selected element index
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"
54
- Other methods not for you
55
- ## Credits
56
- ~~[https://pypi.org/user/moses.palmer/] : made pynput lib~~ Pynput not more used
57
- ## License
58
- Licensed under MIT license
xemonity-3.0/README.md DELETED
@@ -1,32 +0,0 @@
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
@@ -1,12 +0,0 @@
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)
@@ -1,100 +0,0 @@
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"
@@ -1,58 +0,0 @@
1
- Metadata-Version: 2.2
2
- Name: xemonity
3
- Version: 3.0
4
- Summary: Libraly for simple menu with chosing
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 choose choice
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 simple choose menu ~~mained on pynput ~~
29
- ## How to use?
30
- Code look as
31
- ```python
32
- import Xemonity #import lib
33
- am = Xemonity.XemonityAM(elements=['one','two','three'],'Its a title') #make class with elements and title
34
- result = am.show_sync() #show menu (only sync) and return choosed string as str()
35
- print(result) #print result to screen
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`
46
- ## Classes and methods
47
- `Xemonity.XemonityAM(elements:list,title:str)`
48
- Main class for menu
49
- 1. `XemonityAM.cursor` : int var : return a current selected element index
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"
54
- Other methods not for you
55
- ## Credits
56
- ~~[https://pypi.org/user/moses.palmer/] : made pynput lib~~ Pynput not more used
57
- ## License
58
- Licensed under MIT license
File without changes
File without changes
File without changes