jx-gui 1.0.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.
- jx_gui-1.0.0/LICENSE +21 -0
- jx_gui-1.0.0/PKG-INFO +73 -0
- jx_gui-1.0.0/README.md +55 -0
- jx_gui-1.0.0/pyproject.toml +27 -0
- jx_gui-1.0.0/setup.cfg +4 -0
- jx_gui-1.0.0/src/jx_gui/__init__.py +7 -0
- jx_gui-1.0.0/src/jx_gui/_core.py +250 -0
- jx_gui-1.0.0/src/jx_gui/_linux.py +7 -0
- jx_gui-1.0.0/src/jx_gui/_windows.py +12 -0
- jx_gui-1.0.0/src/jx_gui.egg-info/PKG-INFO +73 -0
- jx_gui-1.0.0/src/jx_gui.egg-info/SOURCES.txt +11 -0
- jx_gui-1.0.0/src/jx_gui.egg-info/dependency_links.txt +1 -0
- jx_gui-1.0.0/src/jx_gui.egg-info/top_level.txt +1 -0
jx_gui-1.0.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Mr. Inosuke
|
|
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.
|
jx_gui-1.0.0/PKG-INFO
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: jx_gui
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary: Turn simple print() and input() programs into a GUI window with one line of code.
|
|
5
|
+
Author-email: "Mr. Inosuke" <inosukehasibira149@gmail.com>
|
|
6
|
+
License-Expression: MIT
|
|
7
|
+
Keywords: gui,beginner,tkinter,print,input,education
|
|
8
|
+
Classifier: Development Status :: 4 - Beta
|
|
9
|
+
Classifier: Intended Audience :: Education
|
|
10
|
+
Classifier: Programming Language :: Python :: 3
|
|
11
|
+
Classifier: Operating System :: Microsoft :: Windows
|
|
12
|
+
Classifier: Operating System :: POSIX :: Linux
|
|
13
|
+
Classifier: Topic :: Education
|
|
14
|
+
Requires-Python: >=3.9
|
|
15
|
+
Description-Content-Type: text/markdown
|
|
16
|
+
License-File: LICENSE
|
|
17
|
+
Dynamic: license-file
|
|
18
|
+
|
|
19
|
+
# jx_gui
|
|
20
|
+
|
|
21
|
+
Turn a simple `print()` / `input()` program into a GUI window with one line.
|
|
22
|
+
Made for beginners who only know `print`, `input` and `if / else`.
|
|
23
|
+
|
|
24
|
+
## Install
|
|
25
|
+
|
|
26
|
+
```
|
|
27
|
+
pip install jx_gui
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
On Linux you may also need tkinter: `sudo apt install python3-tk`
|
|
31
|
+
|
|
32
|
+
## Use
|
|
33
|
+
|
|
34
|
+
Put your normal code inside a function, then pass that function to `win` (Windows) or `lix` (Linux):
|
|
35
|
+
|
|
36
|
+
```python
|
|
37
|
+
import jx_gui
|
|
38
|
+
|
|
39
|
+
def code():
|
|
40
|
+
num_1 = int(input("Number 1 : "))
|
|
41
|
+
num_2 = int(input("Number 2 : "))
|
|
42
|
+
op = input("Operator (+ - * /) : ")
|
|
43
|
+
|
|
44
|
+
if op == "+":
|
|
45
|
+
print("Result :", num_1 + num_2)
|
|
46
|
+
elif op == "-":
|
|
47
|
+
print("Result :", num_1 - num_2)
|
|
48
|
+
elif op == "*":
|
|
49
|
+
print("Result :", num_1 * num_2)
|
|
50
|
+
elif op == "/":
|
|
51
|
+
if num_2 == 0:
|
|
52
|
+
print("Cannot divide by 0")
|
|
53
|
+
else:
|
|
54
|
+
print("Result :", num_1 / num_2)
|
|
55
|
+
else:
|
|
56
|
+
print("Wrong operator")
|
|
57
|
+
|
|
58
|
+
jx_gui.win(code) # Windows
|
|
59
|
+
# jx_gui.lix(code) # Linux
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
Write `jx_gui.win(code)`, not `jx_gui.win(code())`.
|
|
63
|
+
|
|
64
|
+
## How it behaves
|
|
65
|
+
|
|
66
|
+
- `print()` shows the text in the window.
|
|
67
|
+
- `input("text")` shows the text above an input box. Press **Ok** (or Enter) to continue.
|
|
68
|
+
- Any `print()` or `input()` that is inside an `if / elif / else` appears as a popup with an **Ok** button.
|
|
69
|
+
- If your code crashes, the error is shown in the window and in a popup.
|
|
70
|
+
|
|
71
|
+
## License
|
|
72
|
+
|
|
73
|
+
MIT
|
jx_gui-1.0.0/README.md
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
# jx_gui
|
|
2
|
+
|
|
3
|
+
Turn a simple `print()` / `input()` program into a GUI window with one line.
|
|
4
|
+
Made for beginners who only know `print`, `input` and `if / else`.
|
|
5
|
+
|
|
6
|
+
## Install
|
|
7
|
+
|
|
8
|
+
```
|
|
9
|
+
pip install jx_gui
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
On Linux you may also need tkinter: `sudo apt install python3-tk`
|
|
13
|
+
|
|
14
|
+
## Use
|
|
15
|
+
|
|
16
|
+
Put your normal code inside a function, then pass that function to `win` (Windows) or `lix` (Linux):
|
|
17
|
+
|
|
18
|
+
```python
|
|
19
|
+
import jx_gui
|
|
20
|
+
|
|
21
|
+
def code():
|
|
22
|
+
num_1 = int(input("Number 1 : "))
|
|
23
|
+
num_2 = int(input("Number 2 : "))
|
|
24
|
+
op = input("Operator (+ - * /) : ")
|
|
25
|
+
|
|
26
|
+
if op == "+":
|
|
27
|
+
print("Result :", num_1 + num_2)
|
|
28
|
+
elif op == "-":
|
|
29
|
+
print("Result :", num_1 - num_2)
|
|
30
|
+
elif op == "*":
|
|
31
|
+
print("Result :", num_1 * num_2)
|
|
32
|
+
elif op == "/":
|
|
33
|
+
if num_2 == 0:
|
|
34
|
+
print("Cannot divide by 0")
|
|
35
|
+
else:
|
|
36
|
+
print("Result :", num_1 / num_2)
|
|
37
|
+
else:
|
|
38
|
+
print("Wrong operator")
|
|
39
|
+
|
|
40
|
+
jx_gui.win(code) # Windows
|
|
41
|
+
# jx_gui.lix(code) # Linux
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
Write `jx_gui.win(code)`, not `jx_gui.win(code())`.
|
|
45
|
+
|
|
46
|
+
## How it behaves
|
|
47
|
+
|
|
48
|
+
- `print()` shows the text in the window.
|
|
49
|
+
- `input("text")` shows the text above an input box. Press **Ok** (or Enter) to continue.
|
|
50
|
+
- Any `print()` or `input()` that is inside an `if / elif / else` appears as a popup with an **Ok** button.
|
|
51
|
+
- If your code crashes, the error is shown in the window and in a popup.
|
|
52
|
+
|
|
53
|
+
## License
|
|
54
|
+
|
|
55
|
+
MIT
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=77"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "jx_gui"
|
|
7
|
+
version = "1.0.0"
|
|
8
|
+
description = "Turn simple print() and input() programs into a GUI window with one line of code."
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
requires-python = ">=3.9"
|
|
11
|
+
license = "MIT"
|
|
12
|
+
license-files = ["LICENSE"]
|
|
13
|
+
authors = [
|
|
14
|
+
{ name = "Mr. Inosuke", email = "inosukehasibira149@gmail.com" },
|
|
15
|
+
]
|
|
16
|
+
keywords = ["gui", "beginner", "tkinter", "print", "input", "education"]
|
|
17
|
+
classifiers = [
|
|
18
|
+
"Development Status :: 4 - Beta",
|
|
19
|
+
"Intended Audience :: Education",
|
|
20
|
+
"Programming Language :: Python :: 3",
|
|
21
|
+
"Operating System :: Microsoft :: Windows",
|
|
22
|
+
"Operating System :: POSIX :: Linux",
|
|
23
|
+
"Topic :: Education",
|
|
24
|
+
]
|
|
25
|
+
|
|
26
|
+
[tool.setuptools.packages.find]
|
|
27
|
+
where = ["src"]
|
jx_gui-1.0.0/setup.cfg
ADDED
|
@@ -0,0 +1,250 @@
|
|
|
1
|
+
"""Shared engine for jx_gui (used by both the Windows and the Linux entry points)."""
|
|
2
|
+
|
|
3
|
+
import ast
|
|
4
|
+
import builtins
|
|
5
|
+
import linecache
|
|
6
|
+
import sys
|
|
7
|
+
import tkinter as tk
|
|
8
|
+
import traceback
|
|
9
|
+
from tkinter import ttk
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
class _Closed(Exception):
|
|
13
|
+
"""Raised inside the user's code when the window is closed."""
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
# ---------------------------------------------------------------------------
|
|
17
|
+
# Finding out whether a print()/input() call sits inside if / elif / else
|
|
18
|
+
# ---------------------------------------------------------------------------
|
|
19
|
+
|
|
20
|
+
_if_cache = {}
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
def _if_lines(filename):
|
|
24
|
+
"""Line numbers of the file that belong to an if / elif / else block."""
|
|
25
|
+
if filename not in _if_cache:
|
|
26
|
+
lines = set()
|
|
27
|
+
try:
|
|
28
|
+
tree = ast.parse("".join(linecache.getlines(filename)))
|
|
29
|
+
for node in ast.walk(tree):
|
|
30
|
+
if isinstance(node, ast.If):
|
|
31
|
+
end = getattr(node, "end_lineno", node.lineno)
|
|
32
|
+
lines.update(range(node.lineno, end + 1))
|
|
33
|
+
except Exception:
|
|
34
|
+
pass
|
|
35
|
+
_if_cache[filename] = lines
|
|
36
|
+
return _if_cache[filename]
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
def _in_if(depth):
|
|
40
|
+
try:
|
|
41
|
+
frame = sys._getframe(depth)
|
|
42
|
+
except ValueError:
|
|
43
|
+
return False
|
|
44
|
+
return frame.f_lineno in _if_lines(frame.f_code.co_filename)
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
# ---------------------------------------------------------------------------
|
|
48
|
+
# The window
|
|
49
|
+
# ---------------------------------------------------------------------------
|
|
50
|
+
|
|
51
|
+
class _App:
|
|
52
|
+
def __init__(self, title, font, mono):
|
|
53
|
+
self.font = font
|
|
54
|
+
self.closed = False
|
|
55
|
+
self.waiting = False
|
|
56
|
+
|
|
57
|
+
self.root = tk.Tk()
|
|
58
|
+
self.root.title(title)
|
|
59
|
+
self.root.geometry("560x460")
|
|
60
|
+
self.root.minsize(360, 300)
|
|
61
|
+
self.root.protocol("WM_DELETE_WINDOW", self._close)
|
|
62
|
+
self.answer = tk.StringVar(self.root)
|
|
63
|
+
|
|
64
|
+
bottom = ttk.Frame(self.root, padding=8)
|
|
65
|
+
bottom.pack(side="bottom", fill="x")
|
|
66
|
+
|
|
67
|
+
self.prompt = ttk.Label(bottom, text="", font=font, anchor="w", justify="left")
|
|
68
|
+
self.prompt.pack(fill="x")
|
|
69
|
+
|
|
70
|
+
row = ttk.Frame(bottom)
|
|
71
|
+
row.pack(fill="x", pady=(4, 0))
|
|
72
|
+
self.entry = ttk.Entry(row, font=font, state="disabled")
|
|
73
|
+
self.entry.pack(side="left", fill="x", expand=True)
|
|
74
|
+
self.ok = ttk.Button(row, text="Ok", state="disabled", command=self._submit)
|
|
75
|
+
self.ok.pack(side="left", padx=(8, 0))
|
|
76
|
+
self.entry.bind("<Return>", lambda e: self._submit())
|
|
77
|
+
|
|
78
|
+
area = ttk.Frame(self.root)
|
|
79
|
+
area.pack(side="top", fill="both", expand=True)
|
|
80
|
+
scroll = ttk.Scrollbar(area)
|
|
81
|
+
scroll.pack(side="right", fill="y")
|
|
82
|
+
self.out = tk.Text(area, state="disabled", wrap="word", font=mono,
|
|
83
|
+
padx=8, pady=8, relief="flat", yscrollcommand=scroll.set)
|
|
84
|
+
self.out.pack(side="left", fill="both", expand=True)
|
|
85
|
+
scroll.config(command=self.out.yview)
|
|
86
|
+
|
|
87
|
+
# -- closing ------------------------------------------------------------
|
|
88
|
+
|
|
89
|
+
def _close(self):
|
|
90
|
+
self.closed = True
|
|
91
|
+
if self.waiting:
|
|
92
|
+
self.answer.set("") # wake up the waiting input()/popup
|
|
93
|
+
else:
|
|
94
|
+
self.destroy()
|
|
95
|
+
|
|
96
|
+
def destroy(self):
|
|
97
|
+
try:
|
|
98
|
+
self.root.destroy()
|
|
99
|
+
except tk.TclError:
|
|
100
|
+
pass
|
|
101
|
+
|
|
102
|
+
def _check(self):
|
|
103
|
+
if self.closed:
|
|
104
|
+
raise _Closed()
|
|
105
|
+
|
|
106
|
+
# -- output -------------------------------------------------------------
|
|
107
|
+
|
|
108
|
+
def write(self, text):
|
|
109
|
+
self._check()
|
|
110
|
+
self.out.configure(state="normal")
|
|
111
|
+
self.out.insert("end", text)
|
|
112
|
+
self.out.see("end")
|
|
113
|
+
self.out.configure(state="disabled")
|
|
114
|
+
self.root.update_idletasks()
|
|
115
|
+
|
|
116
|
+
# -- waiting for the user -----------------------------------------------
|
|
117
|
+
|
|
118
|
+
def _submit(self):
|
|
119
|
+
if self.waiting:
|
|
120
|
+
self.answer.set(self.entry.get())
|
|
121
|
+
|
|
122
|
+
def _wait(self):
|
|
123
|
+
self.waiting = True
|
|
124
|
+
try:
|
|
125
|
+
self.root.wait_variable(self.answer)
|
|
126
|
+
finally:
|
|
127
|
+
self.waiting = False
|
|
128
|
+
self._check()
|
|
129
|
+
return self.answer.get()
|
|
130
|
+
|
|
131
|
+
# -- input inside the window --------------------------------------------
|
|
132
|
+
|
|
133
|
+
def ask(self, prompt):
|
|
134
|
+
self._check()
|
|
135
|
+
self.prompt.configure(text=prompt)
|
|
136
|
+
self.entry.configure(state="normal")
|
|
137
|
+
self.ok.configure(state="normal")
|
|
138
|
+
self.entry.delete(0, "end")
|
|
139
|
+
self.entry.focus_set()
|
|
140
|
+
try:
|
|
141
|
+
text = self._wait()
|
|
142
|
+
finally:
|
|
143
|
+
if not self.closed:
|
|
144
|
+
self.entry.configure(state="disabled")
|
|
145
|
+
self.ok.configure(state="disabled")
|
|
146
|
+
self.prompt.configure(text="")
|
|
147
|
+
self.write(prompt + text + "\n")
|
|
148
|
+
return text
|
|
149
|
+
|
|
150
|
+
# -- popup (used inside if / elif / else) -------------------------------
|
|
151
|
+
|
|
152
|
+
def popup(self, message, ask=False):
|
|
153
|
+
self._check()
|
|
154
|
+
top = tk.Toplevel(self.root)
|
|
155
|
+
top.title(self.root.title())
|
|
156
|
+
top.transient(self.root)
|
|
157
|
+
top.resizable(False, False)
|
|
158
|
+
|
|
159
|
+
frame = ttk.Frame(top, padding=16)
|
|
160
|
+
frame.pack()
|
|
161
|
+
ttk.Label(frame, text=message, font=self.font, wraplength=360,
|
|
162
|
+
justify="left").pack(anchor="w")
|
|
163
|
+
|
|
164
|
+
entry = None
|
|
165
|
+
if ask:
|
|
166
|
+
entry = ttk.Entry(frame, font=self.font, width=40)
|
|
167
|
+
entry.pack(fill="x", pady=(8, 0))
|
|
168
|
+
|
|
169
|
+
def done(event=None):
|
|
170
|
+
self.answer.set(entry.get() if entry is not None else "")
|
|
171
|
+
|
|
172
|
+
button = ttk.Button(frame, text="Ok", command=done)
|
|
173
|
+
button.pack(anchor="e", pady=(12, 0))
|
|
174
|
+
top.bind("<Return>", done)
|
|
175
|
+
top.protocol("WM_DELETE_WINDOW", done)
|
|
176
|
+
|
|
177
|
+
top.update_idletasks()
|
|
178
|
+
x = self.root.winfo_rootx() + (self.root.winfo_width() - top.winfo_reqwidth()) // 2
|
|
179
|
+
y = self.root.winfo_rooty() + (self.root.winfo_height() - top.winfo_reqheight()) // 2
|
|
180
|
+
top.geometry("+%d+%d" % (max(x, 0), max(y, 0)))
|
|
181
|
+
|
|
182
|
+
try:
|
|
183
|
+
top.wait_visibility()
|
|
184
|
+
top.grab_set()
|
|
185
|
+
except tk.TclError:
|
|
186
|
+
pass
|
|
187
|
+
(entry or button).focus_set()
|
|
188
|
+
|
|
189
|
+
try:
|
|
190
|
+
return self._wait()
|
|
191
|
+
finally:
|
|
192
|
+
try:
|
|
193
|
+
top.destroy()
|
|
194
|
+
except tk.TclError:
|
|
195
|
+
pass
|
|
196
|
+
|
|
197
|
+
|
|
198
|
+
# ---------------------------------------------------------------------------
|
|
199
|
+
# Public runner
|
|
200
|
+
# ---------------------------------------------------------------------------
|
|
201
|
+
|
|
202
|
+
def run(code, title, font, mono):
|
|
203
|
+
if not callable(code):
|
|
204
|
+
raise TypeError("jx_gui: pass the function itself, like win(code) - not win(code())")
|
|
205
|
+
|
|
206
|
+
app = _App(title, font, mono)
|
|
207
|
+
real_print = builtins.print
|
|
208
|
+
real_input = builtins.input
|
|
209
|
+
|
|
210
|
+
def _print(*args, sep=" ", end="\n", file=None, flush=False):
|
|
211
|
+
if file is not None:
|
|
212
|
+
return real_print(*args, sep=sep, end=end, file=file, flush=flush)
|
|
213
|
+
joiner = " " if sep is None else sep
|
|
214
|
+
text = joiner.join(str(a) for a in args) + ("\n" if end is None else end)
|
|
215
|
+
if _in_if(2):
|
|
216
|
+
if text.strip():
|
|
217
|
+
app.popup(text.rstrip("\n"))
|
|
218
|
+
else:
|
|
219
|
+
app.write(text)
|
|
220
|
+
|
|
221
|
+
def _input(prompt=""):
|
|
222
|
+
prompt = str(prompt)
|
|
223
|
+
if _in_if(2):
|
|
224
|
+
return app.popup(prompt, ask=True)
|
|
225
|
+
return app.ask(prompt)
|
|
226
|
+
|
|
227
|
+
builtins.print = _print
|
|
228
|
+
builtins.input = _input
|
|
229
|
+
try:
|
|
230
|
+
code()
|
|
231
|
+
except _Closed:
|
|
232
|
+
pass
|
|
233
|
+
except Exception as error:
|
|
234
|
+
try:
|
|
235
|
+
app.write("\n" + traceback.format_exc())
|
|
236
|
+
app.popup("Error: %s: %s" % (type(error).__name__, error))
|
|
237
|
+
except _Closed:
|
|
238
|
+
pass
|
|
239
|
+
finally:
|
|
240
|
+
builtins.print = real_print
|
|
241
|
+
builtins.input = real_input
|
|
242
|
+
|
|
243
|
+
if app.closed:
|
|
244
|
+
app.destroy()
|
|
245
|
+
return
|
|
246
|
+
try:
|
|
247
|
+
app.write("\n--- finished ---\n")
|
|
248
|
+
except _Closed:
|
|
249
|
+
return
|
|
250
|
+
app.root.mainloop()
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"""Windows entry point: jx_gui.win(code)"""
|
|
2
|
+
|
|
3
|
+
from ._core import run
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
def win(code, title="jx_gui"):
|
|
7
|
+
try: # sharp text on high-DPI screens
|
|
8
|
+
import ctypes
|
|
9
|
+
ctypes.windll.shcore.SetProcessDpiAwareness(1)
|
|
10
|
+
except Exception:
|
|
11
|
+
pass
|
|
12
|
+
run(code, title, ("Segoe UI", 11), ("Consolas", 11))
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: jx_gui
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary: Turn simple print() and input() programs into a GUI window with one line of code.
|
|
5
|
+
Author-email: "Mr. Inosuke" <inosukehasibira149@gmail.com>
|
|
6
|
+
License-Expression: MIT
|
|
7
|
+
Keywords: gui,beginner,tkinter,print,input,education
|
|
8
|
+
Classifier: Development Status :: 4 - Beta
|
|
9
|
+
Classifier: Intended Audience :: Education
|
|
10
|
+
Classifier: Programming Language :: Python :: 3
|
|
11
|
+
Classifier: Operating System :: Microsoft :: Windows
|
|
12
|
+
Classifier: Operating System :: POSIX :: Linux
|
|
13
|
+
Classifier: Topic :: Education
|
|
14
|
+
Requires-Python: >=3.9
|
|
15
|
+
Description-Content-Type: text/markdown
|
|
16
|
+
License-File: LICENSE
|
|
17
|
+
Dynamic: license-file
|
|
18
|
+
|
|
19
|
+
# jx_gui
|
|
20
|
+
|
|
21
|
+
Turn a simple `print()` / `input()` program into a GUI window with one line.
|
|
22
|
+
Made for beginners who only know `print`, `input` and `if / else`.
|
|
23
|
+
|
|
24
|
+
## Install
|
|
25
|
+
|
|
26
|
+
```
|
|
27
|
+
pip install jx_gui
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
On Linux you may also need tkinter: `sudo apt install python3-tk`
|
|
31
|
+
|
|
32
|
+
## Use
|
|
33
|
+
|
|
34
|
+
Put your normal code inside a function, then pass that function to `win` (Windows) or `lix` (Linux):
|
|
35
|
+
|
|
36
|
+
```python
|
|
37
|
+
import jx_gui
|
|
38
|
+
|
|
39
|
+
def code():
|
|
40
|
+
num_1 = int(input("Number 1 : "))
|
|
41
|
+
num_2 = int(input("Number 2 : "))
|
|
42
|
+
op = input("Operator (+ - * /) : ")
|
|
43
|
+
|
|
44
|
+
if op == "+":
|
|
45
|
+
print("Result :", num_1 + num_2)
|
|
46
|
+
elif op == "-":
|
|
47
|
+
print("Result :", num_1 - num_2)
|
|
48
|
+
elif op == "*":
|
|
49
|
+
print("Result :", num_1 * num_2)
|
|
50
|
+
elif op == "/":
|
|
51
|
+
if num_2 == 0:
|
|
52
|
+
print("Cannot divide by 0")
|
|
53
|
+
else:
|
|
54
|
+
print("Result :", num_1 / num_2)
|
|
55
|
+
else:
|
|
56
|
+
print("Wrong operator")
|
|
57
|
+
|
|
58
|
+
jx_gui.win(code) # Windows
|
|
59
|
+
# jx_gui.lix(code) # Linux
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
Write `jx_gui.win(code)`, not `jx_gui.win(code())`.
|
|
63
|
+
|
|
64
|
+
## How it behaves
|
|
65
|
+
|
|
66
|
+
- `print()` shows the text in the window.
|
|
67
|
+
- `input("text")` shows the text above an input box. Press **Ok** (or Enter) to continue.
|
|
68
|
+
- Any `print()` or `input()` that is inside an `if / elif / else` appears as a popup with an **Ok** button.
|
|
69
|
+
- If your code crashes, the error is shown in the window and in a popup.
|
|
70
|
+
|
|
71
|
+
## License
|
|
72
|
+
|
|
73
|
+
MIT
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
LICENSE
|
|
2
|
+
README.md
|
|
3
|
+
pyproject.toml
|
|
4
|
+
src/jx_gui/__init__.py
|
|
5
|
+
src/jx_gui/_core.py
|
|
6
|
+
src/jx_gui/_linux.py
|
|
7
|
+
src/jx_gui/_windows.py
|
|
8
|
+
src/jx_gui.egg-info/PKG-INFO
|
|
9
|
+
src/jx_gui.egg-info/SOURCES.txt
|
|
10
|
+
src/jx_gui.egg-info/dependency_links.txt
|
|
11
|
+
src/jx_gui.egg-info/top_level.txt
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
jx_gui
|