Python-With-Gtk-Template/src/__init__.py

51 lines
1.4 KiB
Python
Raw Normal View History

2020-05-08 00:07:33 +00:00
# Python imports
2022-01-23 22:56:27 +00:00
import os, inspect, time
2020-05-08 00:07:33 +00:00
2022-01-23 22:56:27 +00:00
# Lib imports
2020-05-08 00:07:33 +00:00
# Application imports
from utils import Settings
2022-01-31 00:06:02 +00:00
from controller import Controller
2021-10-11 04:28:19 +00:00
from __builtins__ import Builtins
2020-05-08 00:07:33 +00:00
2022-01-23 22:56:27 +00:00
2021-10-11 04:28:19 +00:00
class Main(Builtins):
2022-01-23 22:56:27 +00:00
def __init__(self, args, unknownargs):
if not debug:
event_system.create_ipc_server()
time.sleep(0.2)
if not trace_debug:
if not event_system.is_ipc_alive:
if unknownargs:
for arg in unknownargs:
if os.path.isdir(arg):
message = f"FILE|{arg}"
event_system.send_ipc_message(message)
raise Exception("IPC Server Exists: Will send data to it and close...")
2020-05-08 00:07:33 +00:00
settings = Settings()
2022-01-23 22:56:27 +00:00
settings.create_window()
2020-05-08 00:07:33 +00:00
2022-01-23 23:33:52 +00:00
controller = Controller(settings, args, unknownargs)
2022-01-23 22:56:27 +00:00
if not controller:
raise Exception("Controller exited and doesn't exist...")
2020-05-08 00:07:33 +00:00
2022-01-23 22:56:27 +00:00
# Gets the methods from the classes and sets to handler.
# Then, builder from settings will connect to any signals it needs.
classes = [controller]
2020-05-08 00:07:33 +00:00
handlers = {}
for c in classes:
2021-03-18 05:24:08 +00:00
methods = None
try:
methods = inspect.getmembers(c, predicate=inspect.ismethod)
handlers.update(methods)
except Exception as e:
2022-01-23 22:56:27 +00:00
print(repr(e))
2020-05-08 00:07:33 +00:00
2022-01-23 22:56:27 +00:00
settings.get_builder().connect_signals(handlers)