pytpro 0.1.5__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.
pytpro-0.1.5/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Ibrahim
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
13
+ all 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
21
+ THE SOFTWARE.
pytpro-0.1.5/PKG-INFO ADDED
@@ -0,0 +1,101 @@
1
+ Metadata-Version: 2.4
2
+ Name: pytpro
3
+ Version: 0.1.5
4
+ Summary: A simple Python tools package by Ibrahim Akhlaq
5
+ Author: Ibrahim Akhlaq
6
+ Author-email: ibakhlaq@gmail.com
7
+ Classifier: Programming Language :: Python :: 3
8
+ Classifier: License :: OSI Approved :: MIT License
9
+ Classifier: Operating System :: OS Independent
10
+ Requires-Python: >=3.6
11
+ Description-Content-Type: text/markdown
12
+ License-File: LICENSE
13
+ Dynamic: author
14
+ Dynamic: author-email
15
+ Dynamic: classifier
16
+ Dynamic: description
17
+ Dynamic: description-content-type
18
+ Dynamic: license-file
19
+ Dynamic: requires-python
20
+ Dynamic: summary
21
+
22
+ # pytpro
23
+
24
+ **pytpro** is a lightweight Python package by Ibrahim Akhlaq that provides powerful utility functions for math, randomness, and HTML rendering. It's clean, minimal, and built to feel like magic.
25
+
26
+ ---
27
+
28
+ ## 🚀 Features
29
+
30
+ ### ➕ Math Functions
31
+ - `add(a, b)` / `subtract(a, b)`
32
+ - `multiply(a, b)` / `divide(a, b)`
33
+ - `modulus(a, b)` / `floordivision(a, b)`
34
+ - `square(a)` / `cube(a)`
35
+ - `squareroot(a)` / `cuberoot(a)`
36
+ - `absolutevalue(a)` / `roundoff(a)`
37
+ - `exponent(a, b)` / `power(a, b)`
38
+
39
+ ### 🔢 Random Number Generators
40
+ - `randint(start=0, end=100)`
41
+ - `randfloat()`
42
+ - `randomintpositive(start, end, step=1)`
43
+ - `randomintnegative(start, end, step=1)`
44
+ - `randomfloatpositive(start, end)`
45
+ - `randomfloatnegative(start, end)`
46
+
47
+ ### 📐 Trigonometry & Logs
48
+ - `sine(x)` / `cosine(x)` / `tangent(x)` / `arctangent(x)`
49
+ - `log_base_2(x)` / `log_base_10(x)` / `natural_log(x)`
50
+
51
+ ### 📏 Constants (Auto-displayed)
52
+ - `pi`, `e`, `goldenratio`, `tau`
53
+ - `speedoflight`, `planckconstant`, `gravitationalconstant`
54
+ - `electronmass`, `protonmass`, `neutronmass`
55
+ - `electronvolt`, `joule`, `kilojoule`, `megajoule`, `gigajoule`, `terajoule`, `petajoule`, `exajoule`
56
+
57
+ ---
58
+
59
+ ### Text
60
+ - `write(...)`
61
+ - `title(text)`
62
+ - `header(text)`
63
+ - `subheader(text)`
64
+ - `caption(text)`
65
+
66
+ ### HTML Embeds
67
+ - `htmlcssjs(html_fragment)`
68
+
69
+ ### Alert Boxes
70
+ - `alertbox_red(text)` / `alertbox_green(text)` / `alertbox_blue(text)`
71
+ - `alertbox_yellow(text)` / `alertbox_purple(text)` / `alertbox_orange(text)`
72
+ - `alertbox_pink(text)` / `alertbox_cyan(text)` / `alertbox_lime(text)`
73
+ - `alertbox_brown(text)` / `alertbox_gray(text)` / `alertbox_black(text)`
74
+
75
+ ### Toast Notifications (auto-fade)
76
+ - `toast(text)` – white default
77
+ - `toast_red(text)` / `toast_green(text)` / `toast_blue(text)`
78
+ - `toast_black(text)` / `toast_pink(text)`
79
+
80
+ ---
81
+
82
+ ## 🖥️ Example Usage
83
+
84
+ ```python
85
+ import pytpro
86
+
87
+ pytpro.add(2, 3)
88
+ pytpro.square(6)
89
+ pytpro.pi()
90
+ pytpro.htmlcssjs("<h1>Hello!</h1><p>This is raw HTML.</p>")
91
+ ```
92
+
93
+ # 🖥️ Instructions to install:
94
+
95
+ To install locally from your project directory, open PowerShell or terminal and run:
96
+
97
+ ```bash
98
+ pip install pytpro
99
+ ```
100
+
101
+ __version:0.3.0__
pytpro-0.1.5/README.md ADDED
@@ -0,0 +1,80 @@
1
+ # pytpro
2
+
3
+ **pytpro** is a lightweight Python package by Ibrahim Akhlaq that provides powerful utility functions for math, randomness, and HTML rendering. It's clean, minimal, and built to feel like magic.
4
+
5
+ ---
6
+
7
+ ## 🚀 Features
8
+
9
+ ### ➕ Math Functions
10
+ - `add(a, b)` / `subtract(a, b)`
11
+ - `multiply(a, b)` / `divide(a, b)`
12
+ - `modulus(a, b)` / `floordivision(a, b)`
13
+ - `square(a)` / `cube(a)`
14
+ - `squareroot(a)` / `cuberoot(a)`
15
+ - `absolutevalue(a)` / `roundoff(a)`
16
+ - `exponent(a, b)` / `power(a, b)`
17
+
18
+ ### 🔢 Random Number Generators
19
+ - `randint(start=0, end=100)`
20
+ - `randfloat()`
21
+ - `randomintpositive(start, end, step=1)`
22
+ - `randomintnegative(start, end, step=1)`
23
+ - `randomfloatpositive(start, end)`
24
+ - `randomfloatnegative(start, end)`
25
+
26
+ ### 📐 Trigonometry & Logs
27
+ - `sine(x)` / `cosine(x)` / `tangent(x)` / `arctangent(x)`
28
+ - `log_base_2(x)` / `log_base_10(x)` / `natural_log(x)`
29
+
30
+ ### 📏 Constants (Auto-displayed)
31
+ - `pi`, `e`, `goldenratio`, `tau`
32
+ - `speedoflight`, `planckconstant`, `gravitationalconstant`
33
+ - `electronmass`, `protonmass`, `neutronmass`
34
+ - `electronvolt`, `joule`, `kilojoule`, `megajoule`, `gigajoule`, `terajoule`, `petajoule`, `exajoule`
35
+
36
+ ---
37
+
38
+ ### Text
39
+ - `write(...)`
40
+ - `title(text)`
41
+ - `header(text)`
42
+ - `subheader(text)`
43
+ - `caption(text)`
44
+
45
+ ### HTML Embeds
46
+ - `htmlcssjs(html_fragment)`
47
+
48
+ ### Alert Boxes
49
+ - `alertbox_red(text)` / `alertbox_green(text)` / `alertbox_blue(text)`
50
+ - `alertbox_yellow(text)` / `alertbox_purple(text)` / `alertbox_orange(text)`
51
+ - `alertbox_pink(text)` / `alertbox_cyan(text)` / `alertbox_lime(text)`
52
+ - `alertbox_brown(text)` / `alertbox_gray(text)` / `alertbox_black(text)`
53
+
54
+ ### Toast Notifications (auto-fade)
55
+ - `toast(text)` – white default
56
+ - `toast_red(text)` / `toast_green(text)` / `toast_blue(text)`
57
+ - `toast_black(text)` / `toast_pink(text)`
58
+
59
+ ---
60
+
61
+ ## 🖥️ Example Usage
62
+
63
+ ```python
64
+ import pytpro
65
+
66
+ pytpro.add(2, 3)
67
+ pytpro.square(6)
68
+ pytpro.pi()
69
+ pytpro.htmlcssjs("<h1>Hello!</h1><p>This is raw HTML.</p>")
70
+ ```
71
+
72
+ # 🖥️ Instructions to install:
73
+
74
+ To install locally from your project directory, open PowerShell or terminal and run:
75
+
76
+ ```bash
77
+ pip install pytpro
78
+ ```
79
+
80
+ __version:0.3.0__
@@ -0,0 +1,85 @@
1
+ from .main import (
2
+ # Web
3
+ htmlcssjs, image, button,
4
+
5
+ # Core UI
6
+ write, title, header, subheader, caption,
7
+
8
+ # Alert Boxes
9
+ alertbox_red, alertbox_green, alertbox_blue, alertbox_yellow,
10
+ alertbox_purple, alertbox_orange, alertbox_pink, alertbox_cyan,
11
+ alertbox_lime, alertbox_brown, alertbox_gray, alertbox_black,
12
+
13
+ # Toasts
14
+ toast, toast_red, toast_green, toast_blue,
15
+ toast_black, toast_pink,
16
+
17
+ # Math
18
+ add, subtract, multiply, divide, modulus, exponent, power,
19
+ square, cube, squareroot, cuberoot, absolutevalue, floordivision, roundoff,
20
+
21
+ # Trigonometry and Logs
22
+ sine, cosine, tangent, arctangent,
23
+ log_base_2, log_base_10, natural_log,
24
+
25
+ # Random
26
+ randint, randfloat,
27
+ randomintpositive, randomintnegative,
28
+ randomfloatpositive, randomfloatnegative,
29
+
30
+ # Constants
31
+ pi, e, goldenratio, tau,
32
+ speedoflight, planckconstant, gravitationalconstant,
33
+ electronmass, protonmass, neutronmass,
34
+ electronvolt, joule, kilojoule, megajoule,
35
+ gigajoule, terajoule, petajoule, exajoule,
36
+ )
37
+
38
+ __all__ = [
39
+ # Web
40
+ "htmlcssjs", "image", "button",
41
+
42
+ # Core UI
43
+ "write", "title", "header", "subheader", "caption",
44
+
45
+ # Alert Boxes
46
+ "alertbox_red", "alertbox_green", "alertbox_blue", "alertbox_yellow",
47
+ "alertbox_purple", "alertbox_orange", "alertbox_pink", "alertbox_cyan",
48
+ "alertbox_lime", "alertbox_brown", "alertbox_gray", "alertbox_black",
49
+
50
+ # Toasts
51
+ "toast", "toast_red", "toast_green", "toast_blue",
52
+ "toast_black", "toast_pink",
53
+
54
+ # Math
55
+ "add", "subtract", "multiply", "divide", "modulus", "exponent", "power",
56
+ "square", "cube", "squareroot", "cuberoot", "absolutevalue", "floordivision", "roundoff",
57
+
58
+ # Trigonometry and Logs
59
+ "sine", "cosine", "tangent", "arctangent",
60
+ "log_base_2", "log_base_10", "natural_log",
61
+
62
+ # Random
63
+ "randint", "randfloat",
64
+ "randomintpositive", "randomintnegative",
65
+ "randomfloatpositive", "randomfloatnegative",
66
+
67
+ # Constants
68
+ "pi", "e", "goldenratio", "tau",
69
+ "speedoflight", "planckconstant", "gravitationalconstant",
70
+ "electronmass", "protonmass", "neutronmass",
71
+ "electronvolt", "joule", "kilojoule", "megajoule",
72
+ "gigajoule", "terajoule", "petajoule", "exajoule"
73
+ ]
74
+
75
+ __version__ = "0.1.5"
76
+ __author__ = "Ibrahim Akhlaq"
77
+ __email__ = "ibakhlaq@gmail.com"
78
+ __license__ = "MIT"
79
+ __description__ = "A powerful Python toolkit with automatic HTML output and utilities by Ibrahim Akhlaq"
80
+
81
+ __classifiers__ = [
82
+ "Programming Language :: Python :: 3",
83
+ "License :: OSI Approved :: MIT License",
84
+ "Operating System :: OS Independent",
85
+ ]
@@ -0,0 +1,720 @@
1
+ import html as html_escape
2
+ import webbrowser
3
+ import tempfile
4
+ import random
5
+ import atexit
6
+ import uuid
7
+ import math
8
+ import os
9
+ import sys
10
+ import urllib.parse
11
+
12
+ _output_buffer = []
13
+ _output_file_path = None
14
+
15
+ def write(*args, sep=" ", end="\n"):
16
+ joined = sep.join(str(arg) for arg in args) + end
17
+ _output_buffer.append(joined + "<br>")
18
+
19
+ def image(src, width=None, height=None, alt=""):
20
+ style = ""
21
+ if width:
22
+ style += f"width:{width}px;"
23
+ if height:
24
+ style += f"height:{height}px;"
25
+ img_tag = f"<img src='{src}' alt='{html_escape.escape(alt)}' style='border-radius:7px;box-shadow: 0 4px 8px rgba(0,0,0,0.2), 0 6px 20px rgba(0,0,0,0.19);{style}'>"
26
+ write(img_tag)
27
+
28
+ def htmlcssjs(html_fragment):
29
+ cleaned = html_fragment.strip()
30
+ cleaned = cleaned.replace("<html>", "").replace("</html>", "")
31
+ cleaned = cleaned.replace("<body>", "").replace("</body>", "")
32
+ cleaned = cleaned.replace("<head>", "").replace("</head>", "")
33
+ cleaned = cleaned.replace("<!DOCTYPE html>", "")
34
+ write(cleaned)
35
+
36
+ def _auto_render():
37
+ global _output_file_path
38
+ if not _output_buffer:
39
+ return
40
+
41
+ html_content = "\n".join(_output_buffer)
42
+ html_template = f"""
43
+ <!DOCTYPE html>
44
+ <html>
45
+ <head>
46
+ <meta charset="UTF-8">
47
+ <title></title>
48
+ <style>
49
+ body {{
50
+ font-family: sans-serif;
51
+ padding: 20px;
52
+ line-height: 1.6;
53
+ }}
54
+ #output {{
55
+ white-space: normal;
56
+ }}
57
+ </style>
58
+ </head>
59
+ <body>
60
+ <div id="output">{html_content}</div>
61
+ </body>
62
+ </html>
63
+ """
64
+
65
+ # Use a stable file path
66
+ temp_path = os.path.join(tempfile.gettempdir(), "pytpro_output.html")
67
+ with open(temp_path, "w", encoding="utf-8") as f:
68
+ f.write(html_template)
69
+
70
+ _output_file_path = temp_path
71
+ webbrowser.open(f"file://{_output_file_path}")
72
+ _output_buffer.clear()
73
+
74
+ atexit.register(_auto_render)
75
+
76
+ # -----------------------------
77
+ # Math and utility functions
78
+ # -----------------------------
79
+
80
+ def add(a, b):
81
+ """find the sum of two numbers. in other words, add 2 numbers together."""
82
+ result = a + b
83
+ write(result)
84
+ return result
85
+
86
+ def subtract(a, b):
87
+ """find the difference of two numbers. in other words, subtract the second number from the first."""
88
+ result = a - b
89
+ write(result)
90
+ return result
91
+
92
+ def multiply(a, b):
93
+ """find the product of two numbers. in other words, find the result of a multiplication."""
94
+ result = a * b
95
+ write(result)
96
+ return result
97
+
98
+ def divide(a, b):
99
+ """find the division of two numbers. in other words, find the result of a fraction."""
100
+ result = a / b
101
+ write(result)
102
+ return result
103
+
104
+ def modulus(a, b):
105
+ """find the remainder of two numbers in a fraction. Inputs must be integers."""
106
+ result = a % b
107
+ write(result)
108
+ return result
109
+
110
+ def exponent(a, b):
111
+ """find the exponent/power of two numbers. The first number is the base and the second is the power."""
112
+ result = a ** b
113
+ write(result)
114
+ return result
115
+
116
+ def power(a, b):
117
+ """find the exponent/power of two numbers. The first number is the base and the second is the power."""
118
+ result = math.pow(a, b)
119
+ write(result)
120
+ return result
121
+
122
+ def floordivision(a, b):
123
+ """find the floor division of two numbers."""
124
+ result = a // b
125
+ write(result)
126
+ return result
127
+
128
+ def squareroot(a):
129
+ """find the square root of a number."""
130
+ result = math.sqrt(a)
131
+ write(result)
132
+ return result
133
+
134
+ def cuberoot(a):
135
+ """find the cube root of a number."""
136
+ result = a ** (1 / 3)
137
+ write(result)
138
+ return result
139
+
140
+ def square(a):
141
+ """find the square of a number."""
142
+ result = a ** 2
143
+ write(result)
144
+ return result
145
+
146
+ def cube(a):
147
+ """find the cube of a number."""
148
+ result = a ** 3
149
+ write(result)
150
+ return result
151
+
152
+ def absolutevalue(a):
153
+ """find the absolute value of a number."""
154
+ result = abs(a)
155
+ write(result)
156
+ return result
157
+
158
+ def roundoff(a):
159
+ """round a number to the nearest integer."""
160
+ result = round(a)
161
+ write(result)
162
+ return result
163
+
164
+ # -----------------------------
165
+ # Random number functions
166
+ # -----------------------------
167
+
168
+ def randomfloatpositive(start, end):
169
+ """Returns a positive random float between start and end."""
170
+ result = abs(random.uniform(start, end))
171
+ write(result)
172
+ return result
173
+
174
+ def randomintpositive(start, end, step=1):
175
+ """Returns a positive random integer from start to end with step."""
176
+ result = abs(random.randrange(start, end + 1, step))
177
+ write(result)
178
+ return result
179
+
180
+ def randint(start=0, end=100):
181
+ """Returns a random integer between start and end."""
182
+ result = random.randint(start, end)
183
+ write(result)
184
+ return result
185
+
186
+ def randfloat():
187
+ """Returns a random float between 0 and 1."""
188
+ result = random.random()
189
+ write(result)
190
+ return result
191
+
192
+ def randomfloatnegative(start, end):
193
+ """Returns a negative random float between start and end."""
194
+ result = -abs(random.uniform(start, end))
195
+ write(result)
196
+ return result
197
+
198
+ def randomintnegative(start, end, step=1):
199
+ """Returns a negative random integer from start to end with step."""
200
+ result = -abs(random.randrange(start, end + 1, step))
201
+ write(result)
202
+ return result
203
+
204
+ # -----------------------------
205
+ # Trigonometry and log functions
206
+ # -----------------------------
207
+
208
+ def sine(x):
209
+ """Return the sine of x (in radians)."""
210
+ result = math.sin(x)
211
+ write(result)
212
+ return result
213
+
214
+ def cosine(x):
215
+ """Return the cosine of x (in radians)."""
216
+ result = math.cos(x)
217
+ write(result)
218
+ return result
219
+
220
+ def tangent(x):
221
+ """Return the tangent of x (in radians)."""
222
+ result = math.tan(x)
223
+ write(result)
224
+ return result
225
+
226
+ def arctangent(x):
227
+ """Return the arctangent of x (in radians)."""
228
+ result = math.atan(x)
229
+ write(result)
230
+ return result
231
+
232
+ def log_base_10(x):
233
+ """Return the log base 10 of x."""
234
+ result = math.log10(x)
235
+ write(result)
236
+ return result
237
+
238
+ def log_base_2(x):
239
+ """Return the log base 2 of x."""
240
+ result = math.log2(x)
241
+ write(result)
242
+ return result
243
+
244
+ def natural_log(x):
245
+ """Return the natural log (base e) of x."""
246
+ result = math.log(x)
247
+ write(result)
248
+ return result
249
+
250
+ # -----------------------------
251
+ # Mathematical Constants
252
+ # -----------------------------
253
+
254
+ class AutoWriteFloat:
255
+ def __init__(self, value, description=""):
256
+ self.value = value
257
+ self.description = description
258
+
259
+ def __str__(self):
260
+ write(self.value)
261
+ return str(self.value)
262
+
263
+ def __repr__(self):
264
+ return str(self.value)
265
+
266
+ pi = AutoWriteFloat(math.pi, "Return the value of π (pi).")
267
+
268
+ e = AutoWriteFloat(math.e, "Return the value of e (Euler’s number).")
269
+
270
+ goldenratio = AutoWriteFloat((1 + math.sqrt(5)) / 2, "Return φ (the golden ratio).")
271
+
272
+ tau = AutoWriteFloat(math.tau, "Return τ (the tau constant).")
273
+
274
+ # -----------------------------
275
+ # Scientific Constants
276
+ # -----------------------------
277
+
278
+ speedoflight = AutoWriteFloat(299792458, "Return the speed of light (c) in m/s.")
279
+
280
+ planckconstant = AutoWriteFloat(6.62607004e-34, "Return the Planck constant (h) in J⋅s.")
281
+
282
+ gravitationalconstant = AutoWriteFloat(6.67408e-11, "Return the gravitational constant (G) in m3⋅kg−1⋅s−2.")
283
+
284
+ electronmass = AutoWriteFloat(9.10938356e-31, "Return the mass of an electron (me) in kg.")
285
+
286
+ protonmass = AutoWriteFloat(1.6726219e-27, "Return the mass of a proton (mp) in kg.")
287
+
288
+ neutronmass = AutoWriteFloat(1.674927471e-27, "Return the mass of a neutron (mn) in kg.")
289
+
290
+ electronvolt = AutoWriteFloat(1.602176634e-19, "Return the electron volt (eV) in J.")
291
+
292
+ joule = AutoWriteFloat(1, "Return the joule (J) in J.")
293
+
294
+ kilojoule = AutoWriteFloat(1000, "Return the kilojoule (kJ) in J.")
295
+
296
+ megajoule = AutoWriteFloat(1000000, "Return the megajoule (MJ) in J.")
297
+
298
+ gigajoule = AutoWriteFloat(1000000000, "Return the gigajoule (GJ) in J.")
299
+
300
+ terajoule = AutoWriteFloat(1000000000000, "Return the terajoule (TJ) in J.")
301
+
302
+ petajoule = AutoWriteFloat(1000000000000000, "Return the petajoule (PJ) in J.")
303
+
304
+ exajoule = AutoWriteFloat(1000000000000000000, "Return the exajoule (EJ) in J.")
305
+
306
+ # ------------------------------
307
+ # streamlit-like functions, etc.
308
+ # ------------------------------
309
+
310
+ def header(text):
311
+ """Display a secondary header."""
312
+ write(f"<h2>{html_escape.escape(str(text))}</h2>")
313
+
314
+ def subheader(text):
315
+ """Display a smaller subheader."""
316
+ write(f"<h3>{html_escape.escape(str(text))}</h3>")
317
+
318
+ def caption(text):
319
+ """Display a small caption or note."""
320
+ write(f"<p style='font-size: 0.9em; color: gray;'>{html_escape.escape(str(text))}</p>")
321
+
322
+ def title(text):
323
+ """Display a title in large bold text."""
324
+ write(f"<h1>{html_escape.escape(str(text))}</h1>")
325
+
326
+ def alertbox_red(text):
327
+ """Display a red alert box."""
328
+ safe_text = html_escape.escape(str(text))
329
+ html = f"""
330
+ <div style='
331
+ padding: 16px;
332
+ margin: 10px 0;
333
+ background-color: #fdecea;
334
+ color: #b00020;
335
+ border-left: 6px solid #b00020;
336
+ border-radius: 4px;
337
+ font-family: sans-serif;
338
+ '>
339
+ {safe_text}
340
+ </div>
341
+ """
342
+ write(html)
343
+
344
+ def alertbox_green(text):
345
+ """Display a green alert box."""
346
+ safe_text = html_escape.escape(str(text))
347
+ html = f"""
348
+ <div style='
349
+ padding: 16px;
350
+ margin: 10px 0;
351
+ background-color: #e8f5e9;
352
+ color: #2e7d32;
353
+ border-left: 6px solid #2e7d32;
354
+ border-radius: 4px;
355
+ font-family: sans-serif;
356
+ '>
357
+ {safe_text}
358
+ </div>
359
+ """
360
+ write(html)
361
+
362
+ def alertbox_blue(text):
363
+ """Display a blue alert box."""
364
+ safe_text = html_escape.escape(str(text))
365
+ html = f"""
366
+ <div style='
367
+ padding: 16px;
368
+ margin: 10px 0;
369
+ background-color: #e3f2fd;
370
+ color: #1976d2;
371
+ border-left: 6px solid #1976d2;
372
+ border-radius: 4px;
373
+ font-family: sans-serif;
374
+ '>
375
+ {safe_text}
376
+ </div>
377
+ """
378
+ write(html)
379
+
380
+ def alertbox_yellow(text):
381
+ """Display a yellow alert box."""
382
+ safe_text = html_escape.escape(str(text))
383
+ html = f"""
384
+ <div style='
385
+ padding: 16px;
386
+ margin: 10px 0;
387
+ background-color: #fffde7;
388
+ color: #fbc02d;
389
+ border-left: 6px solid #fbc02d;
390
+ border-radius: 4px;
391
+ font-family: sans-serif;
392
+ '>
393
+ {safe_text}
394
+ </div>
395
+ """
396
+ write(html)
397
+
398
+ def alertbox_purple(text):
399
+ """Display a purple alert box."""
400
+ safe_text = html_escape.escape(str(text))
401
+ html = f"""
402
+ <div style='
403
+ padding: 16px;
404
+ margin: 10px 0;
405
+ background-color: #f3e5f5;
406
+ color: #8e24aa;
407
+ border-left: 6px solid #8e24aa;
408
+ border-radius: 4px;
409
+ font-family: sans-serif;
410
+ '>
411
+ {safe_text}
412
+ </div>
413
+ """
414
+ write(html)
415
+
416
+ def alertbox_orange(text):
417
+ """Display an orange alert box."""
418
+ safe_text = html_escape.escape(str(text))
419
+ html = f"""
420
+ <div style='
421
+ padding: 16px;
422
+ margin: 10px 0;
423
+ background-color: #fff3e0;
424
+ color: #f57c00;
425
+ border-left: 6px solid #f57c00;
426
+ border-radius: 4px;
427
+ font-family: sans-serif;
428
+ '>
429
+ {safe_text}
430
+ </div>
431
+ """
432
+ write(html)
433
+
434
+ def alertbox_pink(text):
435
+ """Display a pink alert box."""
436
+ safe_text = html_escape.escape(str(text))
437
+ html = f"""
438
+ <div style='
439
+ padding: 16px;
440
+ margin: 10px 0;
441
+ background-color: #fce4ec;
442
+ color: #c2185b;
443
+ border-left: 6px solid #c2185b;
444
+ border-radius: 4px;
445
+ font-family: sans-serif;
446
+ '>
447
+ {safe_text}
448
+ </div>
449
+ """
450
+ write(html)
451
+
452
+ def alertbox_cyan(text):
453
+ """Display a cyan alert box."""
454
+ safe_text = html_escape.escape(str(text))
455
+ html = f"""
456
+ <div style='
457
+ padding: 16px;
458
+ margin: 10px 0;
459
+ background-color: #e0f7fa;
460
+ color: #00acc1;
461
+ border-left: 6px solid #00acc1;
462
+ border-radius: 4px;
463
+ font-family: sans-serif;
464
+ '>
465
+ {safe_text}
466
+ </div>
467
+ """
468
+ write(html)
469
+
470
+ def alertbox_lime(text):
471
+ """Display a lime alert box."""
472
+ safe_text = html_escape.escape(str(text))
473
+ html = f"""
474
+ <div style='
475
+ padding: 16px;
476
+ margin: 10px 0;
477
+ background-color: #f1f8e9;
478
+ color: #c0ca33;
479
+ border-left: 6px solid #c0ca33;
480
+ border-radius: 4px;
481
+ font-family: sans-serif;
482
+ '>
483
+ {safe_text}
484
+ </div>
485
+ """
486
+ write(html)
487
+
488
+ def alertbox_brown(text):
489
+ """Display a brown alert box."""
490
+ safe_text = html_escape.escape(str(text))
491
+ html = f"""
492
+ <div style='
493
+ padding: 16px;
494
+ margin: 10px 0;
495
+ background-color: #efebe9;
496
+ color: #795548;
497
+ border-left: 6px solid #795548;
498
+ border-radius: 4px;
499
+ font-family: sans-serif;
500
+ '>
501
+ {safe_text}
502
+ </div>
503
+ """
504
+ write(html)
505
+
506
+ def alertbox_gray(text):
507
+ """Display a gray alert box."""
508
+ safe_text = html_escape.escape(str(text))
509
+ html = f"""
510
+ <div style='
511
+ padding: 16px;
512
+ margin: 10px 0;
513
+ background-color: #f5f5f5;
514
+ color: #616161;
515
+ border-left: 6px solid #616161;
516
+ border-radius: 4px;
517
+ font-family: sans-serif;
518
+ '>
519
+ {safe_text}
520
+ </div>
521
+ """
522
+ write(html)
523
+
524
+ def alertbox_black(text):
525
+ """Display a black alert box."""
526
+ safe_text = html_escape.escape(str(text))
527
+ html = f"""
528
+ <div style='
529
+ padding: 16px;
530
+ margin: 10px 0;
531
+ background-color: #eeeeee;
532
+ color: #212121;
533
+ border-left: 6px solid #212121;
534
+ border-radius: 4px;
535
+ font-family: sans-serif;
536
+ '>
537
+ {safe_text}
538
+ </div>
539
+ """
540
+ write(html)
541
+
542
+ def toast_red(text):
543
+ """Display a red toast message (disappears after 1.5 seconds)."""
544
+ safe_text = html_escape.escape(str(text))
545
+ html = f"""
546
+ <div style='
547
+ position: fixed;
548
+ bottom: 20px;
549
+ left: 50%;
550
+ transform: translateX(-50%);
551
+ background-color: #fdecea;
552
+ color: #b00020;
553
+ padding: 12px 20px;
554
+ border-radius: 6px;
555
+ box-shadow: 0 2px 10px rgba(0,0,0,0.1);
556
+ font-family: sans-serif;
557
+ z-index: 9999;
558
+ animation: fadeout 1.5s forwards;
559
+ '>
560
+ {safe_text}
561
+ </div>
562
+ <style>
563
+ @keyframes fadeout {{
564
+ 0% {{ opacity: 1; }}
565
+ 70% {{ opacity: 1; }}
566
+ 100% {{ opacity: 0; display: none; }}
567
+ }}
568
+ </style>
569
+ """
570
+ write(html)
571
+
572
+ def toast_green(text):
573
+ """Display a green toast message (disappears after 1.5 seconds)."""
574
+ safe_text = html_escape.escape(str(text))
575
+ html = f"""
576
+ <div style='
577
+ position: fixed;
578
+ bottom: 20px;
579
+ left: 50%;
580
+ transform: translateX(-50%);
581
+ background-color: #e8f5e9;
582
+ color: #2e7d32;
583
+ padding: 12px 20px;
584
+ border-radius: 6px;
585
+ box-shadow: 0 2px 10px rgba(0,0,0,0.1);
586
+ font-family: sans-serif;
587
+ z-index: 9999;
588
+ animation: fadeout 1.5s forwards;
589
+ '>
590
+ {safe_text}
591
+ </div>
592
+ <style>
593
+ @keyframes fadeout {{
594
+ 0% {{ opacity: 1; }}
595
+ 70% {{ opacity: 1; }}
596
+ 100% {{ opacity: 0; display: none; }}
597
+ }}
598
+ </style>
599
+ """
600
+ write(html)
601
+
602
+ def toast_blue(text):
603
+ """Display a blue toast message (disappears after 1.5 seconds)."""
604
+ safe_text = html_escape.escape(str(text))
605
+ html = f"""
606
+ <div style='
607
+ position: fixed;
608
+ bottom: 20px;
609
+ left: 50%;
610
+ transform: translateX(-50%);
611
+ background-color: #e3f2fd;
612
+ color: #1976d2;
613
+ padding: 12px 20px;
614
+ border-radius: 6px;
615
+ box-shadow: 0 2px 10px rgba(0,0,0,0.1);
616
+ font-family: sans-serif;
617
+ z-index: 9999;
618
+ animation: fadeout 1.5s forwards;
619
+ '>
620
+ {safe_text}
621
+ </div>
622
+ <style>
623
+ @keyframes fadeout {{
624
+ 0% {{ opacity: 1; }}
625
+ 70% {{ opacity: 1; }}
626
+ 100% {{ opacity: 0; display: none; }}
627
+ }}
628
+ </style>
629
+ """
630
+ write(html)
631
+
632
+ def toast_black(text):
633
+ """Display a black toast message (disappears after 1.5 seconds)."""
634
+ safe_text = html_escape.escape(str(text))
635
+ html = f"""
636
+ <div style='
637
+ position: fixed;
638
+ bottom: 20px;
639
+ left: 50%;
640
+ transform: translateX(-50%);
641
+ background-color: #eeeeee;
642
+ color: #212121;
643
+ padding: 12px 20px;
644
+ border-radius: 6px;
645
+ box-shadow: 0 2px 10px rgba(0,0,0,0.1);
646
+ font-family: sans-serif;
647
+ z-index: 9999;
648
+ animation: fadeout 1.5s forwards;
649
+ '>
650
+ {safe_text}
651
+ </div>
652
+ <style>
653
+ @keyframes fadeout {{
654
+ 0% {{ opacity: 1; }}
655
+ 70% {{ opacity: 1; }}
656
+ 100% {{ opacity: 0; display: none; }}
657
+ }}
658
+ </style>
659
+ """
660
+ write(html)
661
+
662
+ def toast_pink(text):
663
+ """Display a pink toast message (disappears after 1.5 seconds)."""
664
+ safe_text = html_escape.escape(str(text))
665
+ html = f"""
666
+ <div style='
667
+ position: fixed;
668
+ bottom: 20px;
669
+ left: 50%;
670
+ transform: translateX(-50%);
671
+ background-color: #fce4ec;
672
+ color: #c2185b;
673
+ padding: 12px 20px;
674
+ border-radius: 6px;
675
+ box-shadow: 0 2px 10px rgba(0,0,0,0.1);
676
+ font-family: sans-serif;
677
+ z-index: 9999;
678
+ animation: fadeout 1.5s forwards;
679
+ '>
680
+ {safe_text}
681
+ </div>
682
+ <style>
683
+ @keyframes fadeout {{
684
+ 0% {{ opacity: 1; }}
685
+ 70% {{ opacity: 1; }}
686
+ 100% {{ opacity: 0; display: none; }}
687
+ }}
688
+ </style>
689
+ """
690
+ write(html)
691
+
692
+ def toast(text):
693
+ """Display a default toast message (disappears after 1.5 seconds)."""
694
+ safe_text = html_escape.escape(str(text))
695
+ html = f"""
696
+ <div style='
697
+ position: fixed;
698
+ bottom: 20px;
699
+ left: 50%;
700
+ transform: translateX(-50%);
701
+ background-color: #ffffff;
702
+ color: #212121;
703
+ padding: 12px 20px;
704
+ border-radius: 6px;
705
+ box-shadow: 0 2px 10px rgba(0,0,0,0.1);
706
+ font-family: sans-serif;
707
+ z-index: 9999;
708
+ animation: fadeout 1.5s forwards;
709
+ '>
710
+ {safe_text}
711
+ </div>
712
+ <style>
713
+ @keyframes fadeout {{
714
+ 0% {{ opacity: 1; }}
715
+ 70% {{ opacity: 1; }}
716
+ 100% {{ opacity: 0; display: none; }}
717
+ }}
718
+ </style>
719
+ """
720
+ write(html)
@@ -0,0 +1,101 @@
1
+ Metadata-Version: 2.4
2
+ Name: pytpro
3
+ Version: 0.1.5
4
+ Summary: A simple Python tools package by Ibrahim Akhlaq
5
+ Author: Ibrahim Akhlaq
6
+ Author-email: ibakhlaq@gmail.com
7
+ Classifier: Programming Language :: Python :: 3
8
+ Classifier: License :: OSI Approved :: MIT License
9
+ Classifier: Operating System :: OS Independent
10
+ Requires-Python: >=3.6
11
+ Description-Content-Type: text/markdown
12
+ License-File: LICENSE
13
+ Dynamic: author
14
+ Dynamic: author-email
15
+ Dynamic: classifier
16
+ Dynamic: description
17
+ Dynamic: description-content-type
18
+ Dynamic: license-file
19
+ Dynamic: requires-python
20
+ Dynamic: summary
21
+
22
+ # pytpro
23
+
24
+ **pytpro** is a lightweight Python package by Ibrahim Akhlaq that provides powerful utility functions for math, randomness, and HTML rendering. It's clean, minimal, and built to feel like magic.
25
+
26
+ ---
27
+
28
+ ## 🚀 Features
29
+
30
+ ### ➕ Math Functions
31
+ - `add(a, b)` / `subtract(a, b)`
32
+ - `multiply(a, b)` / `divide(a, b)`
33
+ - `modulus(a, b)` / `floordivision(a, b)`
34
+ - `square(a)` / `cube(a)`
35
+ - `squareroot(a)` / `cuberoot(a)`
36
+ - `absolutevalue(a)` / `roundoff(a)`
37
+ - `exponent(a, b)` / `power(a, b)`
38
+
39
+ ### 🔢 Random Number Generators
40
+ - `randint(start=0, end=100)`
41
+ - `randfloat()`
42
+ - `randomintpositive(start, end, step=1)`
43
+ - `randomintnegative(start, end, step=1)`
44
+ - `randomfloatpositive(start, end)`
45
+ - `randomfloatnegative(start, end)`
46
+
47
+ ### 📐 Trigonometry & Logs
48
+ - `sine(x)` / `cosine(x)` / `tangent(x)` / `arctangent(x)`
49
+ - `log_base_2(x)` / `log_base_10(x)` / `natural_log(x)`
50
+
51
+ ### 📏 Constants (Auto-displayed)
52
+ - `pi`, `e`, `goldenratio`, `tau`
53
+ - `speedoflight`, `planckconstant`, `gravitationalconstant`
54
+ - `electronmass`, `protonmass`, `neutronmass`
55
+ - `electronvolt`, `joule`, `kilojoule`, `megajoule`, `gigajoule`, `terajoule`, `petajoule`, `exajoule`
56
+
57
+ ---
58
+
59
+ ### Text
60
+ - `write(...)`
61
+ - `title(text)`
62
+ - `header(text)`
63
+ - `subheader(text)`
64
+ - `caption(text)`
65
+
66
+ ### HTML Embeds
67
+ - `htmlcssjs(html_fragment)`
68
+
69
+ ### Alert Boxes
70
+ - `alertbox_red(text)` / `alertbox_green(text)` / `alertbox_blue(text)`
71
+ - `alertbox_yellow(text)` / `alertbox_purple(text)` / `alertbox_orange(text)`
72
+ - `alertbox_pink(text)` / `alertbox_cyan(text)` / `alertbox_lime(text)`
73
+ - `alertbox_brown(text)` / `alertbox_gray(text)` / `alertbox_black(text)`
74
+
75
+ ### Toast Notifications (auto-fade)
76
+ - `toast(text)` – white default
77
+ - `toast_red(text)` / `toast_green(text)` / `toast_blue(text)`
78
+ - `toast_black(text)` / `toast_pink(text)`
79
+
80
+ ---
81
+
82
+ ## 🖥️ Example Usage
83
+
84
+ ```python
85
+ import pytpro
86
+
87
+ pytpro.add(2, 3)
88
+ pytpro.square(6)
89
+ pytpro.pi()
90
+ pytpro.htmlcssjs("<h1>Hello!</h1><p>This is raw HTML.</p>")
91
+ ```
92
+
93
+ # 🖥️ Instructions to install:
94
+
95
+ To install locally from your project directory, open PowerShell or terminal and run:
96
+
97
+ ```bash
98
+ pip install pytpro
99
+ ```
100
+
101
+ __version:0.3.0__
@@ -0,0 +1,9 @@
1
+ LICENSE
2
+ README.md
3
+ setup.py
4
+ pytpro/__init__.py
5
+ pytpro/main.py
6
+ pytpro.egg-info/PKG-INFO
7
+ pytpro.egg-info/SOURCES.txt
8
+ pytpro.egg-info/dependency_links.txt
9
+ pytpro.egg-info/top_level.txt
@@ -0,0 +1 @@
1
+ pytpro
pytpro-0.1.5/setup.cfg ADDED
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
pytpro-0.1.5/setup.py ADDED
@@ -0,0 +1,26 @@
1
+ from setuptools import setup, find_packages
2
+ import sys
3
+
4
+ if sys.version_info < (3, 6):
5
+ print("❌ To use this module, you need Python 3.6 or newer.")
6
+ sys.exit(1)
7
+
8
+ with open("README.md", encoding="utf-8") as f:
9
+ long_description = f.read()
10
+
11
+ setup(
12
+ name="pytpro",
13
+ version="0.1.5",
14
+ description="A simple Python tools package by Ibrahim Akhlaq",
15
+ long_description=long_description,
16
+ long_description_content_type="text/markdown",
17
+ author="Ibrahim Akhlaq",
18
+ author_email="ibakhlaq@gmail.com",
19
+ packages=find_packages(),
20
+ classifiers=[
21
+ "Programming Language :: Python :: 3",
22
+ "License :: OSI Approved :: MIT License",
23
+ "Operating System :: OS Independent",
24
+ ],
25
+ python_requires=">=3.6",
26
+ )