novy 0.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.
- novy-0.2.0/PKG-INFO +7 -0
- novy-0.2.0/kres/__init__.py +1 -0
- novy-0.2.0/kres/core.py +254 -0
- novy-0.2.0/novy.egg-info/PKG-INFO +7 -0
- novy-0.2.0/novy.egg-info/SOURCES.txt +7 -0
- novy-0.2.0/novy.egg-info/dependency_links.txt +1 -0
- novy-0.2.0/novy.egg-info/top_level.txt +1 -0
- novy-0.2.0/pyproject.toml +11 -0
- novy-0.2.0/setup.cfg +4 -0
novy-0.2.0/PKG-INFO
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
from .core import *
|
novy-0.2.0/kres/core.py
ADDED
|
@@ -0,0 +1,254 @@
|
|
|
1
|
+
from tkinter import *
|
|
2
|
+
import tkinter as tk
|
|
3
|
+
|
|
4
|
+
# =========================
|
|
5
|
+
# CORE
|
|
6
|
+
# =========================
|
|
7
|
+
|
|
8
|
+
root = None
|
|
9
|
+
canvas = None
|
|
10
|
+
WIDTH = 800
|
|
11
|
+
HEIGHT = 600
|
|
12
|
+
|
|
13
|
+
# =========================
|
|
14
|
+
# WINDOW
|
|
15
|
+
# =========================
|
|
16
|
+
|
|
17
|
+
def window(width=800, height=600, title="Python+ Engine"):
|
|
18
|
+
global root, canvas, WIDTH, HEIGHT
|
|
19
|
+
|
|
20
|
+
WIDTH = width
|
|
21
|
+
HEIGHT = height
|
|
22
|
+
|
|
23
|
+
root = Tk()
|
|
24
|
+
root.title(title)
|
|
25
|
+
|
|
26
|
+
canvas = Canvas(root, width=width, height=height, bg="white")
|
|
27
|
+
canvas.pack(fill=BOTH, expand=True)
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
def speed_window(width=800, height=600, title="Speed Mode"):
|
|
31
|
+
global root, canvas, WIDTH, HEIGHT
|
|
32
|
+
|
|
33
|
+
WIDTH = width
|
|
34
|
+
HEIGHT = height
|
|
35
|
+
|
|
36
|
+
root = tk.Tk()
|
|
37
|
+
root.title(title)
|
|
38
|
+
|
|
39
|
+
canvas = tk.Canvas(root, width=width, height=height, bg="white")
|
|
40
|
+
canvas.pack(fill=tk.BOTH, expand=True)
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
# =========================
|
|
44
|
+
# COORD SYSTEM
|
|
45
|
+
# =========================
|
|
46
|
+
|
|
47
|
+
def _x(x): return WIDTH / 2 + x
|
|
48
|
+
def _y(y): return HEIGHT / 2 - y
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
# =========================
|
|
52
|
+
# NORMAL GUI
|
|
53
|
+
# =========================
|
|
54
|
+
|
|
55
|
+
def button(text, command, x=0, y=0):
|
|
56
|
+
b = Button(root, text=text, command=command)
|
|
57
|
+
canvas.create_window(_x(x), _y(y), window=b)
|
|
58
|
+
return b
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
def input_field(x=0, y=0, width=20):
|
|
62
|
+
e = Entry(root, width=width)
|
|
63
|
+
canvas.create_window(_x(x), _y(y), window=e)
|
|
64
|
+
return e
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
def text_widget(msg, x=0, y=0, size=20):
|
|
68
|
+
return canvas.create_text(
|
|
69
|
+
_x(x), _y(y),
|
|
70
|
+
text=msg,
|
|
71
|
+
font=("Arial", size)
|
|
72
|
+
)
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
# =========================
|
|
76
|
+
# DRAW
|
|
77
|
+
# =========================
|
|
78
|
+
|
|
79
|
+
def circle(r, x=0, y=0, color="black"):
|
|
80
|
+
return canvas.create_oval(
|
|
81
|
+
_x(x-r), _y(y+r),
|
|
82
|
+
_x(x+r), _y(y-r),
|
|
83
|
+
fill=color, outline=""
|
|
84
|
+
)
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
def rectangle(w, h, x=0, y=0, color="black"):
|
|
88
|
+
return canvas.create_rectangle(
|
|
89
|
+
_x(x-w/2), _y(y+h/2),
|
|
90
|
+
_x(x+w/2), _y(y-h/2),
|
|
91
|
+
fill=color, outline=""
|
|
92
|
+
)
|
|
93
|
+
|
|
94
|
+
|
|
95
|
+
def line(x1, y1, x2, y2, color="black", size=2):
|
|
96
|
+
return canvas.create_line(
|
|
97
|
+
_x(x1), _y(y1),
|
|
98
|
+
_x(x2), _y(y2),
|
|
99
|
+
fill=color,
|
|
100
|
+
width=size
|
|
101
|
+
)
|
|
102
|
+
|
|
103
|
+
|
|
104
|
+
def clear():
|
|
105
|
+
canvas.delete("all")
|
|
106
|
+
|
|
107
|
+
|
|
108
|
+
def show():
|
|
109
|
+
root.mainloop()
|
|
110
|
+
|
|
111
|
+
|
|
112
|
+
# =========================
|
|
113
|
+
# SPEED MODE ELEMENTS
|
|
114
|
+
# =========================
|
|
115
|
+
|
|
116
|
+
def speed_button(text, command, x=200, y=200):
|
|
117
|
+
r = tk.Tk()
|
|
118
|
+
r.title("Speed Button")
|
|
119
|
+
|
|
120
|
+
c = tk.Canvas(r, width=400, height=300, bg="white")
|
|
121
|
+
c.pack()
|
|
122
|
+
|
|
123
|
+
b = tk.Button(r, text=text, command=command)
|
|
124
|
+
c.create_window(x, y, window=b)
|
|
125
|
+
|
|
126
|
+
r.mainloop()
|
|
127
|
+
|
|
128
|
+
|
|
129
|
+
def speed_circle(r, x, y, color):
|
|
130
|
+
w = tk.Tk()
|
|
131
|
+
w.title("Speed Circle")
|
|
132
|
+
|
|
133
|
+
c = tk.Canvas(w, width=400, height=300, bg="white")
|
|
134
|
+
c.pack()
|
|
135
|
+
|
|
136
|
+
c.create_oval(x-r, y-r, x+r, y+r, fill=color, outline="")
|
|
137
|
+
w.mainloop()
|
|
138
|
+
|
|
139
|
+
|
|
140
|
+
def speed_rectangle(w, h, x, y, color):
|
|
141
|
+
win = tk.Tk()
|
|
142
|
+
win.title("Speed Rectangle")
|
|
143
|
+
|
|
144
|
+
c = tk.Canvas(win, width=400, height=300, bg="white")
|
|
145
|
+
c.pack()
|
|
146
|
+
|
|
147
|
+
c.create_rectangle(x-w/2, y-h/2, x+w/2, y+h/2, fill=color, outline="")
|
|
148
|
+
win.mainloop()
|
|
149
|
+
|
|
150
|
+
|
|
151
|
+
def speed_text(msg, x, y, color="black", size=20):
|
|
152
|
+
win = tk.Tk()
|
|
153
|
+
win.title("Speed Text")
|
|
154
|
+
|
|
155
|
+
c = tk.Canvas(win, width=400, height=300, bg="white")
|
|
156
|
+
c.pack()
|
|
157
|
+
|
|
158
|
+
c.create_text(x, y, text=msg, fill=color, font=("Arial", size))
|
|
159
|
+
win.mainloop()
|
|
160
|
+
|
|
161
|
+
|
|
162
|
+
# =========================
|
|
163
|
+
# HELP SYSTEM (GUI)
|
|
164
|
+
# =========================
|
|
165
|
+
|
|
166
|
+
def help(name=None):
|
|
167
|
+
if name is None:
|
|
168
|
+
_help_window()
|
|
169
|
+
else:
|
|
170
|
+
_help_detail(name)
|
|
171
|
+
|
|
172
|
+
|
|
173
|
+
def _help_window():
|
|
174
|
+
win = tk.Tk()
|
|
175
|
+
win.title("Help - Commands")
|
|
176
|
+
win.geometry("400x500")
|
|
177
|
+
|
|
178
|
+
Label(win, text="COMMANDS", font=("Arial", 16)).pack()
|
|
179
|
+
|
|
180
|
+
for k in _docs().keys():
|
|
181
|
+
Button(win, text=k, command=lambda x=k: _help_detail(x)).pack(fill="x")
|
|
182
|
+
|
|
183
|
+
win.mainloop()
|
|
184
|
+
|
|
185
|
+
|
|
186
|
+
def _help_detail(name):
|
|
187
|
+
win = tk.Tk()
|
|
188
|
+
win.title("Help: " + name)
|
|
189
|
+
win.geometry("500x300")
|
|
190
|
+
|
|
191
|
+
text = _docs().get(name, "No info")
|
|
192
|
+
|
|
193
|
+
Label(win, text=name, font=("Arial", 16, "bold")).pack(pady=10)
|
|
194
|
+
Label(win, text=text, wraplength=450, justify="left").pack()
|
|
195
|
+
|
|
196
|
+
win.mainloop()
|
|
197
|
+
|
|
198
|
+
|
|
199
|
+
def _docs():
|
|
200
|
+
return {
|
|
201
|
+
"window": "window() - main GUI window",
|
|
202
|
+
"speed_window": "speed_window() - fast test mode",
|
|
203
|
+
|
|
204
|
+
"button": "button(text, command, x, y)",
|
|
205
|
+
"input_field": "input_field(x, y)",
|
|
206
|
+
"text_widget": "text_widget(msg, x, y)",
|
|
207
|
+
|
|
208
|
+
"circle": "circle(r,x,y,color)",
|
|
209
|
+
"rectangle": "rectangle(w,h,x,y,color)",
|
|
210
|
+
"line": "line(x1,y1,x2,y2)",
|
|
211
|
+
|
|
212
|
+
"speed_button": "speed_button(...) quick test",
|
|
213
|
+
"speed_circle": "speed_circle(...) quick test",
|
|
214
|
+
"speed_text": "speed_text(...) quick test",
|
|
215
|
+
|
|
216
|
+
"template_game": "template_game('snake') - 1 click game"
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
|
|
220
|
+
# =========================
|
|
221
|
+
# GAME TEMPLATE (SNAKE)
|
|
222
|
+
# =========================
|
|
223
|
+
|
|
224
|
+
def template_game(name):
|
|
225
|
+
if name == "snake":
|
|
226
|
+
snake_game()
|
|
227
|
+
|
|
228
|
+
|
|
229
|
+
def snake_game():
|
|
230
|
+
window(800, 600, "Snake Game")
|
|
231
|
+
|
|
232
|
+
player = circle(20, 0, 0, "green")
|
|
233
|
+
|
|
234
|
+
direction = {"x": 20, "y": 0}
|
|
235
|
+
|
|
236
|
+
def move():
|
|
237
|
+
canvas.move(player, direction["x"], direction["y"])
|
|
238
|
+
root.after(120, move)
|
|
239
|
+
|
|
240
|
+
def key(event):
|
|
241
|
+
k = event.keysym
|
|
242
|
+
if k == "Left":
|
|
243
|
+
direction["x"], direction["y"] = -20, 0
|
|
244
|
+
if k == "Right":
|
|
245
|
+
direction["x"], direction["y"] = 20, 0
|
|
246
|
+
if k == "Up":
|
|
247
|
+
direction["x"], direction["y"] = 0, -20
|
|
248
|
+
if k == "Down":
|
|
249
|
+
direction["x"], direction["y"] = 0, 20
|
|
250
|
+
|
|
251
|
+
root.bind("<KeyPress>", key)
|
|
252
|
+
|
|
253
|
+
move()
|
|
254
|
+
root.mainloop()
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
kres
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools", "wheel"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "novy"
|
|
7
|
+
version = "0.2.0"
|
|
8
|
+
description = "Simple tkinter drawing library"
|
|
9
|
+
authors = [{name = "tK1"}]
|
|
10
|
+
readme = "README.md"
|
|
11
|
+
requires-python = ">=3.8"
|
novy-0.2.0/setup.cfg
ADDED