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.
@@ -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: 5.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
+ 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
- """WARNING : this class deprecated, please use XmntUIList with Button class"""
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
- clear_screen()
20
- print(self.title)
21
- if self.cursor >= 4:print("...")
22
- for i in range(0,len(self.elements)):
23
- if i+3 < self.cursor:continue
24
- if i == self.cursor: print(">>",end="")
25
- print(self.elements[i])
26
- delay(intertime)
27
- def relist(self,newlist:list):
28
- self.elements = newlist
29
- self.cursor = 0
30
- def show_sync(self):
31
- try:
32
- self.cursor = 0
33
- open_alt_screen()
34
- while True:
35
- self.update_screen()
36
- pressed = get_key()
37
-
38
- match pressed:
39
- case "DOWN":
40
- self.cursor += 1
41
- if self.cursor >= len(self.elements):self.cursor = 0
42
- self.update_screen()
43
- case "UP":
44
- self.cursor -= 1
45
- if self.cursor <= -1:self.cursor = len(self.elements)-1
46
- self.update_screen()
47
- case "ENTER":
48
- close_alt_screen()
49
- return self.elements[self.cursor]
50
- except:
51
- close_alt_screen()
52
- return ":CANCELED"
53
-
54
- class XmntUIList:
55
- def __init__(self,title=""):
56
- self.title = title
57
- self.elements = []
58
- self.cursor = 0
59
-
60
- self._bupdate = None
61
- self._aupdate = None
62
-
63
- self._breakme = False
64
- def bind_action(self,action:str,method):
65
- """Adds method for action (name of actions watch in DOCS.md)"""
66
- match action.lower():
67
- case "before update":self._bupdate = method
68
- case "after update":self._aupdate = method
69
- case _:raise Exception("Undefined action")
70
- def connect_element(self,element):
71
- """Add new element"""
72
- element.uilist = self
73
- self.elements.append(element)
74
- def clear_elements_list(self):
75
- """Remove all elements"""
76
- for i in self.elements:i.uilist = None
77
- self.elements.clear()
78
- def connect_element_list(self,elements:list,clear_before=True):
79
- """Clears list of elements and add new"""
80
- if clear_before:self.clear_elements_list()
81
- for i in elements:
82
- self.connect_element(i)
83
- def out_of(self):
84
- """Stop XmntUIList.show_sync()"""
85
- self._breakme = True
86
- def update_screen(self):
87
- clear_screen()
88
- if support_colorama:
89
- print(colorama.Back.WHITE+
90
- (self.title[:terminal_width()])+
91
- (" " * (terminal_width() - len(self.title))))
92
- print(colorama.Style.RESET_ALL,end="")
93
- else:
94
- print(self.title[:terminal_width()]+
95
- ("_" * min(0,terminal_width() - len(self.title))))
96
-
97
- visible_height = terminal_height() - 2
98
- if visible_height < 1: visible_height = 1
99
-
100
- offset = 0
101
- if self.cursor >= visible_height:
102
- offset = self.cursor - visible_height + 1
103
-
104
- for i in range(offset, offset + visible_height):
105
- if i >= len(self.elements):
106
- break
107
- if i == self.cursor:print("::",end="")
108
- else: print(" ",end="")
109
- self.elements[i].render()
110
- def show_sync(self,intertime=0.05):
111
- """Show interface"""
112
- while True:
113
- if self._bupdate != None:self._bupdate()
114
- if self._breakme:
115
- self._breakme = False
116
- break
117
- self.update_screen()
118
- try:pr = get_key()
119
- except KeyboardInterrupt:
120
- self._breakme = True
121
- continue
122
-
123
- match pr:
124
- case "DOWN":
125
- if self.cursor >= len(self.elements)-1:self.cursor = 0
126
- else:self.cursor += 1
127
- self.elements[self.cursor].when_acted("DOWN")
128
- case "UP":
129
- if self.cursor <= 0:self.cursor = len(self.elements)-1
130
- else:self.cursor -= 1
131
- self.elements[self.cursor].when_acted("UP")
132
- case "ENTER":
133
- self.elements[self.cursor].when_acted("ENTER")
134
- case "LEFT":
135
- self.elements[self.cursor].when_acted("LEFT")
136
- case "RIGHT":
137
- self.elements[self.cursor].when_acted("RIGHT")
138
- if self._aupdate != None:self._aupdate()
139
- delay(intertime)
140
- to_out = {}
141
- for i in self.elements:
142
- to_out[i.realname] = i.stdout
143
- clear_screen()
144
- close_alt_screen()
145
- return to_out
146
-
147
- class XUIL_Element:
148
- def __init__(self,realname,name="XmntUIList template"):
149
- """Main class for all UI elements"""
150
- self.uilist:XmntUIList = None
151
- self.name = name
152
- self.realname = realname
153
- self.stdout = ""
154
- def is_selected(self):
155
- """Return true if cursor in element"""
156
- return self.uilist.elements.count(self) >= 1
157
- def when_acted(self,action:str):
158
- """Called when user press arrows, enter and other buttons registred in get_key() method"""
159
- def render(self):
160
- """Called when XmntUIList.show_sync() try draw look"""
161
- print(self.name)
162
-
163
- class Button(XUIL_Element):
164
- def __init__(self,realname,title="Button",on_click=None):
165
- super().__init__(realname,title)
166
- self.on_click = on_click
167
- self.stdout = False
168
- def when_acted(self, action):
169
- if action == "ENTER":
170
- self.stdout = True
171
- if self.on_click:self.on_click()
172
- else:self.uilist.out_of()
173
- def render(self):
174
- print("|"+self.name+"|")
175
-
176
- class Label(XUIL_Element):
177
- def __init__(self, realname, label="I lable"):
178
- super().__init__(realname, label)
179
- self.label = label
180
- def render(self):
181
- print(self.label[:terminal_width() - (2 if self.is_selected else 0)])
182
-
183
- class Checkbox(XUIL_Element):
184
- def __init__(self, realname, name="Checkbox",default=False):
185
- super().__init__(realname, name)
186
- self.stdout = default
187
- def when_acted(self, action):
188
- if action == "LEFT" or action == "RIGHT" or action == "ENTER":
189
- self.stdout = not self.stdout
190
- def render(self):
191
- print(self.name + " : " + ("▉▉" if self.stdout else "░░"))
192
-
193
- class Slider(XUIL_Element):
194
- def __init__(self, realname, name="Slider", mini=0, default=50, maxi=100, step=1):
195
- super().__init__(realname, name)
196
- self.min = mini
197
- self.max = maxi
198
- self.stdout = default
199
- self.step = step
200
- def when_acted(self, action):
201
- if action == "LEFT":self.stdout = self.stdout if self.stdout < (self.min + self.step) else self.stdout - self.step
202
- if action == "RIGHT":self.stdout = self.stdout if self.stdout > (self.max - self.step) else self.stdout + self.step
203
- def render(self):
204
- normalized = (self.stdout - self.min) / (self.max - self.min)
205
- bar_width = terminal_width() - len(self.name) - len(str(self.stdout)) - 7
206
- to_fill = int(normalized * bar_width)
207
- to_skip = bar_width - to_fill
208
- print(self.name + f"({self.stdout})" + ":::" + ("▉" * to_fill) + ("░" * to_skip))
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
- 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
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='5.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'
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: 5.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
+ 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