splashscreen-engine 2.0.6__tar.gz → 2.0.7__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.
@@ -0,0 +1,179 @@
1
+ # Required Modules
2
+ import requests
3
+
4
+ # Pre-Installed Modules
5
+ import platform
6
+ import datetime
7
+ import json
8
+ import uuid
9
+ from pathlib import Path
10
+ import os
11
+ from typing import Any
12
+
13
+
14
+ # Firebase Database URL
15
+ DATABASE_URL = "https://splashscreenanalytics-default-rtdb.europe-west1.firebasedatabase.app"
16
+
17
+
18
+ class Analyse:
19
+
20
+ def __init__(self):
21
+
22
+ # ------- MAKING FRAMEWORK FOLDER ----------
23
+
24
+ # Getting File Path for Windows
25
+ if platform.system() == "Windows":
26
+
27
+ local_appdata = os.getenv("LOCALAPPDATA")
28
+ if not local_appdata:
29
+ # Unable to find app data, so don't break the framework and stop analytics
30
+ self.success = False
31
+ return
32
+ self.APP_DIR = Path(local_appdata) / "SplashScreenEngine"
33
+
34
+
35
+ # Getting File Path for Linux / macOS
36
+ else:
37
+ self.APP_DIR = Path.home() / ".SplashScreenEngine"
38
+
39
+ self.success = True # File Path Created
40
+
41
+ # Create Folder
42
+ self.APP_DIR.mkdir(exist_ok=True)
43
+
44
+
45
+ # JSON File Path
46
+ self.DATA_FILE = self.APP_DIR / "SplashData.json"
47
+
48
+ # Default Data Structure
49
+ self.DATA: dict[str,Any] = {
50
+
51
+ # Unique User ID
52
+ "user_id": str(uuid.uuid4()),
53
+
54
+ # OS type
55
+ "OS": platform.system(),
56
+
57
+ # Error Logs
58
+ "errors": {},
59
+
60
+ # Functions Used
61
+ "functions_used": {},
62
+
63
+ # Last Usage Time
64
+ "last_usage": None,
65
+
66
+ # Program running time (seconds)
67
+ "runtime": None,
68
+
69
+ # Total Runtime of module usage till it was installed
70
+ "total_runtime": 0.0
71
+ }
72
+
73
+
74
+ # Other required variables
75
+ self.start_time = None
76
+
77
+
78
+ self.file_exists()
79
+ self.start()
80
+
81
+
82
+ # Checks if file exists and openable
83
+ def file_exists(self):
84
+
85
+ # Return if path not created
86
+ if not self.success:
87
+ return
88
+
89
+ try :
90
+ # Create JSON File if not exists
91
+ if not self.DATA_FILE.exists():
92
+
93
+ # Create JSON File
94
+ with open(self.DATA_FILE, "w") as f:
95
+ json.dump(self.DATA, f, indent=4)
96
+
97
+ # Save JSON File as dictionary in `DATA` variable if exists
98
+ else:
99
+
100
+ with open(self.DATA_FILE, "r") as f:
101
+ self.DATA = json.load(f)
102
+
103
+ # If unable to create/read file
104
+ except Exception as e:
105
+ self.DATA["errors"][self.DATA["user_id"]] = str(e)
106
+ self.success = False
107
+
108
+ # Start Analyzing Data
109
+ def start(self):
110
+
111
+ # Return if path not created
112
+ if not self.success:
113
+ return
114
+
115
+ self.start_time = datetime.datetime.now()
116
+
117
+ # Store which functions used and store usage time
118
+ def append_function(self,func_name):
119
+
120
+ # Return if path not created
121
+ if not self.success:
122
+ return
123
+
124
+ current_time = datetime.datetime.now().strftime("%Y-%m-%d_%H-%M-%S-%f")
125
+ self.DATA["functions_used"][current_time] = func_name
126
+
127
+ # Store Errors
128
+ def add_error(self,error):
129
+
130
+ # Return if path not created
131
+ if not self.success:
132
+ return
133
+
134
+ current_time = datetime.datetime.now().strftime("%Y-%m-%d_%H-%M-%S-%f")
135
+ self.DATA["errors"][current_time] = str(error)
136
+
137
+ # save all the data at the end
138
+ def save(self):
139
+
140
+ if self.start_time is None:
141
+ return
142
+
143
+ # Return if path not created
144
+ if not self.success:
145
+ return
146
+
147
+ current_time = datetime.datetime.now()
148
+ runtime = (current_time - self.start_time).total_seconds()
149
+ total_runtime = float(self.DATA["total_runtime"]) + float(runtime)
150
+ current_time = current_time.strftime("%Y-%m-%d_%H-%M-%S-%f")
151
+
152
+ self.DATA["total_runtime"] = total_runtime
153
+ self.DATA["runtime"] = runtime
154
+ self.DATA["last_usage"] = current_time
155
+
156
+
157
+ try:
158
+ response = requests.post(
159
+
160
+ f"{DATABASE_URL}/analytics.json",
161
+
162
+ json=self.DATA,
163
+
164
+ timeout=3
165
+ )
166
+ response.raise_for_status()
167
+
168
+ except Exception as e:
169
+ self.add_error(e)
170
+
171
+
172
+ # Save Everything in the json file
173
+ try:
174
+ with open(self.DATA_FILE, "w") as f:
175
+ json.dump(self.DATA, f, indent=4)
176
+ except Exception as e:
177
+ self.add_error(e)
178
+
179
+
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: splashscreen-engine
3
- Version: 2.0.6
3
+ Version: 2.0.7
4
4
  Summary: A Python framework for creating splash screens with videos, images, animated loading bars, threaded rendering, transparency, and dynamic UI support.
5
5
  Home-page: https://github.com/NamanChhabra21/splashscreen-engine
6
6
  Author: Naman Chhabra
@@ -10,25 +10,29 @@ Project-URL: Source, https://github.com/NamanChhabra21/splashscreen-engine
10
10
  Project-URL: Issues, https://github.com/NamanChhabra21/splashscreen-engine/issues
11
11
  Project-URL: Discussions, https://github.com/NamanChhabra21/splashscreen-engine/discussions
12
12
  Project-URL: PyPI, https://pypi.org/project/splashscreen-engine/
13
- Keywords: pygame,splash-screen,loading-screen,opencv,video-rendering,pygame-framework,python-gui,animation,desktop-app,threaded-rendering,video-loader,splashscreen,loading-bar,multimedia
13
+ Keywords: pygame,splash-screen,loading-screen,opencv,video-rendering,pygame-framework,python-gui,animation,desktop-app,threaded-rendering,video-loader,splashscreen,loading-bar,multimedia,splash
14
14
  Classifier: Programming Language :: Python :: 3
15
15
  Classifier: Programming Language :: Python :: 3.8
16
16
  Classifier: Programming Language :: Python :: 3.9
17
17
  Classifier: Programming Language :: Python :: 3.10
18
18
  Classifier: Programming Language :: Python :: 3.11
19
19
  Classifier: Programming Language :: Python :: 3.12
20
+ Classifier: Programming Language :: Python :: 3.13
20
21
  Classifier: License :: OSI Approved :: MIT License
21
22
  Classifier: Operating System :: Microsoft :: Windows
22
23
  Classifier: Topic :: Software Development :: Libraries
23
24
  Classifier: Topic :: Multimedia :: Graphics
24
25
  Classifier: Topic :: Multimedia :: Video
25
26
  Classifier: Topic :: Games/Entertainment
27
+ Classifier: Topic :: Multimedia
28
+ Classifier: Topic :: Desktop Environment
26
29
  Classifier: Intended Audience :: Developers
27
30
  Requires-Python: >=3.8
28
31
  Description-Content-Type: text/markdown
29
32
  Requires-Dist: pygame
30
33
  Requires-Dist: opencv-python
31
34
  Requires-Dist: numpy
35
+ Requires-Dist: requests
32
36
  Dynamic: author
33
37
  Dynamic: author-email
34
38
  Dynamic: classifier
@@ -6,17 +6,19 @@ with open("README.md", "r", encoding="utf-8") as f:
6
6
  setup(
7
7
  name="splashscreen-engine",
8
8
 
9
- version="2.0.6",
9
+ version="2.0.7",
10
10
 
11
11
  py_modules=[
12
12
  "splashscreen_engine",
13
- "video_renderer"
13
+ "video_renderer",
14
+ "Analytics"
14
15
  ],
15
16
 
16
17
  install_requires=[
17
18
  "pygame",
18
19
  "opencv-python",
19
- "numpy"
20
+ "numpy",
21
+ "requests"
20
22
  ],
21
23
 
22
24
  author="Naman Chhabra",
@@ -58,7 +60,8 @@ setup(
58
60
  "video-loader",
59
61
  "splashscreen",
60
62
  "loading-bar",
61
- "multimedia"
63
+ "multimedia",
64
+ "splash"
62
65
  ],
63
66
 
64
67
  classifiers=[
@@ -68,6 +71,7 @@ setup(
68
71
  "Programming Language :: Python :: 3.10",
69
72
  "Programming Language :: Python :: 3.11",
70
73
  "Programming Language :: Python :: 3.12",
74
+ "Programming Language :: Python :: 3.13",
71
75
 
72
76
  "License :: OSI Approved :: MIT License",
73
77
 
@@ -77,6 +81,8 @@ setup(
77
81
  "Topic :: Multimedia :: Graphics",
78
82
  "Topic :: Multimedia :: Video",
79
83
  "Topic :: Games/Entertainment",
84
+ "Topic :: Multimedia",
85
+ "Topic :: Desktop Environment",
80
86
 
81
87
  "Intended Audience :: Developers"
82
88
  ],
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: splashscreen-engine
3
- Version: 2.0.6
3
+ Version: 2.0.7
4
4
  Summary: A Python framework for creating splash screens with videos, images, animated loading bars, threaded rendering, transparency, and dynamic UI support.
5
5
  Home-page: https://github.com/NamanChhabra21/splashscreen-engine
6
6
  Author: Naman Chhabra
@@ -10,25 +10,29 @@ Project-URL: Source, https://github.com/NamanChhabra21/splashscreen-engine
10
10
  Project-URL: Issues, https://github.com/NamanChhabra21/splashscreen-engine/issues
11
11
  Project-URL: Discussions, https://github.com/NamanChhabra21/splashscreen-engine/discussions
12
12
  Project-URL: PyPI, https://pypi.org/project/splashscreen-engine/
13
- Keywords: pygame,splash-screen,loading-screen,opencv,video-rendering,pygame-framework,python-gui,animation,desktop-app,threaded-rendering,video-loader,splashscreen,loading-bar,multimedia
13
+ Keywords: pygame,splash-screen,loading-screen,opencv,video-rendering,pygame-framework,python-gui,animation,desktop-app,threaded-rendering,video-loader,splashscreen,loading-bar,multimedia,splash
14
14
  Classifier: Programming Language :: Python :: 3
15
15
  Classifier: Programming Language :: Python :: 3.8
16
16
  Classifier: Programming Language :: Python :: 3.9
17
17
  Classifier: Programming Language :: Python :: 3.10
18
18
  Classifier: Programming Language :: Python :: 3.11
19
19
  Classifier: Programming Language :: Python :: 3.12
20
+ Classifier: Programming Language :: Python :: 3.13
20
21
  Classifier: License :: OSI Approved :: MIT License
21
22
  Classifier: Operating System :: Microsoft :: Windows
22
23
  Classifier: Topic :: Software Development :: Libraries
23
24
  Classifier: Topic :: Multimedia :: Graphics
24
25
  Classifier: Topic :: Multimedia :: Video
25
26
  Classifier: Topic :: Games/Entertainment
27
+ Classifier: Topic :: Multimedia
28
+ Classifier: Topic :: Desktop Environment
26
29
  Classifier: Intended Audience :: Developers
27
30
  Requires-Python: >=3.8
28
31
  Description-Content-Type: text/markdown
29
32
  Requires-Dist: pygame
30
33
  Requires-Dist: opencv-python
31
34
  Requires-Dist: numpy
35
+ Requires-Dist: requests
32
36
  Dynamic: author
33
37
  Dynamic: author-email
34
38
  Dynamic: classifier
@@ -1,3 +1,4 @@
1
+ Analytics.py
1
2
  README.md
2
3
  setup.py
3
4
  splashscreen_engine.py
@@ -1,2 +1,3 @@
1
+ Analytics
1
2
  splashscreen_engine
2
3
  video_renderer
@@ -3,19 +3,22 @@ import threading
3
3
  import time
4
4
 
5
5
 
6
-
7
6
  # Hide pygame Welcome Message and centralize the screen
8
7
  os.environ['PYGAME_HIDE_SUPPORT_PROMPT'] = "hide"
9
8
  s = '1'
10
9
  os.environ['SDL_VIDEO_CENTERED'] = s
11
10
 
12
- # Modules
11
+ # Required Modules
13
12
  import pygame
14
13
 
15
14
  # Engine Files
16
15
  import video_renderer
16
+ import Analytics
17
17
 
18
+ # Setup Analysis
19
+ analyse = Analytics.Analyse()
18
20
 
21
+ # Required Variables to check if the program is stopped or not
19
22
  deleted_by_user = False
20
23
  program_stopped = False
21
24
 
@@ -169,6 +172,8 @@ class Screen:
169
172
 
170
173
  def __init__(self,title_bar=False):
171
174
 
175
+
176
+
172
177
  if not pygame.get_init():
173
178
  pygame.init()
174
179
 
@@ -228,10 +233,12 @@ class Screen:
228
233
 
229
234
 
230
235
  def get_size(self):
236
+ analyse.append_function("get_size()")
231
237
  return self.width,self.height
232
238
 
233
239
  def start(self):
234
240
 
241
+ analyse.append_function("start()")
235
242
 
236
243
  self.running = True
237
244
 
@@ -261,6 +268,7 @@ class Screen:
261
268
  def mainloop():
262
269
  global program_stopped
263
270
 
271
+
264
272
  if not self.screen:
265
273
  self.start()
266
274
 
@@ -324,10 +332,13 @@ class Screen:
324
332
  self.clock.tick(60)
325
333
  global deleted_by_user
326
334
  deleted_by_user = True
335
+
327
336
  threading.Thread(target=mainloop).start() # Starts Mainloop as background process
328
337
 
329
338
  def stop(self,quit_pygame = True):
330
339
 
340
+ analyse.append_function("stop()")
341
+
331
342
  # Stops the Window
332
343
  self.running = False
333
344
  self.stopped = True
@@ -340,10 +351,13 @@ class Screen:
340
351
  if quit_pygame:
341
352
  pygame.quit()
342
353
 
354
+ analyse.save() # save Analysis Data in firebase
355
+
343
356
 
344
357
 
345
358
  def size(self, width=750, height=500, fullscreen=False):
346
359
 
360
+ analyse.append_function("size()")
347
361
 
348
362
  # Check if width and height is integer and more than 0
349
363
  if (
@@ -393,6 +407,8 @@ class Screen:
393
407
 
394
408
  def title(self, text="Splash Screen"):
395
409
 
410
+ analyse.append_function("title")
411
+
396
412
  self.caption = text.strip()
397
413
 
398
414
  pygame.display.set_caption(self.caption)
@@ -400,6 +416,7 @@ class Screen:
400
416
  @staticmethod
401
417
  def wait(seconds):
402
418
 
419
+
403
420
  if seconds <= 1:
404
421
 
405
422
  avoid_lag()
@@ -418,9 +435,14 @@ class Screen:
418
435
 
419
436
  def set_bg_color(self, color=(0, 0, 0)):
420
437
 
438
+ analyse.append_function("set_bg_color()")
439
+
421
440
  self.bgColor = color
422
441
 
423
442
  def set_icon(self,path):
443
+
444
+ analyse.append_function("set_icon()")
445
+
424
446
  if not self.title_bar:
425
447
  raise RuntimeError("Unable to set Icon, Title Bar is disabled.")
426
448
  self.icon = path
@@ -430,11 +452,16 @@ class Screen:
430
452
 
431
453
 
432
454
  def is_quit(self):
455
+
456
+ analyse.append_function("is_quit")
457
+
433
458
  if not self.title_bar:
434
459
  raise RuntimeError("`is_quit` only works if you enable Title Bar.")
435
460
 
461
+
436
462
  return program_stopped # True if quit else False
437
463
  def is_escaped(self):
464
+
438
465
  if not self.title_bar:
439
466
  raise RuntimeError("`is_escaped` only works if Title Bar is enabled.")
440
467
  escape = self.is_escape
@@ -446,6 +473,8 @@ class BackgroundVideo:
446
473
 
447
474
  def __init__(self, screen_object, path, fps=30,loop=False):
448
475
 
476
+ analyse.append_function("BackgroundVideo()")
477
+
449
478
  # ONLY SCREEN ALLOWED
450
479
  if not isinstance(screen_object, Screen):
451
480
 
@@ -483,6 +512,8 @@ class BackgroundVideo:
483
512
 
484
513
  def play(self):
485
514
 
515
+ analyse.append_function("play()")
516
+
486
517
  self.stop = False
487
518
 
488
519
  self.is_playing = True
@@ -542,12 +573,16 @@ class BackgroundVideo:
542
573
 
543
574
  def pause(self):
544
575
 
576
+ analyse.append_function("pause()")
577
+
545
578
  self.stop = True
546
579
 
547
580
  self.is_playing = False
548
581
 
549
582
  def resume(self):
550
583
 
584
+ analyse.append_function("resume()")
585
+
551
586
  if self.stop:
552
587
  self.stop = False
553
588
 
@@ -556,6 +591,8 @@ class BackgroundVideo:
556
591
 
557
592
  def delete(self):
558
593
 
594
+ analyse.append_function("delete()")
595
+
559
596
  self.pause()
560
597
 
561
598
  self.video.reset_frames()
@@ -563,6 +600,8 @@ class BackgroundVideo:
563
600
 
564
601
  def transparency(self, level=120):
565
602
 
603
+ analyse.append_function("transparency()")
604
+
566
605
  if level < 0:
567
606
  level = 0
568
607
 
@@ -575,12 +614,16 @@ class BackgroundVideo:
575
614
 
576
615
  def stop_transparency(self):
577
616
 
617
+ analyse.append_function("stop_transparency()")
618
+
578
619
  self.transparent = False
579
620
 
580
621
  def stop_loop(self):
622
+ analyse.append_function("stop_loop()")
581
623
  self.loop = False
582
624
 
583
625
  def playing(self):
626
+ analyse.append_function("playing()")
584
627
  return self.is_playing
585
628
 
586
629
 
@@ -588,6 +631,8 @@ class BackgroundImage:
588
631
 
589
632
  def __init__(self, parent, path):
590
633
 
634
+ analyse.append_function("BackgroundImage()")
635
+
591
636
  # ONLY SCREEN ALLOWED
592
637
  if not isinstance(parent, Screen):
593
638
 
@@ -605,13 +650,17 @@ class BackgroundImage:
605
650
  self.image = self.original_image
606
651
 
607
652
  def set(self):
653
+ analyse.append_function("set()")
608
654
  self.parent.current_background = self
609
655
 
610
656
 
611
657
  class LoadingBar:
612
658
 
659
+
613
660
  def __init__(self, parent, width=None, height=None,position="center",add_xy = (0,0)):
614
661
 
662
+ analyse.append_function("LoadingBar()")
663
+
615
664
  check_valid_pos(position,"LoadingBar")
616
665
  self.position = position.lower()
617
666
  self.add_xy = add_xy # adds / subtract the value of x-axis and y-axis from the chosen position
@@ -664,6 +713,7 @@ class LoadingBar:
664
713
  colour=(255, 255, 255),
665
714
  loading_colour=(0, 255, 0)
666
715
  ):
716
+ analyse.append_function("Bar: place()")
667
717
 
668
718
  self.colour = colour
669
719
 
@@ -672,7 +722,7 @@ class LoadingBar:
672
722
  self.visible = True
673
723
 
674
724
  def hide(self):
675
-
725
+ analyse.append_function("hide()")
676
726
  self.visible = False
677
727
 
678
728
  def set_progress(self, value):
@@ -687,6 +737,7 @@ class LoadingBar:
687
737
  self.progress = value
688
738
 
689
739
  def set_video(self,path):
740
+ analyse.append_function("set_video")
690
741
  self.video = video_renderer.Vid(path)
691
742
 
692
743
 
@@ -694,12 +745,17 @@ def check_valid_pos(string,object_type):
694
745
  available_position = ["right", "left", "down", "up", "center",None]
695
746
  if string not in available_position:
696
747
  available_position.pop() # Remove `None` for displaying Available positions
748
+
749
+ analyse.add_error("Wrong Argument in check_valid_pos")
750
+
697
751
  raise RuntimeError(f"`{object_type}` object got unknown positional argument. Please choose from {available_position}")
698
752
 
699
753
  class Text:
700
754
 
701
755
  def __init__(self,parent,text="Your Text Here",font=None,size=20,position="center",add_xy = (0,0),colour=(255, 255, 255)):
702
756
 
757
+ analyse.append_function("Text()")
758
+
703
759
  check_valid_pos(position,"Text")
704
760
  self.position = position.lower()
705
761
  self.add_xy = add_xy # adds / subtract the value of x-axis and y-axis from the chosen position
@@ -722,6 +778,7 @@ class Text:
722
778
 
723
779
  def edit(self,text=None,font=None,new_size=None,position=None,add_xy=None,colour=None):
724
780
 
781
+
725
782
  if text is not None:
726
783
  self.text = text
727
784
 
@@ -744,13 +801,18 @@ class Text:
744
801
  self.colour = colour
745
802
 
746
803
  def hide(self):
804
+ analyse.append_function("Text Hidden")
747
805
  self.visible = False
748
806
 
749
807
  def show(self):
808
+ analyse.append_function("text show()")
750
809
  self.visible = True
751
810
 
752
811
  class Documentation:
753
812
  def __init__(self):
813
+
814
+ analyse.append_function("Documentation()")
815
+
754
816
  self.GithubReadMeLink = "https://github.com/NamanChhabra21/splashscreen-engine/blob/main/README.md"
755
817
  self.gmail = "chhabranaman21@gmail.com"
756
818
  self.ytChannel = "www.youtube.com/@GenZCoderZShorts"
@@ -760,8 +822,11 @@ class Documentation:
760
822
  self.discussions = "https://github.com/NamanChhabra21/splashscreen-engine/discussions"
761
823
 
762
824
  def open(self):
825
+
826
+ analyse.append_function("open documentation()")
763
827
  os.startfile(self.GithubReadMeLink)
764
828
  def contact(self):
829
+ analyse.append_function("contact()")
765
830
  print(f"For Contact & Feedback :\n\
766
831
  Github : {self.GithubLink}\n\
767
832
  PyPI : {self.pypi}\n\