Integrals, opening directly from the command line

This commit is contained in:
Adsooi 2021-01-10 20:48:11 +01:00
parent 2fa6d71a27
commit 6d1c3d5450
4 changed files with 39 additions and 8 deletions

14
run.py
View file

@ -25,7 +25,11 @@ import os
import tempfile
from platform import release as os_release
from json import dumps
from sys import platform
from sys import platform, argv
pwd = os.getcwd()
os.chdir(os.path.dirname(os.path.realpath(__file__)))
tempfile = tempfile.mkstemp(suffix = '.png')[1]
@ -77,7 +81,7 @@ class Helper(QObject):
# TODO: Better copy system
os.system("xclip -selection clipboard -t image/png -i " + tempfile)
app = QApplication([])
app = QApplication(argv)
app.setApplicationName("Logarithmic Plotter")
app.setOrganizationName("Ad5001")
app.setWindowIcon(QIcon(os.path.realpath(os.path.join(os.getcwd(), "logplotter.svg"))))
@ -88,6 +92,12 @@ engine.rootContext().setContextProperty("Helper", helper)
engine.addImportPath(os.path.realpath(os.path.join(os.getcwd(), "qml")))
engine.load(os.path.realpath(os.path.join(os.getcwd(), "qml", "LogGraph.qml")))
os.chdir(pwd)
if len(argv) > 0 and os.path.exists(argv[-1]) and argv[-1].split('.')[-1] == 'json':
print(argv[-1])
engine.rootObjects()[0].loadDiagram(argv[-1])
os.chdir(os.path.dirname(os.path.realpath(__file__)))
if not engine.rootObjects():
print("No root object")
exit(-1)