Updatred structure andf exec script
This commit is contained in:
parent
2a93b0e404
commit
e35ef4dcf7
|
@ -0,0 +1,38 @@
|
||||||
|
# Python imports
|
||||||
|
import inspect
|
||||||
|
|
||||||
|
from setproctitle import setproctitle
|
||||||
|
|
||||||
|
# Gtk imports
|
||||||
|
import gi, faulthandler, signal
|
||||||
|
gi.require_version('Gtk', '3.0')
|
||||||
|
|
||||||
|
from gi.repository import Gtk as gtk
|
||||||
|
from gi.repository import Gdk as gdk
|
||||||
|
from gi.repository import GLib
|
||||||
|
|
||||||
|
# Application imports
|
||||||
|
from utils import Settings, CrossClassSignals
|
||||||
|
from signal_classes import MainWindow, DrawingArea, MainMenuPopup
|
||||||
|
|
||||||
|
|
||||||
|
class Main:
|
||||||
|
def __init__(self, args):
|
||||||
|
settings = Settings()
|
||||||
|
builder = settings.returnBuilder()
|
||||||
|
|
||||||
|
# Gets the methods from the classes and sets to handler.
|
||||||
|
# Then, builder connects to any signals it needs.
|
||||||
|
utilsClass = CrossClassSignals(settings)
|
||||||
|
classes = [MainWindow(settings, utilsClass),
|
||||||
|
DrawingArea(settings, utilsClass),
|
||||||
|
MainMenuPopup(settings, utilsClass)]
|
||||||
|
|
||||||
|
handlers = {}
|
||||||
|
for c in classes:
|
||||||
|
methods = inspect.getmembers(c, predicate=inspect.ismethod)
|
||||||
|
handlers.update(methods)
|
||||||
|
|
||||||
|
builder.connect_signals(handlers)
|
||||||
|
window = settings.createWindow()
|
||||||
|
window.show()
|
|
@ -1,53 +1,32 @@
|
||||||
#!/usr/bin/python3
|
#!/usr/bin/python3
|
||||||
|
|
||||||
|
|
||||||
|
# Python imports
|
||||||
|
import argparse
|
||||||
|
from setproctitle import setproctitle
|
||||||
|
|
||||||
# Gtk imports
|
# Gtk imports
|
||||||
import gi, faulthandler, signal
|
import gi, faulthandler, signal
|
||||||
gi.require_version('Gtk', '3.0')
|
gi.require_version('Gtk', '3.0')
|
||||||
|
|
||||||
from gi.repository import Gtk as gtk
|
from gi.repository import Gtk as gtk
|
||||||
from gi.repository import Gdk as gdk
|
|
||||||
from gi.repository import GLib
|
from gi.repository import GLib
|
||||||
|
|
||||||
# Python imports
|
|
||||||
import inspect
|
|
||||||
|
|
||||||
from setproctitle import setproctitle
|
|
||||||
|
|
||||||
# Application imports
|
# Application imports
|
||||||
from utils import Settings, CrossClassSignals
|
from __init__ import Main
|
||||||
from signal_classes import MainWindow, DrawingArea, MainMenuPopup
|
|
||||||
|
|
||||||
|
|
||||||
class Main:
|
|
||||||
def __init__(self):
|
|
||||||
setproctitle('Cornea')
|
|
||||||
GLib.unix_signal_add(GLib.PRIORITY_DEFAULT, signal.SIGINT, gtk.main_quit)
|
|
||||||
faulthandler.enable() # For better debug info
|
|
||||||
|
|
||||||
settings = Settings()
|
|
||||||
builder = settings.returnBuilder()
|
|
||||||
|
|
||||||
# Gets the methods from the classes and sets to handler.
|
|
||||||
# Then, builder connects to any signals it needs.
|
|
||||||
utilsClass = CrossClassSignals(settings)
|
|
||||||
classes = [MainWindow(settings, utilsClass),
|
|
||||||
DrawingArea(settings, utilsClass),
|
|
||||||
MainMenuPopup(settings, utilsClass)]
|
|
||||||
|
|
||||||
handlers = {}
|
|
||||||
for c in classes:
|
|
||||||
methods = inspect.getmembers(c, predicate=inspect.ismethod)
|
|
||||||
handlers.update(methods)
|
|
||||||
|
|
||||||
builder.connect_signals(handlers)
|
|
||||||
window = settings.createWindow()
|
|
||||||
window.show()
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
try:
|
try:
|
||||||
main = Main()
|
setproctitle('Cornea')
|
||||||
|
GLib.unix_signal_add(GLib.PRIORITY_DEFAULT, signal.SIGINT, gtk.main_quit)
|
||||||
|
faulthandler.enable() # For better debug info
|
||||||
|
parser = argparse.ArgumentParser()
|
||||||
|
# Add long and short arguments
|
||||||
|
parser.add_argument("--file", "-f", default="firefox", help="JUST SOME FILE ARG.")
|
||||||
|
|
||||||
|
# Read arguments (If any...)
|
||||||
|
args = parser.parse_args()
|
||||||
|
main = Main(args)
|
||||||
gtk.main()
|
gtk.main()
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print( repr(e) )
|
print( repr(e) )
|
||||||
|
|
|
@ -7,8 +7,7 @@
|
||||||
|
|
||||||
function main() {
|
function main() {
|
||||||
SCRIPTPATH="$( cd "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )"
|
SCRIPTPATH="$( cd "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )"
|
||||||
cd "${SCRIPTPATH}"
|
# source "/home/abaddon/Portable_Apps/py-venvs/flask-apps-venv/venv/bin/activate"
|
||||||
source "../venv/bin/activate"
|
python "${SCRIPTPATH}"
|
||||||
python .
|
|
||||||
}
|
}
|
||||||
main $@;
|
main $@;
|
||||||
|
|
Loading…
Reference in New Issue