/ main.py
main.py
 1  '''
 2  	SuperFormat is a program that converts files into various formats
 3  	Copyright (C) 2025 daroi
 4  
 5      This program is free software: you can redistribute it and/or modify
 6      it under the terms of the GNU General Public License as published by
 7      the Free Software Foundation, either version 3 of the License, or
 8      (at your option) any later version.
 9  
10      This program is distributed in the hope that it will be useful,
11      but WITHOUT ANY WARRANTY; without even the implied warranty of
12      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13      GNU General Public License for more details.
14  
15      You should have received a copy of the GNU General Public License
16      along with this program.  If not, see <https://www.gnu.org/licenses/>.
17  '''
18  
19  import os
20  import sys
21  from PyQt6.QtWidgets import QApplication, QStackedWidget
22  # Import each Window
23  from app.views.main_window import MainWindow
24  from app.views.window_music import WindowMusic
25  from app.views.window_image import WindowImage
26  from app.views.window_movie import WindowMovie
27  from app.views.window_office import WindowOffice
28  from app.views.window_compress import WindowCompress
29  from app.views.window_model import WindowModel
30  
31  app = QApplication(sys.argv)
32  
33  stack = QStackedWidget()
34  
35  # Main Theme
36  app.setStyle("Fusion")
37  
38  def resource_path(rel_path):
39      """Get the resource path for pyinstaller"""
40      if hasattr(sys, "_MEIPASS"):
41          base_path = sys._MEIPASS
42      else:
43          base_path = os.path.abspath(".")
44      return os.path.join(base_path, rel_path)
45  
46  # it load style sheet if it exist
47  qss_path = resource_path("app/assets/style.qss")
48  
49  try:
50      with open(qss_path, "r") as f:
51          app.setStyleSheet(f.read())
52  except FileNotFoundError:
53      pass
54  
55  # Create the screen and pass the stack
56  main_window = MainWindow(stack)
57  window_music = WindowMusic(stack)
58  window_image = WindowImage(stack)
59  window_movie = WindowMovie(stack)
60  window_office = WindowOffice(stack)
61  window_compress = WindowCompress(stack)
62  window_model = WindowModel(stack)
63  
64  # Add each screen to stack
65  stack.addWidget(main_window)  # index 0
66  stack.addWidget(window_music)  # index 1
67  stack.addWidget(window_image)  # index 2
68  stack.addWidget(window_movie)   # index 3
69  stack.addWidget(window_office)  # index 4
70  stack.addWidget(window_compress)  # index 5
71  stack.addWidget(window_model)  # index 6
72  
73  stack.setWindowTitle("SuperFormat")
74  stack.setFixedSize(700, 500)  # Windows size
75  stack.show()
76  
77  sys.exit(app.exec())
78  
79