Commit 7b795852 authored by payno's avatar payno

[app] add canvas application

launch the orange-canvas from it with the default icon and software version.
/close #23
parent 7e28038f
......@@ -61,6 +61,9 @@ def main():
else:
_version = est._version.version
launcher = Launcher(prog="est", version=_version)
launcher.add_command("canvas",
module_name="est.app.canvas",
description="open the orange-canvas")
launcher.add_command("process",
module_name="est.app.process",
description="process a workflow from a .xml.ows file"
......
import sys
from .canvas_launcher import Launcher
def main(argv):
Launcher().launch(argv)
if __name__ == "__main__":
sys.exit(main(sys.argv))
from .launcher import Launcher
\ No newline at end of file
from silx.gui import qt
from Orange.canvas import config, __main__ as main
from .splash import splash_screen, getIcon
import os, sys
from Orange.misc import environ
import pkg_resources
def version():
return pkg_resources.get_distribution("est").version
class EstConfig(config.Config):
ApplicationName = "est"
ApplicationVersion = version()
@staticmethod
def splash_screen():
return splash_screen()
@staticmethod
def core_packages():
return super(EstConfig, EstConfig).core_packages() + [
"est-add-on",
]
@staticmethod
def application_icon():
return getIcon()
class EstSplashScreen(qt.QSplashScreen):
"""SplashScreen to overwrite the one of Orange"""
def __init__(self, parent=None, pixmap=None, textRect=None,
textFormat=qt.Qt.PlainText, **kwargs):
qt.QSplashScreen.__init__(self, parent, pixmap=pixmap, **kwargs)
def showMessage(self, message, alignment=qt.Qt.AlignLeft, color=qt.Qt.black):
super().showMessage(version(), qt.Qt.AlignCenter | qt.Qt.AlignBottom, qt.QColor("#e68f17"))
class Launcher:
"""Proxy to orange-canvas"""
def launch(self, argv):
config.Config = EstConfig
self.fix_application_dirs()
self.replace_splash_screen()
self.main(argv)
def fix_application_dirs(self):
def data_dir(versioned=True):
"""
Return the platform dependent Orange data directory.
This is ``data_dir_base()``/Orange/__VERSION__/ directory if versioned is
`True` and ``data_dir_base()``/Orange/ otherwise.
"""
base = environ.data_dir_base()
if versioned:
return os.path.join(base, "est", version())
else:
return os.path.join(base, "est")
environ.data_dir = data_dir
def cache_dir(*args):
"""
Return the platform dependent Orange cache directory.
"""
if sys.platform == "darwin":
base = os.path.expanduser("~/Library/Caches")
elif sys.platform == "win32":
base = os.getenv("APPDATA", os.path.expanduser("~/AppData/Local"))
elif os.name == "posix":
base = os.getenv("XDG_CACHE_HOME", os.path.expanduser("~/.cache"))
else:
base = os.path.expanduser("~/.cache")
base = os.path.join(base, "est", version())
if sys.platform == "win32":
# On Windows cache and data dir are the same.
# Microsoft suggest using a Cache subdirectory
return os.path.join(base, "Cache")
else:
return base
environ.cache_dir = cache_dir
def replace_splash_screen(self):
main.SplashScreen = EstSplashScreen
def main(self, argv):
from Orange.canvas.__main__ import main
main(argv)
from silx.gui import qt
from est.gui import icons
def splash_screen():
"""
:return: splash screen for orange-canvas
:rtype: tuple(QPixmap, QRect),
note: QRect is used by orange to define a mask to display the message.
In our case we overwrite the QSplashScreen so we don't need this.
"""
pixmap = icons.getQPixmap('est')
return pixmap, qt.QRect(0, 0, 0, 0)
def getIcon():
"""
:return: application icon
:rtype: QIcon
"""
pixmap = icons.getQPixmap('est')
return qt.QIcon(pixmap)
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
width="200"
height="200"
viewBox="0 0 52.916667 52.916667"
version="1.1"
id="svg8"
inkscape:version="0.92.4 (5da689c313, 2019-01-14)"
sodipodi:docname="est.svg">
<defs
id="defs2" />
<sodipodi:namedview
id="base"
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1.0"
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
inkscape:zoom="0.98994949"
inkscape:cx="-36.202787"
inkscape:cy="4.6936731"
inkscape:document-units="mm"
inkscape:current-layer="layer1"
showgrid="false"
units="px"
inkscape:window-width="1920"
inkscape:window-height="1136"
inkscape:window-x="0"
inkscape:window-y="27"
inkscape:window-maximized="1" />
<metadata
id="metadata5">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title></dc:title>
</cc:Work>
</rdf:RDF>
</metadata>
<g
inkscape:label="Calque 1"
inkscape:groupmode="layer"
id="layer1"
transform="translate(0,-244.08333)">
<ellipse
id="path3715"
cx="26.960814"
cy="270.67398"
rx="23.797617"
ry="23.296488"
style="fill:none;stroke:#000000;stroke-width:2.90511227;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
<path
style="fill:#ff0000;fill-opacity:1;stroke:#000000;stroke-width:0.41501606;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
d="m 26.398625,268.75897 15.319728,2.73563 -15.17918,2.7356 z"
id="path4524"
inkscape:connector-curvature="0" />
<path
style="fill:none;fill-opacity:1;stroke:#000000;stroke-width:0.41501606;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
d="m 26.539173,274.2302 -15.297492,-2.85101 15.200501,-2.62108 z"
id="path4524-3"
inkscape:connector-curvature="0" />
<ellipse
style="fill:#7a7a7a;fill-opacity:1;stroke:none;stroke-width:2.64695072;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
id="path4522"
cx="26.481686"
cy="271.44614"
rx="2.7775881"
ry="2.5338755" />
</g>
</svg>
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment