crystalwindow 5.5__py3-none-any.whl → 5.6__py3-none-any.whl

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.
@@ -0,0 +1,137 @@
1
+ import sys
2
+ import os
3
+ import time
4
+ import platform
5
+ import atexit
6
+
7
+
8
+ class System:
9
+ def __init__(self):
10
+ # ---------- BASIC INFO ----------
11
+ self.system_name = self._get_os_name()
12
+ self.python_version = sys.version
13
+ self.platform = sys.platform
14
+ self.executable = sys.executable
15
+ self.cwd = os.getcwd()
16
+
17
+ # ---------- RUNTIME ----------
18
+ self.start_time = time.time()
19
+ self.logs = []
20
+
21
+ # ---------- CRASH DETECTION ----------
22
+ self.flag_file = ".cw_running.flag"
23
+ self.last_run_crashed = os.path.exists(self.flag_file)
24
+
25
+ # mark app as running
26
+ with open(self.flag_file, "w") as f:
27
+ f.write("running")
28
+
29
+ # cleanup on clean exit
30
+ atexit.register(self._clean_exit)
31
+
32
+ self.log("System initialized")
33
+ if self.last_run_crashed:
34
+ self.log("WARNING: last run did not exit cleanly")
35
+
36
+ # ==============================
37
+ # OS NAME (WINDOWS 11 ETC)
38
+ # ==============================
39
+ def _get_os_name(self):
40
+ system = platform.system()
41
+
42
+ if system == "Windows":
43
+ # returns 10 or 11
44
+ return f"Windows {platform.release()}"
45
+ elif system == "Linux":
46
+ return "Linux"
47
+ elif system == "Darwin":
48
+ return "macOS"
49
+ else:
50
+ return system
51
+
52
+ # ==============================
53
+ # CRASH / STATUS
54
+ # ==============================
55
+ def crashed_before(self):
56
+ return self.last_run_crashed
57
+
58
+ def _clean_exit(self):
59
+ if os.path.exists(self.flag_file):
60
+ os.remove(self.flag_file)
61
+ self.log("Clean exit")
62
+
63
+ # ==============================
64
+ # TIME
65
+ # ==============================
66
+ def uptime_seconds(self):
67
+ return int(time.time() - self.start_time)
68
+
69
+ def uptime_formatted(self):
70
+ s = self.uptime_seconds()
71
+ m, s = divmod(s, 60)
72
+ h, m = divmod(m, 60)
73
+ return f"{h:02}:{m:02}:{s:02}"
74
+
75
+ # ==============================
76
+ # LOGGING
77
+ # ==============================
78
+ def log(self, msg):
79
+ timestamp = time.strftime("%H:%M:%S")
80
+ entry = f"[{timestamp}] {msg}"
81
+ self.logs.append(entry)
82
+
83
+ def save_logs(self, path="system.log"):
84
+ with open(path, "a", encoding="utf-8") as f:
85
+ for line in self.logs:
86
+ f.write(line + "\n")
87
+ self.logs.clear()
88
+
89
+ # ==============================
90
+ # INFO DUMP
91
+ # ==============================
92
+ def get_system_info(self):
93
+ return {
94
+ "system": self.system_name,
95
+ "platform": self.platform,
96
+ "python": self.python_version,
97
+ "executable": self.executable,
98
+ "cwd": self.cwd,
99
+ "uptime": self.uptime_formatted(),
100
+ "last_run_crashed": self.last_run_crashed
101
+ }
102
+
103
+ def delete_file(self, path):
104
+ try:
105
+ if os.path.exists(path):
106
+ os.remove(path)
107
+ self.log(f"Deleted file: {path}")
108
+ return True
109
+ else:
110
+ self.log(f"File not found for deletion: {path}")
111
+ return False
112
+ except Exception as e:
113
+ self.log(f"Error deleting file {path}: {e}")
114
+ return False
115
+
116
+ def create_file(name, filetype):
117
+ full_name = f"{name}.{filetype}"
118
+ try:
119
+ with open(full_name, "w") as f:
120
+ f.write("") # create empty file
121
+ return True
122
+ except Exception as e:
123
+ return False
124
+
125
+ # ==============================
126
+ # WATCHDOG (FREEZE DETECTOR)
127
+ # ==============================
128
+ class Watchdog:
129
+ def __init__(self, timeout=3):
130
+ self.timeout = timeout
131
+ self.last_ping = time.time()
132
+
133
+ def ping(self):
134
+ self.last_ping = time.time()
135
+
136
+ def frozen(self):
137
+ return (time.time() - self.last_ping) > self.timeout
crystalwindow/__init__.py CHANGED
@@ -64,6 +64,10 @@ from .Fonts import Font
64
64
  # === App/Window ====
65
65
  from .apphelper import GameAppHelper
66
66
 
67
+ # === System ===
68
+ from .System import System, Watchdog
69
+
70
+
67
71
  __all__ = [
68
72
  # --- Core ---
69
73
  "Window", "Sprite", "TileMap", "Player", "Block", "Enemy", "Gravity", "FileHelper", "Mathematics",
@@ -115,4 +119,7 @@ __all__ = [
115
119
 
116
120
  # --- App/Window ---
117
121
  "GameAppHelper",
122
+
123
+ # --- System ---
124
+ "System", "Watchdog",
118
125
  ]
crystalwindow/math.py CHANGED
@@ -1,3 +1,4 @@
1
+ import matplotlib.pyplot as plt
1
2
  class Mathematics:
2
3
  """
3
4
  A class used to perform basic mathematical operations.
@@ -38,3 +39,25 @@ class Mathematics:
38
39
  raise ZeroDivisionError("Cannot divide by zero!")
39
40
  return num1 / num2
40
41
 
42
+
43
+ @staticmethod
44
+ def export_graph(object, object2, filetype="png", filename="graph"):
45
+ """
46
+ object -> x values (list)
47
+ object2 -> y values (list)
48
+ filetype -> png, webp, jpeg
49
+ """
50
+
51
+ if len(object) != len(object2):
52
+ raise ValueError("X and Y must be same length bruh")
53
+
54
+ plt.figure()
55
+ plt.plot(object, object2, marker="o")
56
+ plt.xlabel("X Axis")
57
+ plt.ylabel("Y Axis")
58
+ plt.title("Generated Graph")
59
+
60
+ plt.grid(True)
61
+
62
+ plt.savefig(f"{filename}.{filetype}")
63
+ plt.close()
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: crystalwindow
3
- Version: 5.5
3
+ Version: 5.6
4
4
  Summary: A Tkinter powered window + GUI toolkit made by Crystal (ME)! Easier apps, smoother UI and all-in-one helpers!, Gui, Buttons, FileHelper, Sprites, Animations, Colors, Math, Gravity, Camera, 3D and more!
5
5
  Home-page: https://pypi.org/project/crystalwindow/
6
6
  Author: CrystalBallyHereXD
@@ -1,6 +1,7 @@
1
1
  crystalwindow/FileHelper.py,sha256=U20iwND4jX1y91TOK46e8MPH8xyw7GOrZ697nPEnOPk,10706
2
2
  crystalwindow/Fonts.py,sha256=XGqmM3GaauM5a74BtqhKk9zzKgQPcHyN3vcOP1TeoOs,954
3
- crystalwindow/__init__.py,sha256=9KgD3KnjkDbq2sFUaT3_uDwHd_vgGnAFO2vy0f59ZtA,3151
3
+ crystalwindow/System.py,sha256=-ecjzVlTH4ncNnZ_SDNfvqoQLeh8Zefy9laojpQKUUk,4045
4
+ crystalwindow/__init__.py,sha256=qG6tCqCZXpv4qzbSgG-EusDkYp41rwszFugbG4MOOG8,3262
4
5
  crystalwindow/ai.py,sha256=YIt6dNe1QljSAlNECCVa3DMUSIqQEJRIAAbQpYqFNNo,11525
5
6
  crystalwindow/animation.py,sha256=zHjrdBXQeyNaLAuaGPldJueX05OZ5j31YR8NizmR0uQ,427
6
7
  crystalwindow/apphelper.py,sha256=CAcX5n0Jq7zdBMFZkwbMt3_M0mBVVZRoXldOcXsZan4,2924
@@ -19,7 +20,7 @@ crystalwindow/fun_helpers.py,sha256=UHfveBTJ3NlgFd8ZbEJpHtQL-YUWiG7Hl9CWhT06VmQ,
19
20
  crystalwindow/gravity.py,sha256=wqVQt1S9ECA69gHdN__xahnm7I4xsFreV5hBzRRN8so,2971
20
21
  crystalwindow/gui.py,sha256=9JA25IztgqSYN1NnWVKK99G0rlEosXf2ATWww2rUZIQ,5353
21
22
  crystalwindow/gui_ext.py,sha256=JctpNPr7gtGdro3csyUo9ft3FFArj3JhkVlgKF0lyME,3407
22
- crystalwindow/math.py,sha256=slOY3KQZ99VDMUMxsSJabMyRtJcwVzEyxR2RoXspHho,963
23
+ crystalwindow/math.py,sha256=AGhLGkPWozNOMlSieF5u8jSDY0qakOPJIi5aWI9P91o,1598
23
24
  crystalwindow/messagebus.py,sha256=9K2P_TkdQ1rt-oouIkRg_XHwMTwykttBt-9gFYaItyI,696
24
25
  crystalwindow/objects.py,sha256=InChyxjOWya-XdYXGIAn9rp0waQkLvhTsRWZ0ANYHIU,5606
25
26
  crystalwindow/sprites.py,sha256=IADCQetFDQoat3qGpKkH93TdtqqgldfHl4N0HKX1Ajc,7480
@@ -40,8 +41,8 @@ crystalwindow/gametests/sandbox.py,sha256=Oo2tU2N0y3BPVa6T5vs_h9N6islhQrjSrr_78X
40
41
  crystalwindow/gametests/squaremove.py,sha256=ei6DMnvcgpOhmxbGv-Yqmx5EqiZjKbVlZhI7YbT2hY8,643
41
42
  crystalwindow/gametests/testtttagain.py,sha256=oIhK9MGgMVly_W2lRwD9Hn9WyPdd8JnX2HGrLTGZdxY,373
42
43
  crystalwindow/gametests/windowtesting.py,sha256=_9X6wnV1-_X_PtNS-0zu-k209NtFIwAc4vpxLPp7V2o,97
43
- crystalwindow-5.5.dist-info/licenses/LICENSE,sha256=Gt5cJRchdNt0guxyQMHKsATN5PM5mjuDhdO6Gzs9qQc,1096
44
- crystalwindow-5.5.dist-info/METADATA,sha256=ZGYHwqby96I0Z_j7qmWzCYHJt3PbhbRKE9lOWppMuUs,7523
45
- crystalwindow-5.5.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
46
- crystalwindow-5.5.dist-info/top_level.txt,sha256=PeQSld4b19XWT-zvbYkvE2Xg8sakIMbDzSzSdOSRN8o,14
47
- crystalwindow-5.5.dist-info/RECORD,,
44
+ crystalwindow-5.6.dist-info/licenses/LICENSE,sha256=Gt5cJRchdNt0guxyQMHKsATN5PM5mjuDhdO6Gzs9qQc,1096
45
+ crystalwindow-5.6.dist-info/METADATA,sha256=yaYpHzrlqZEw-YjnFC4qC1k9JNUyiN_kS4GShCjwwzw,7523
46
+ crystalwindow-5.6.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
47
+ crystalwindow-5.6.dist-info/top_level.txt,sha256=PeQSld4b19XWT-zvbYkvE2Xg8sakIMbDzSzSdOSRN8o,14
48
+ crystalwindow-5.6.dist-info/RECORD,,