Pytop/src/Pytop/PyTop.py

53 lines
1.3 KiB
Python
Raw Normal View History

2019-06-09 06:24:03 +00:00
#!/usr/bin/python3
# Gtk imports
2019-06-23 00:21:18 +00:00
import gi, faulthandler, signal
2019-06-09 06:24:03 +00:00
gi.require_version('Gtk', '3.0')
from gi.repository import Gtk as gtk
from gi.repository import Gdk as gdk
2019-06-23 00:21:18 +00:00
from gi.repository import GLib
2019-06-09 06:24:03 +00:00
# Python imports
2019-07-05 06:08:18 +00:00
import inspect
2019-09-02 21:37:25 +00:00
from setproctitle import setproctitle
# Application imports
2019-06-23 00:21:18 +00:00
from utils import Settings
2019-07-05 19:34:15 +00:00
from signal_classes import CrossClassSignals, GridSignals
2019-06-09 06:24:03 +00:00
class Main:
2019-09-02 21:37:25 +00:00
setproctitle('Pytop')
2019-06-09 06:24:03 +00:00
def __init__(self):
2019-07-05 06:08:18 +00:00
GLib.unix_signal_add(GLib.PRIORITY_DEFAULT, signal.SIGINT, gtk.main_quit)
faulthandler.enable() # For better debug info
2019-06-09 06:24:03 +00:00
builder = gtk.Builder()
settings = Settings()
settings.attachBuilder(builder)
2019-07-05 06:08:18 +00:00
# Gets the methods from the classes and sets to handler.
# Then, builder connects to any signals it needs.
classes = [CrossClassSignals(settings),
GridSignals(settings)]
2019-07-05 06:08:18 +00:00
handlers = {}
for c in classes:
methods = inspect.getmembers(c, predicate=inspect.ismethod)
handlers.update(methods)
2019-06-09 06:24:03 +00:00
2019-07-05 06:08:18 +00:00
builder.connect_signals(handlers)
window = settings.createWindow()
2019-06-09 06:24:03 +00:00
window.fullscreen()
window.show_all()
if __name__ == "__main__":
try:
main = Main()
gtk.main()
except Exception as e:
print(e)