splashscreen-engine 2.0.6__tar.gz → 2.0.8__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.8
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.8",
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.8
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
 
@@ -299,8 +307,14 @@ class Screen:
299
307
  self.screen.fill(self.bgColor)
300
308
 
301
309
  # DRAW BACKGROUND IMAGE
310
+
302
311
  if self.current_background:
303
- bg = pygame.transform.scale(self.current_background.original_image,(self.width,self.height))
312
+ screen_width, screen_height = self.screen.get_size()
313
+
314
+ bg = pygame.transform.scale(
315
+ self.current_background.original_image,
316
+ (screen_width, screen_height)
317
+ )
304
318
  self.screen.blit(bg,(0, 0))
305
319
  draw_loading_bar(self.screen,self.current_background.ui_elements)
306
320
  draw_text(self.screen,self.current_background.ui_elements)
@@ -324,10 +338,13 @@ class Screen:
324
338
  self.clock.tick(60)
325
339
  global deleted_by_user
326
340
  deleted_by_user = True
341
+
327
342
  threading.Thread(target=mainloop).start() # Starts Mainloop as background process
328
343
 
329
344
  def stop(self,quit_pygame = True):
330
345
 
346
+ analyse.append_function("stop()")
347
+
331
348
  # Stops the Window
332
349
  self.running = False
333
350
  self.stopped = True
@@ -340,10 +357,13 @@ class Screen:
340
357
  if quit_pygame:
341
358
  pygame.quit()
342
359
 
360
+ analyse.save() # save Analysis Data in firebase
361
+
343
362
 
344
363
 
345
364
  def size(self, width=750, height=500, fullscreen=False):
346
365
 
366
+ analyse.append_function("size()")
347
367
 
348
368
  # Check if width and height is integer and more than 0
349
369
  if (
@@ -393,6 +413,8 @@ class Screen:
393
413
 
394
414
  def title(self, text="Splash Screen"):
395
415
 
416
+ analyse.append_function("title")
417
+
396
418
  self.caption = text.strip()
397
419
 
398
420
  pygame.display.set_caption(self.caption)
@@ -400,6 +422,7 @@ class Screen:
400
422
  @staticmethod
401
423
  def wait(seconds):
402
424
 
425
+
403
426
  if seconds <= 1:
404
427
 
405
428
  avoid_lag()
@@ -418,9 +441,14 @@ class Screen:
418
441
 
419
442
  def set_bg_color(self, color=(0, 0, 0)):
420
443
 
444
+ analyse.append_function("set_bg_color()")
445
+
421
446
  self.bgColor = color
422
447
 
423
448
  def set_icon(self,path):
449
+
450
+ analyse.append_function("set_icon()")
451
+
424
452
  if not self.title_bar:
425
453
  raise RuntimeError("Unable to set Icon, Title Bar is disabled.")
426
454
  self.icon = path
@@ -430,11 +458,16 @@ class Screen:
430
458
 
431
459
 
432
460
  def is_quit(self):
461
+
462
+ analyse.append_function("is_quit")
463
+
433
464
  if not self.title_bar:
434
465
  raise RuntimeError("`is_quit` only works if you enable Title Bar.")
435
466
 
467
+
436
468
  return program_stopped # True if quit else False
437
469
  def is_escaped(self):
470
+
438
471
  if not self.title_bar:
439
472
  raise RuntimeError("`is_escaped` only works if Title Bar is enabled.")
440
473
  escape = self.is_escape
@@ -446,6 +479,8 @@ class BackgroundVideo:
446
479
 
447
480
  def __init__(self, screen_object, path, fps=30,loop=False):
448
481
 
482
+ analyse.append_function("BackgroundVideo()")
483
+
449
484
  # ONLY SCREEN ALLOWED
450
485
  if not isinstance(screen_object, Screen):
451
486
 
@@ -483,6 +518,8 @@ class BackgroundVideo:
483
518
 
484
519
  def play(self):
485
520
 
521
+ analyse.append_function("play()")
522
+
486
523
  self.stop = False
487
524
 
488
525
  self.is_playing = True
@@ -542,27 +579,38 @@ class BackgroundVideo:
542
579
 
543
580
  def pause(self):
544
581
 
582
+ analyse.append_function("pause()")
583
+
545
584
  self.stop = True
546
585
 
547
586
  self.is_playing = False
548
587
 
549
588
  def resume(self):
550
589
 
590
+ analyse.append_function("resume()")
591
+
551
592
  if self.stop:
552
593
  self.stop = False
553
594
 
554
595
  self.play()
555
596
 
556
-
557
597
  def delete(self):
558
598
 
599
+ analyse.append_function("delete()")
600
+
559
601
  self.pause()
560
602
 
561
603
  self.video.reset_frames()
604
+
562
605
  self.frame = None
563
606
 
607
+ if self.parent.foreground_video is self:
608
+ self.parent.foreground_video = None
609
+
564
610
  def transparency(self, level=120):
565
611
 
612
+ analyse.append_function("transparency()")
613
+
566
614
  if level < 0:
567
615
  level = 0
568
616
 
@@ -575,12 +623,16 @@ class BackgroundVideo:
575
623
 
576
624
  def stop_transparency(self):
577
625
 
626
+ analyse.append_function("stop_transparency()")
627
+
578
628
  self.transparent = False
579
629
 
580
630
  def stop_loop(self):
631
+ analyse.append_function("stop_loop()")
581
632
  self.loop = False
582
633
 
583
634
  def playing(self):
635
+ analyse.append_function("playing()")
584
636
  return self.is_playing
585
637
 
586
638
 
@@ -588,6 +640,8 @@ class BackgroundImage:
588
640
 
589
641
  def __init__(self, parent, path):
590
642
 
643
+ analyse.append_function("BackgroundImage()")
644
+
591
645
  # ONLY SCREEN ALLOWED
592
646
  if not isinstance(parent, Screen):
593
647
 
@@ -605,13 +659,17 @@ class BackgroundImage:
605
659
  self.image = self.original_image
606
660
 
607
661
  def set(self):
662
+ analyse.append_function("set()")
608
663
  self.parent.current_background = self
609
664
 
610
665
 
611
666
  class LoadingBar:
612
667
 
668
+
613
669
  def __init__(self, parent, width=None, height=None,position="center",add_xy = (0,0)):
614
670
 
671
+ analyse.append_function("LoadingBar()")
672
+
615
673
  check_valid_pos(position,"LoadingBar")
616
674
  self.position = position.lower()
617
675
  self.add_xy = add_xy # adds / subtract the value of x-axis and y-axis from the chosen position
@@ -664,6 +722,7 @@ class LoadingBar:
664
722
  colour=(255, 255, 255),
665
723
  loading_colour=(0, 255, 0)
666
724
  ):
725
+ analyse.append_function("Bar: place()")
667
726
 
668
727
  self.colour = colour
669
728
 
@@ -672,7 +731,7 @@ class LoadingBar:
672
731
  self.visible = True
673
732
 
674
733
  def hide(self):
675
-
734
+ analyse.append_function("hide()")
676
735
  self.visible = False
677
736
 
678
737
  def set_progress(self, value):
@@ -687,6 +746,7 @@ class LoadingBar:
687
746
  self.progress = value
688
747
 
689
748
  def set_video(self,path):
749
+ analyse.append_function("set_video")
690
750
  self.video = video_renderer.Vid(path)
691
751
 
692
752
 
@@ -694,12 +754,17 @@ def check_valid_pos(string,object_type):
694
754
  available_position = ["right", "left", "down", "up", "center",None]
695
755
  if string not in available_position:
696
756
  available_position.pop() # Remove `None` for displaying Available positions
757
+
758
+ analyse.add_error("Wrong Argument in check_valid_pos")
759
+
697
760
  raise RuntimeError(f"`{object_type}` object got unknown positional argument. Please choose from {available_position}")
698
761
 
699
762
  class Text:
700
763
 
701
764
  def __init__(self,parent,text="Your Text Here",font=None,size=20,position="center",add_xy = (0,0),colour=(255, 255, 255)):
702
765
 
766
+ analyse.append_function("Text()")
767
+
703
768
  check_valid_pos(position,"Text")
704
769
  self.position = position.lower()
705
770
  self.add_xy = add_xy # adds / subtract the value of x-axis and y-axis from the chosen position
@@ -722,6 +787,7 @@ class Text:
722
787
 
723
788
  def edit(self,text=None,font=None,new_size=None,position=None,add_xy=None,colour=None):
724
789
 
790
+
725
791
  if text is not None:
726
792
  self.text = text
727
793
 
@@ -744,13 +810,18 @@ class Text:
744
810
  self.colour = colour
745
811
 
746
812
  def hide(self):
813
+ analyse.append_function("Text Hidden")
747
814
  self.visible = False
748
815
 
749
816
  def show(self):
817
+ analyse.append_function("text show()")
750
818
  self.visible = True
751
819
 
752
820
  class Documentation:
753
821
  def __init__(self):
822
+
823
+ analyse.append_function("Documentation()")
824
+
754
825
  self.GithubReadMeLink = "https://github.com/NamanChhabra21/splashscreen-engine/blob/main/README.md"
755
826
  self.gmail = "chhabranaman21@gmail.com"
756
827
  self.ytChannel = "www.youtube.com/@GenZCoderZShorts"
@@ -760,8 +831,11 @@ class Documentation:
760
831
  self.discussions = "https://github.com/NamanChhabra21/splashscreen-engine/discussions"
761
832
 
762
833
  def open(self):
834
+
835
+ analyse.append_function("open documentation()")
763
836
  os.startfile(self.GithubReadMeLink)
764
837
  def contact(self):
838
+ analyse.append_function("contact()")
765
839
  print(f"For Contact & Feedback :\n\
766
840
  Github : {self.GithubLink}\n\
767
841
  PyPI : {self.pypi}\n\