Example #1
0
def main():
    if settings.get('log:errors'):
        log_filename = settings.get('log:filename')
        if log_filename:
            try:
                log_file = open(log_filename, "w")
                print('Redirecting stderr/stdout... to %s' % log_filename)
                sys.stderr = log_file
                sys.stdout = log_file
            except IOError:
                print("Lector could not open log file '%s'!\n" % log_filename \
                      + " Redirecting will not work.")
        else:
            print("Log file is not set. Please set it in settings.")

    app = QApplication(sys.argv)
    opts = [str(arg) for arg in app.arguments()[1:]]
    if '--no-scanner' in opts:
        scanner = False
    else:
        scanner = True
    qsrand(QTime(0, 0, 0).secsTo(QTime.currentTime()))

    locale = settings.get('ui:lang')
    if not locale:
        locale = QLocale.system().name()
    qtTranslator = QTranslator()
    if qtTranslator.load(":/translations/ts/lector_" + locale, 'ts'):
        app.installTranslator(qtTranslator)

    window = Window(scanner)
    window.show()
    app.exec_()
Example #2
0
def main():
    app = QApplication(sys.argv)
    args = app.arguments()
    parser = argparse.ArgumentParser(
        description='Zernike DM control',
        formatter_class=argparse.ArgumentDefaultsHelpFormatter)
    add_log_parameters(parser)
    add_arguments(parser)
    parser.add_argument('--params',
                        type=argparse.FileType('rb'),
                        default=None,
                        metavar='JSON')
    parser.add_argument('--no-params', action='store_true')
    args = parser.parse_args(args[1:])
    setup_logging(args)

    dminfo, pars = load_parameters(app, args)
    calib_dm_name = dminfo[0]
    calib_dm_transform = dminfo[1]

    if args.dm_name is None:
        args.dm_name = calib_dm_name
    dm = open_dm(app, args, calib_dm_transform)

    try:
        with File(pars['calibration'], 'r') as f:
            calib = RegLSCalib.load_h5py(f, lazy_cart_grid=True)
    except Exception as e:
        quit(f'error loading calibration {pars["calibration"]}: {str(e)}')

    zwindow = DMWindow(app, dm, calib, pars)
    zwindow.show()

    sys.exit(app.exec_())
Example #3
0
def main():
    if settings.get('log:errors'):
        log_filename = settings.get('log:filename')
        if log_filename:
            try:
                log_file = open(log_filename,"w")
                print ('Redirecting stderr/stdout... to %s' % log_filename)
                sys.stderr = log_file
                sys.stdout = log_file
            except IOError:
                print("Lector could not open log file '%s'!\n" % log_filename \
                      + " Redirecting will not work.")
        else:
            print("Log file is not set. Please set it in settings.")

    app = QApplication(sys.argv)
    opts = [str(arg) for arg in app.arguments()[1:]]
    if '--no-scanner' in opts:
        scanner = False
    else:
        scanner = True
    qsrand(QTime(0, 0, 0).secsTo(QTime.currentTime()))

    locale = settings.get('ui:lang')
    if not locale:
        locale = QLocale.system().name()
    qtTranslator = QTranslator()
    if qtTranslator.load(":/translations/ts/lector_" + locale, 'ts'):
        app.installTranslator(qtTranslator)

    window = Window(scanner)
    window.show()
    app.exec_()
Example #4
0
def parse_commandline():
    """Parses the command line; returns options and filenames.

    If --version, --help or invalid options were given, the application will
    exit.

    """
    import argparse
    argparse._ = _ # let argparse use our translations
    parser = argparse.ArgumentParser(conflict_handler="resolve",
        description = _("A LilyPond Music Editor"))
    parser.add_argument('-v', '--version', action="version",
        version="{0} {1}".format(appinfo.appname, appinfo.version),
        help=_("show program's version number and exit"))
    parser.add_argument('-V', '--version-debug', action="store_true", default=False,
        help=_("show version numbers of {appname} and its supporting modules "
               "and exit").format(appname=appinfo.appname))
    parser.add_argument('-e', '--encoding', metavar=_("ENC"),
        help=_("Encoding to use"))
    parser.add_argument('-l', '--line', type=int, metavar=_("NUM"),
        help=_("Line number to go to, starting at 1"))
    parser.add_argument('-c', '--column', type=int, metavar=_("NUM"),
        help=_("Column to go to, starting at 0"), default=0)
    parser.add_argument('--start', metavar=_("NAME"),
        help=_("Session to start ('{none}' for empty session)").format(none="-"),
        dest="session")
    parser.add_argument('--list-sessions', action="store_true", default=False,
        help=_("List the session names and exit"))
    parser.add_argument('-n', '--new', action="store_true", default=False,
        help=_("Always start a new instance"))
    parser.add_argument('--python-ly', type=str, metavar=_("STR"), default="",
        help=_("Path to python-ly"))
    parser.add_argument('files', metavar=_("file"), nargs='*',
        help=_("File to be opened"))

    # Make sure debugger options are recognized as valid. These are passed automatically
    # from PyDev in Eclipse to the inferior process.
    if "pydevd" in sys.modules:
        parser.add_argument('--vm_type', '-v')
        parser.add_argument('-a', '--client')
        parser.add_argument('-p', '--port')
        parser.add_argument('-f', '--file')
        parser.add_argument('-o', '--output')



    args = QApplication.arguments()

    # Decode arguments to properly handle Unicode on Windows
    if os.name == 'nt':
        args = [os.fsdecode(bytes(arg, 'mbcs')) for arg in args]

    # Strip interpreter name and its command line options on Windows
    if os.name == 'nt':
        while args:
            if os.path.basename(args[0]).lower().startswith(appinfo.name):
                break
            args.pop(0)

    return parser.parse_args(args[1:])
Example #5
0
def main():
    app = QApplication(sys.argv)
    mw = MainWindow()
    if "--debug" in app.arguments():
        print("Debug active...")
        mw.enableDebugMode()
    return app.exec_()
Example #6
0
def getCommandLineUrlArgument() -> str:
    args = QApplication.arguments()
    if len(args) > 1:
        lastArg = args[-1]
        isValidUrl = QUrl.fromUserInput(lastArg).isValid()
        if isValidUrl:
            return lastArg
    return ''
Example #7
0
def main():
	if sys.excepthook is sys.__excepthook__:
		sys.excepthook = lambda *args: sys.__excepthook__(*args)

	app = QApplication(sys.argv)
	opts = parse_options(list(app.arguments()))
	win = Win(opts)
	win.show()
	app.exec_()
Example #8
0
def parse_commandline():
    """Parses the command line; returns options and filenames.

    If --version, --help or invalid options were given, the application will
    exit.

    """
    import argparse
    argparse._ = _ # let argparse use our translations
    parser = argparse.ArgumentParser(conflict_handler="resolve",
        description = _("A LilyPond Music Editor"))
    parser.add_argument('-v', '--version', action="version",
        version="{0} {1}".format(appinfo.appname, appinfo.version),
        help=_("show program's version number and exit"))
    parser.add_argument('-V', '--version-debug', action="store_true", default=False,
        help=_("show version numbers of {appname} and its supporting modules "
               "and exit").format(appname=appinfo.appname))
    parser.add_argument('-e', '--encoding', metavar=_("ENC"),
        help=_("Encoding to use"))
    parser.add_argument('-l', '--line', type=int, metavar=_("NUM"),
        help=_("Line number to go to, starting at 1"))
    parser.add_argument('-c', '--column', type=int, metavar=_("NUM"),
        help=_("Column to go to, starting at 0"), default=0)
    parser.add_argument('--start', metavar=_("NAME"),
        help=_("Session to start ('{none}' for empty session)").format(none="-"),
        dest="session")
    parser.add_argument('--list-sessions', action="store_true", default=False,
        help=_("List the session names and exit"))
    parser.add_argument('-n', '--new', action="store_true", default=False,
        help=_("Always start a new instance"))
    parser.add_argument('--python-ly', type=str, metavar=_("STR"), default="",
        help=_("Path to python-ly"))
    parser.add_argument('files', metavar=_("file"), nargs='*',
        help=_("File to be opened"))

    # Make sure debugger options are recognized as valid. These are passed automatically
    # from PyDev in Eclipse to the inferior process.
    if "pydevd" in sys.modules:
        parser.add_argument('--vm_type', '-v')
        parser.add_argument('-a', '--client')
        parser.add_argument('-p', '--port')
        parser.add_argument('-f', '--file')
        parser.add_argument('-o', '--output')



    args = QApplication.arguments()

    # Strip interpreter name and its command line options on Windows
    if os.name == 'nt':
        while args:
            if os.path.basename(args[0]).lower().startswith(appinfo.name):
                break
            args.pop(0)

    return parser.parse_args(args[1:])
Example #9
0
 def restart(self):
     program = QApplication.applicationFilePath()
     # print(program)
     arguments = QApplication.arguments()
     # print(arguments)
     workingDirectory = QDir.currentPath()
     # print(workingDirectory)
     QProcess.startDetached(program, arguments, workingDirectory)
     # QProcess.startDetached(program)
     self.close()
Example #10
0
def main():
    '''
    Main app is run here
    :return:None
    '''
    app = QApplication(sys.argv)
    argv2 = app.arguments()
    ex = MyMainWindow(argv2)
    ex.show()
    sys.exit(app.exec_())
Example #11
0
def main():
    if sys.excepthook is sys.__excepthook__:
        sys.excepthook = lambda *args: sys.__excepthook__(*args)

    app = QApplication(sys.argv)
    win = Window()
    win.show()

    for file in app.arguments()[1:]:
        win.loadFile(file)

    app.exec()
Example #12
0
def main():
    """Start the Qt application and GUI."""
    import sys
    app = QApplication(sys.argv)
    # Spawn a window per file
    wins = []
    for arg in QApplication.arguments()[1:]:
        wins.append(FileSoupWindow(arg))
    ret = 0
    if len(wins):
        ret = app.exec_()
    sys.exit(ret)
Example #13
0
def main():
	if sys.excepthook is sys.__excepthook__:
		sys.excepthook = lambda *args: sys.__excepthook__(*args)

	app = QApplication(sys.argv)
	app.setApplicationDisplayName('SIT-Tagger')
	app.setApplicationName('SIT-Tagger')

	opts = parse_options(list(app.arguments())[1:])
	win = Win(opts)
	win.show()
	app.exec_()
Example #14
0
def main():
    app = QApplication(sys.argv)
    app.setApplicationDisplayName("EvoBridge")

    args = app.arguments()

    window = MainWindow(args[1] if len(args) == 2 else None)
    app.installEventFilter(window)
    window.resize(800, 600)
    window.show()

    sys.exit(app.exec_())
Example #15
0
def main(argv):
    app = QApplication(argv)
    app.setApplicationName('BeamDelta')
    app.setOrganizationName('Micron Oxford')
    app.setOrganizationDomain('micron.ox.ac.uk')

    args = parse_arguments(app.arguments())

    cams = [Imager(uri, args.exposure_time) for uri in args.cam_uris]

    window = MainWindow(imagers=cams)
    window.show()
    return app.exec()
def main(argv=None):
    app = QApplication(argv or [])

    argv = app.arguments()
    if len(argv) > 1:
        fname = argv[1]
        df = pd.read_csv(fname)
    else:
        df = pd.DataFrame({"A": [1, 2, 3], "B": ["a", "b", "c"]})
    x = np.array([(1.0, 2), (3.0, 4)], dtype=[('x', float), ('y', np.dtype("i8", metadata={"a": 1}))])
    w = OWDataFrameDisplay()
    w.set_data_frame(df)
    w.show()
    w.raise_()
    return app.exec()
Example #17
0
def main():

    import sys
    from PyQt5.QtWidgets import QApplication

    app = QApplication(sys.argv, applicationName=NAME)
    win = MainWindow()

    parser = argparse.ArgumentParser(description=NAME)
    parser.add_argument('filename', nargs='?', default=None)

    args = parser.parse_args(app.arguments()[1:])
    print(args)
    if args.filename:
        win.components['editor'].load_from_file(args.filename)

    win.show()
    sys.exit(app.exec_())
Example #18
0
def main():
    app = QApplication(sys.argv)
    app.setQuitOnLastWindowClosed(False)
    app.setApplicationVersion("1.0 Beta")
    locale = QLocale.system().name()
    translator = QTranslator(app)
    translator.load("/usr/share/lilii/languages/{}.qm".format(locale))
    app.installTranslator(translator)

    single = SingleApplication()
    if single.hasPrevious("lilii", app.arguments()):
        return False

    single.listen("lilii")

    window = MainWindow()
    window.show()
    sys.exit(app.exec_())
Example #19
0
def main():
    # if this is not a windows platform, initialize QApp here.
    # This also silences the warning from qt about initializing
    # pyqtgraph after QApplication
    if sys.platform != "win32":
        app = QApplication(sys.argv, applicationName=NAME)

    win = MainWindow()

    parser = argparse.ArgumentParser(description=NAME)
    parser.add_argument('filename',nargs='?',default=None)

    args = parser.parse_args(app.arguments()[1:])
    print(args)
    if args.filename:
        win.components['editor'].load_from_file(args.filename)

    win.show()
    sys.exit(app.exec_())
def main(splash=True):
    import os
    import pkg_resources
    import sys

    from PyQt5.QtWidgets import QApplication
    from PyQt5.QtCore import QEventLoop
    # import before creating application
    import pyqtgraph  # noqa: F401

    app = QApplication(sys.argv)
    imdir = pkg_resources.resource_filename("shapeout2", "img")

    if splash:
        from PyQt5.QtWidgets import QSplashScreen
        from PyQt5.QtGui import QPixmap
        splash_path = os.path.join(imdir, "splash.png")
        splash_pix = QPixmap(splash_path)
        splash = QSplashScreen(splash_pix)
        splash.setMask(splash_pix.mask())
        splash.show()
        # make sure Qt really displays the splash screen
        app.processEvents(QEventLoop.AllEvents, 300)

    from PyQt5 import QtCore, QtGui
    from .gui import ShapeOut2

    # Set Application Icon
    icon_path = os.path.join(imdir, "icon.png")
    app.setWindowIcon(QtGui.QIcon(icon_path))

    # Use dots as decimal separators
    QtCore.QLocale.setDefault(QtCore.QLocale(QtCore.QLocale.C))

    window = ShapeOut2(*app.arguments()[1:])

    if splash:
        splash.finish(window)

    sys.exit(app.exec_())
Example #21
0
def start():
	app = QApplication(sys.argv)
	app.setOrganizationName(globals.ORGANIZATION_NAME)
	app.setOrganizationDomain(globals.ORGANIZATION_DOMAIN)
	app.setApplicationName(globals.APPLICATION_NAME)

	if isMacintoshComputer():
		# add /opt/local/bin to PATH to find pdflatex binary -- useful for Mac plateform using Macports
		os.environ['PATH'] = os.environ.get('PATH', '/usr/bin') + ':/opt/local/bin'
		app.setQuitOnLastWindowClosed(False)

	app_controller = ControllerFactory.createAppController()

	args = app.arguments()[1:]
	if len(args) > 0:
		for file_path in args:
			app_controller.open(file_path)
	else:
		app_controller.new()

	app.exec_()
	app_controller.quit()
Example #22
0
def start():
    app = QApplication(sys.argv)
    app.setOrganizationName(globals.ORGANIZATION_NAME)
    app.setOrganizationDomain(globals.ORGANIZATION_DOMAIN)
    app.setApplicationName(globals.APPLICATION_NAME)

    if isMacintoshComputer():
        # add /opt/local/bin to PATH to find pdflatex binary -- useful for Mac plateform using Macports
        os.environ['PATH'] = os.environ.get('PATH',
                                            '/usr/bin') + ':/opt/local/bin'
        app.setQuitOnLastWindowClosed(False)

    app_controller = ControllerFactory.createAppController()

    args = app.arguments()[1:]
    if len(args) > 0:
        for file_path in args:
            app_controller.open(file_path)
    else:
        app_controller.new()

    app.exec_()
    app_controller.quit()
Example #23
0
import sys
import theme

from PyQt5.QtWidgets import QApplication
from PyQt5.uic import loadUi

if __name__ == "__main__":

    app = QApplication(sys.argv)
    
    if len(app.arguments()) != 2:
    
        sys.stderr.write("Usage: %s <ui file>\n" % app.arguments()[0])
        sys.exit()

    app.setStyleSheet(theme.load_stylesheet_pyqt5())
    
    window = loadUi(app.arguments()[1])
    window.show()
    sys.exit(app.exec_())
Example #24
0
        if not f:
            return
        v = Video()
        v.load(f)
        self.centralWidget().addWidgetInGrid(v)

    def openUrl(self):
        u, _ = QInputDialog.getText(self, 'Open')
        if not u:
            return
        v = Video()
        v.loadUrl(u)
        self.centralWidget().addWidgetInGrid(v)


if __name__ == '__main__':
    app = QApplication(sys.argv)
    w = Win()
    w.show()

    for f in app.arguments()[1:]:
        v = Video()
        if f.startswith('/'):
            v.load(f)
        else:
            v.loadUrl(f)
        v.play()
        w.centralWidget().addWidgetInGrid(v)

    app.exec_()
Example #25
0
        top = QFrame()
        lay = QGridLayout()
        top.setLayout(lay)
        lay.addWidget(fig0, 0, 0)
        if self.dmplot1:
            lay.addWidget(fig1, 0, 1)
        lay.addWidget(breset, 1, 0)
        main.addWidget(top)
        main.addWidget(scroll)
        self.setCentralWidget(main)


if __name__ == '__main__':
    app = QApplication(sys.argv)

    args = app.arguments()
    parser = argparse.ArgumentParser(
        description='', formatter_class=argparse.ArgumentDefaultsHelpFormatter)
    parser.add_argument('--hardware',
                        action='store_true',
                        help='Actually drive the DM hardware')
    args = parser.parse_args(args[1:])

    fname = path.join(get_def_files(), 'config.json')
    with open(fname, 'r') as f:
        conf = json.load(f)

    C = np.array(conf['Matrix'])
    modes = conf['Modes']
    serials = conf['Serials']
Example #26
0
                    self.params.written += sent
                    self.params.progress_signal.emit(self.params.devstring)

                # while True:
                # 	chunk = self.params.open_iso.read(65536)
                # 	if not chunk:
                # 		# end of file
                # 		break
                # 	sent = self.params.open_dev.write(chunk)
                # 	if sent < len(chunk):
                # 		raise IOError(f"Wrote {sent} bytes out of {len(chunk)} read")
                # 	self.params.written += sent
                # 	self.params.progress_signal.emit(self.params.devstring)

                # self.end_time.currentDateTime()
        except FileNotFoundError as e:
            self.params.finished_signal.emit(self.params.devstring, 1,
                                             e.strerror)
            return
        except Exception as e:
            self.params.finished_signal.emit(self.params.devstring, 2,
                                             e.__class__.__name__)
            return
        self.params.finished_signal.emit(self.params.devstring, 0, "")


if __name__ == '__main__':
    app = QApplication(sys.argv)
    ex = Toaster(app.arguments())
    sys.exit(app.exec_())
Example #27
0
    QCoreApplication.setAttribute(QtCore.Qt.AA_X11InitThreads, True)

from PyQt5.QtWidgets import QApplication
app = QApplication(sys.argv)
app.setOrganizationName("Deepin")
app.setApplicationName("Deepin Screenshot")
app.setApplicationVersion("3.1.0")
app.setQuitOnLastWindowClosed(False)

from app_controller import AppController
from dbus_services import is_service_exist, register_object
from dbus_interfaces import screenshotInterface

if __name__ == "__main__":
    if is_service_exist():
        screenshotInterface.runWithArguments(app.arguments())
        # TODO: maybe there will never be a situation that
        # the following should be executed.
        # notificationsInterface.notify(_("Deepin Screenshot"),
        #     _("Deepin Screenshot has been started!"))
    else:
        controller = AppController()

        returncode = controller.runWithArguments(app.arguments())
        if returncode == 0:
            register_object(controller)
            signal.signal(signal.SIGINT, signal.SIG_DFL)
            sys.exit(app.exec_())
        else:
            sys.exit(1)
Example #28
0
# DEALINGS IN THE SOFTWARE.

import sys

from PyQt5.QtCore import QSettings, QThread, Qt
from PyQt5.QtGui import QFont
from PyQt5.QtWidgets import QApplication, QTextBrowser

from QtBridge.objectmanager import ObjectManager
from QtBridge.processhandler import ProcessHandler

if __name__ == "__main__":

    app = QApplication(sys.argv)

    args = app.arguments()
    if "--debug" in args:
        debug = True
        args.remove("--debug")
    else:
        debug = False

    if len(args) != 2:
        sys.stderr.write("Usage: %s <executable>\n" % sys.argv[0])
        sys.exit(1)

    executable = app.arguments()[1]

    objectManager = ObjectManager(debug=debug)

    processThread = QThread()
Example #29
0
class CarlaApplication(object):
    def __init__(self, appName = "Carla2", libPrefix = None):
        object.__init__(self)

        # try to find styles dir
        stylesDir = ""

        CWDl = CWD.lower()

        # standalone, installed system-wide linux
        if libPrefix is not None:
            stylesDir = os.path.join(libPrefix, "lib", "carla")

        # standalone, local source
        elif CWDl.endswith("source"):
            stylesDir = os.path.abspath(os.path.join(CWD, "..", "bin"))

            if WINDOWS:
                # Fixes local wine build
                QApplication.addLibraryPath("C:\\Python34\\Lib\\site-packages\\PyQt5\\plugins")

        # plugin
        elif CWDl.endswith("resources"):
            # installed system-wide linux
            if CWDl.endswith("/share/carla/resources"):
                stylesDir = os.path.abspath(os.path.join(CWD, "..", "..", "..", "lib", "carla"))

            # local source
            elif CWDl.endswith("native-plugins%sresources" % os.sep):
                stylesDir = os.path.abspath(os.path.join(CWD, "..", "..", "..", "..", "bin"))

            # other
            else:
                stylesDir = os.path.abspath(os.path.join(CWD, ".."))

        # everything else
        else:
            stylesDir = CWD

        if os.path.exists(stylesDir):
            QApplication.addLibraryPath(stylesDir)

            if WINDOWS:
                stylesDir = ""

        elif config_UseQt5:
            stylesDir = ""

        else:
            self._createApp(appName)
            return

        # base settings
        settings    = QSettings("falkTX", appName)
        useProTheme = settings.value(CARLA_KEY_MAIN_USE_PRO_THEME, CARLA_DEFAULT_MAIN_USE_PRO_THEME, type=bool)

        if not useProTheme:
            self._createApp(appName)
            return

        # set style
        QApplication.setStyle("carla" if stylesDir else "fusion")

        # create app
        self._createApp(appName)

        self.fApp.setStyle("carla" if stylesDir else "fusion")

        # set palette
        proThemeColor = settings.value(CARLA_KEY_MAIN_PRO_THEME_COLOR, CARLA_DEFAULT_MAIN_PRO_THEME_COLOR, type=str).lower()

        if proThemeColor == "black":
            self.fPalBlack = QPalette()
            self.fPalBlack.setColor(QPalette.Disabled, QPalette.Window, QColor(14, 14, 14))
            self.fPalBlack.setColor(QPalette.Active,   QPalette.Window, QColor(17, 17, 17))
            self.fPalBlack.setColor(QPalette.Inactive, QPalette.Window, QColor(17, 17, 17))
            self.fPalBlack.setColor(QPalette.Disabled, QPalette.WindowText, QColor(83, 83, 83))
            self.fPalBlack.setColor(QPalette.Active,   QPalette.WindowText, QColor(240, 240, 240))
            self.fPalBlack.setColor(QPalette.Inactive, QPalette.WindowText, QColor(240, 240, 240))
            self.fPalBlack.setColor(QPalette.Disabled, QPalette.Base, QColor(6, 6, 6))
            self.fPalBlack.setColor(QPalette.Active,   QPalette.Base, QColor(7, 7, 7))
            self.fPalBlack.setColor(QPalette.Inactive, QPalette.Base, QColor(7, 7, 7))
            self.fPalBlack.setColor(QPalette.Disabled, QPalette.AlternateBase, QColor(12, 12, 12))
            self.fPalBlack.setColor(QPalette.Active,   QPalette.AlternateBase, QColor(14, 14, 14))
            self.fPalBlack.setColor(QPalette.Inactive, QPalette.AlternateBase, QColor(14, 14, 14))
            self.fPalBlack.setColor(QPalette.Disabled, QPalette.ToolTipBase, QColor(4, 4, 4))
            self.fPalBlack.setColor(QPalette.Active,   QPalette.ToolTipBase, QColor(4, 4, 4))
            self.fPalBlack.setColor(QPalette.Inactive, QPalette.ToolTipBase, QColor(4, 4, 4))
            self.fPalBlack.setColor(QPalette.Disabled, QPalette.ToolTipText, QColor(230, 230, 230))
            self.fPalBlack.setColor(QPalette.Active,   QPalette.ToolTipText, QColor(230, 230, 230))
            self.fPalBlack.setColor(QPalette.Inactive, QPalette.ToolTipText, QColor(230, 230, 230))
            self.fPalBlack.setColor(QPalette.Disabled, QPalette.Text, QColor(74, 74, 74))
            self.fPalBlack.setColor(QPalette.Active,   QPalette.Text, QColor(230, 230, 230))
            self.fPalBlack.setColor(QPalette.Inactive, QPalette.Text, QColor(230, 230, 230))
            self.fPalBlack.setColor(QPalette.Disabled, QPalette.Button, QColor(24, 24, 24))
            self.fPalBlack.setColor(QPalette.Active,   QPalette.Button, QColor(28, 28, 28))
            self.fPalBlack.setColor(QPalette.Inactive, QPalette.Button, QColor(28, 28, 28))
            self.fPalBlack.setColor(QPalette.Disabled, QPalette.ButtonText, QColor(90, 90, 90))
            self.fPalBlack.setColor(QPalette.Active,   QPalette.ButtonText, QColor(240, 240, 240))
            self.fPalBlack.setColor(QPalette.Inactive, QPalette.ButtonText, QColor(240, 240, 240))
            self.fPalBlack.setColor(QPalette.Disabled, QPalette.BrightText, QColor(255, 255, 255))
            self.fPalBlack.setColor(QPalette.Active,   QPalette.BrightText, QColor(255, 255, 255))
            self.fPalBlack.setColor(QPalette.Inactive, QPalette.BrightText, QColor(255, 255, 255))
            self.fPalBlack.setColor(QPalette.Disabled, QPalette.Light, QColor(191, 191, 191))
            self.fPalBlack.setColor(QPalette.Active,   QPalette.Light, QColor(191, 191, 191))
            self.fPalBlack.setColor(QPalette.Inactive, QPalette.Light, QColor(191, 191, 191))
            self.fPalBlack.setColor(QPalette.Disabled, QPalette.Midlight, QColor(155, 155, 155))
            self.fPalBlack.setColor(QPalette.Active,   QPalette.Midlight, QColor(155, 155, 155))
            self.fPalBlack.setColor(QPalette.Inactive, QPalette.Midlight, QColor(155, 155, 155))
            self.fPalBlack.setColor(QPalette.Disabled, QPalette.Dark, QColor(129, 129, 129))
            self.fPalBlack.setColor(QPalette.Active,   QPalette.Dark, QColor(129, 129, 129))
            self.fPalBlack.setColor(QPalette.Inactive, QPalette.Dark, QColor(129, 129, 129))
            self.fPalBlack.setColor(QPalette.Disabled, QPalette.Mid, QColor(94, 94, 94))
            self.fPalBlack.setColor(QPalette.Active,   QPalette.Mid, QColor(94, 94, 94))
            self.fPalBlack.setColor(QPalette.Inactive, QPalette.Mid, QColor(94, 94, 94))
            self.fPalBlack.setColor(QPalette.Disabled, QPalette.Shadow, QColor(155, 155, 155))
            self.fPalBlack.setColor(QPalette.Active,   QPalette.Shadow, QColor(155, 155, 155))
            self.fPalBlack.setColor(QPalette.Inactive, QPalette.Shadow, QColor(155, 155, 155))
            self.fPalBlack.setColor(QPalette.Disabled, QPalette.Highlight, QColor(14, 14, 14))
            self.fPalBlack.setColor(QPalette.Active,   QPalette.Highlight, QColor(60, 60, 60))
            self.fPalBlack.setColor(QPalette.Inactive, QPalette.Highlight, QColor(34, 34, 34))
            self.fPalBlack.setColor(QPalette.Disabled, QPalette.HighlightedText, QColor(83, 83, 83))
            self.fPalBlack.setColor(QPalette.Active,   QPalette.HighlightedText, QColor(255, 255, 255))
            self.fPalBlack.setColor(QPalette.Inactive, QPalette.HighlightedText, QColor(240, 240, 240))
            self.fPalBlack.setColor(QPalette.Disabled, QPalette.Link, QColor(34, 34, 74))
            self.fPalBlack.setColor(QPalette.Active,   QPalette.Link, QColor(100, 100, 230))
            self.fPalBlack.setColor(QPalette.Inactive, QPalette.Link, QColor(100, 100, 230))
            self.fPalBlack.setColor(QPalette.Disabled, QPalette.LinkVisited, QColor(74, 34, 74))
            self.fPalBlack.setColor(QPalette.Active,   QPalette.LinkVisited, QColor(230, 100, 230))
            self.fPalBlack.setColor(QPalette.Inactive, QPalette.LinkVisited, QColor(230, 100, 230))
            self.fApp.setPalette(self.fPalBlack)

        elif proThemeColor == "blue":
            self.fPalBlue = QPalette()
            self.fPalBlue.setColor(QPalette.Disabled, QPalette.Window, QColor(32, 35, 39))
            self.fPalBlue.setColor(QPalette.Active,   QPalette.Window, QColor(37, 40, 45))
            self.fPalBlue.setColor(QPalette.Inactive, QPalette.Window, QColor(37, 40, 45))
            self.fPalBlue.setColor(QPalette.Disabled, QPalette.WindowText, QColor(89, 95, 104))
            self.fPalBlue.setColor(QPalette.Active,   QPalette.WindowText, QColor(223, 237, 255))
            self.fPalBlue.setColor(QPalette.Inactive, QPalette.WindowText, QColor(223, 237, 255))
            self.fPalBlue.setColor(QPalette.Disabled, QPalette.Base, QColor(48, 53, 60))
            self.fPalBlue.setColor(QPalette.Active,   QPalette.Base, QColor(55, 61, 69))
            self.fPalBlue.setColor(QPalette.Inactive, QPalette.Base, QColor(55, 61, 69))
            self.fPalBlue.setColor(QPalette.Disabled, QPalette.AlternateBase, QColor(60, 64, 67))
            self.fPalBlue.setColor(QPalette.Active,   QPalette.AlternateBase, QColor(69, 73, 77))
            self.fPalBlue.setColor(QPalette.Inactive, QPalette.AlternateBase, QColor(69, 73, 77))
            self.fPalBlue.setColor(QPalette.Disabled, QPalette.ToolTipBase, QColor(182, 193, 208))
            self.fPalBlue.setColor(QPalette.Active,   QPalette.ToolTipBase, QColor(182, 193, 208))
            self.fPalBlue.setColor(QPalette.Inactive, QPalette.ToolTipBase, QColor(182, 193, 208))
            self.fPalBlue.setColor(QPalette.Disabled, QPalette.ToolTipText, QColor(42, 44, 48))
            self.fPalBlue.setColor(QPalette.Active,   QPalette.ToolTipText, QColor(42, 44, 48))
            self.fPalBlue.setColor(QPalette.Inactive, QPalette.ToolTipText, QColor(42, 44, 48))
            self.fPalBlue.setColor(QPalette.Disabled, QPalette.Text, QColor(96, 103, 113))
            self.fPalBlue.setColor(QPalette.Active,   QPalette.Text, QColor(210, 222, 240))
            self.fPalBlue.setColor(QPalette.Inactive, QPalette.Text, QColor(210, 222, 240))
            self.fPalBlue.setColor(QPalette.Disabled, QPalette.Button, QColor(51, 55, 62))
            self.fPalBlue.setColor(QPalette.Active,   QPalette.Button, QColor(59, 63, 71))
            self.fPalBlue.setColor(QPalette.Inactive, QPalette.Button, QColor(59, 63, 71))
            self.fPalBlue.setColor(QPalette.Disabled, QPalette.ButtonText, QColor(98, 104, 114))
            self.fPalBlue.setColor(QPalette.Active,   QPalette.ButtonText, QColor(210, 222, 240))
            self.fPalBlue.setColor(QPalette.Inactive, QPalette.ButtonText, QColor(210, 222, 240))
            self.fPalBlue.setColor(QPalette.Disabled, QPalette.BrightText, QColor(255, 255, 255))
            self.fPalBlue.setColor(QPalette.Active,   QPalette.BrightText, QColor(255, 255, 255))
            self.fPalBlue.setColor(QPalette.Inactive, QPalette.BrightText, QColor(255, 255, 255))
            self.fPalBlue.setColor(QPalette.Disabled, QPalette.Light, QColor(59, 64, 72))
            self.fPalBlue.setColor(QPalette.Active,   QPalette.Light, QColor(63, 68, 76))
            self.fPalBlue.setColor(QPalette.Inactive, QPalette.Light, QColor(63, 68, 76))
            self.fPalBlue.setColor(QPalette.Disabled, QPalette.Midlight, QColor(48, 52, 59))
            self.fPalBlue.setColor(QPalette.Active,   QPalette.Midlight, QColor(51, 56, 63))
            self.fPalBlue.setColor(QPalette.Inactive, QPalette.Midlight, QColor(51, 56, 63))
            self.fPalBlue.setColor(QPalette.Disabled, QPalette.Dark, QColor(18, 19, 22))
            self.fPalBlue.setColor(QPalette.Active,   QPalette.Dark, QColor(20, 22, 25))
            self.fPalBlue.setColor(QPalette.Inactive, QPalette.Dark, QColor(20, 22, 25))
            self.fPalBlue.setColor(QPalette.Disabled, QPalette.Mid, QColor(28, 30, 34))
            self.fPalBlue.setColor(QPalette.Active,   QPalette.Mid, QColor(32, 35, 39))
            self.fPalBlue.setColor(QPalette.Inactive, QPalette.Mid, QColor(32, 35, 39))
            self.fPalBlue.setColor(QPalette.Disabled, QPalette.Shadow, QColor(13, 14, 16))
            self.fPalBlue.setColor(QPalette.Active,   QPalette.Shadow, QColor(15, 16, 18))
            self.fPalBlue.setColor(QPalette.Inactive, QPalette.Shadow, QColor(15, 16, 18))
            self.fPalBlue.setColor(QPalette.Disabled, QPalette.Highlight, QColor(32, 35, 39))
            self.fPalBlue.setColor(QPalette.Active,   QPalette.Highlight, QColor(14, 14, 17))
            self.fPalBlue.setColor(QPalette.Inactive, QPalette.Highlight, QColor(27, 28, 33))
            self.fPalBlue.setColor(QPalette.Disabled, QPalette.HighlightedText, QColor(89, 95, 104))
            self.fPalBlue.setColor(QPalette.Active,   QPalette.HighlightedText, QColor(217, 234, 253))
            self.fPalBlue.setColor(QPalette.Inactive, QPalette.HighlightedText, QColor(223, 237, 255))
            self.fPalBlue.setColor(QPalette.Disabled, QPalette.Link, QColor(79, 100, 118))
            self.fPalBlue.setColor(QPalette.Active,   QPalette.Link, QColor(156, 212, 255))
            self.fPalBlue.setColor(QPalette.Inactive, QPalette.Link, QColor(156, 212, 255))
            self.fPalBlue.setColor(QPalette.Disabled, QPalette.LinkVisited, QColor(51, 74, 118))
            self.fPalBlue.setColor(QPalette.Active,   QPalette.LinkVisited, QColor(64, 128, 255))
            self.fPalBlue.setColor(QPalette.Inactive, QPalette.LinkVisited, QColor(64, 128, 255))
            self.fApp.setPalette(self.fPalBlue)

        print("Using \"%s\" theme" % self.fApp.style().objectName())

    def _createApp(self, appName):
        self.fApp = QApplication(sys.argv)
        self.fApp.setApplicationName(appName)
        self.fApp.setApplicationVersion(VERSION)
        self.fApp.setOrganizationName("falkTX")

        if appName.lower() == "carla-control":
            self.fApp.setWindowIcon(QIcon(":/scalable/carla-control.svg"))
        else:
            self.fApp.setWindowIcon(QIcon(":/scalable/carla.svg"))

        if MACOS and config_UseQt5:
            self.fApp.setAttribute(Qt.AA_DontShowIconsInMenus)

    def arguments(self):
        return self.fApp.arguments()

    def exec_(self):
        return self.fApp.exec_()

    def exit_exec(self):
        return sys.exit(self.fApp.exec_())

    def getApp(self):
        return self.fApp

    def quit(self):
        self.fApp.quit()
Example #30
0
class CarlaApplication(object):
    def __init__(self, appName = "Carla2", libPrefix = None):
        object.__init__(self)

        pathBinaries, pathResources = getPaths(libPrefix)

        # Needed for MacOS LV2 plugin
        if MACOS and os.path.exists(CWD):
            QApplication.addLibraryPath(CWD)

        # Needed for local wine build
        if WINDOWS and (CWD.endswith("source") or os.getenv("CXFREEZE") is not None):
            QApplication.addLibraryPath("C:\\Python34\\Lib\\site-packages\\PyQt5\\plugins")

        # Use binary dir as library path (except in Windows)
        if os.path.exists(pathBinaries) and not WINDOWS:
            QApplication.addLibraryPath(pathBinaries)
            stylesDir = pathBinaries

        # If style is not available we can still fake it in Qt5
        elif config_UseQt5:
            stylesDir = ""

        else:
            self.createApp(appName)
            return

        # base settings
        settings    = QSettings("falkTX", appName)
        useProTheme = settings.value(CARLA_KEY_MAIN_USE_PRO_THEME, CARLA_DEFAULT_MAIN_USE_PRO_THEME, type=bool)

        if not useProTheme:
            self.createApp(appName)
            return

        # set style
        QApplication.setStyle("carla" if stylesDir else "fusion")

        # create app
        self.createApp(appName)

        self.fApp.setStyle("carla" if stylesDir else "fusion")

        # set palette
        proThemeColor = settings.value(CARLA_KEY_MAIN_PRO_THEME_COLOR, CARLA_DEFAULT_MAIN_PRO_THEME_COLOR, type=str).lower()

        if proThemeColor == "black":
            self.fPalBlack = QPalette()
            self.fPalBlack.setColor(QPalette.Disabled, QPalette.Window, QColor(14, 14, 14))
            self.fPalBlack.setColor(QPalette.Active,   QPalette.Window, QColor(17, 17, 17))
            self.fPalBlack.setColor(QPalette.Inactive, QPalette.Window, QColor(17, 17, 17))
            self.fPalBlack.setColor(QPalette.Disabled, QPalette.WindowText, QColor(83, 83, 83))
            self.fPalBlack.setColor(QPalette.Active,   QPalette.WindowText, QColor(240, 240, 240))
            self.fPalBlack.setColor(QPalette.Inactive, QPalette.WindowText, QColor(240, 240, 240))
            self.fPalBlack.setColor(QPalette.Disabled, QPalette.Base, QColor(6, 6, 6))
            self.fPalBlack.setColor(QPalette.Active,   QPalette.Base, QColor(7, 7, 7))
            self.fPalBlack.setColor(QPalette.Inactive, QPalette.Base, QColor(7, 7, 7))
            self.fPalBlack.setColor(QPalette.Disabled, QPalette.AlternateBase, QColor(12, 12, 12))
            self.fPalBlack.setColor(QPalette.Active,   QPalette.AlternateBase, QColor(14, 14, 14))
            self.fPalBlack.setColor(QPalette.Inactive, QPalette.AlternateBase, QColor(14, 14, 14))
            self.fPalBlack.setColor(QPalette.Disabled, QPalette.ToolTipBase, QColor(4, 4, 4))
            self.fPalBlack.setColor(QPalette.Active,   QPalette.ToolTipBase, QColor(4, 4, 4))
            self.fPalBlack.setColor(QPalette.Inactive, QPalette.ToolTipBase, QColor(4, 4, 4))
            self.fPalBlack.setColor(QPalette.Disabled, QPalette.ToolTipText, QColor(230, 230, 230))
            self.fPalBlack.setColor(QPalette.Active,   QPalette.ToolTipText, QColor(230, 230, 230))
            self.fPalBlack.setColor(QPalette.Inactive, QPalette.ToolTipText, QColor(230, 230, 230))
            self.fPalBlack.setColor(QPalette.Disabled, QPalette.Text, QColor(74, 74, 74))
            self.fPalBlack.setColor(QPalette.Active,   QPalette.Text, QColor(230, 230, 230))
            self.fPalBlack.setColor(QPalette.Inactive, QPalette.Text, QColor(230, 230, 230))
            self.fPalBlack.setColor(QPalette.Disabled, QPalette.Button, QColor(24, 24, 24))
            self.fPalBlack.setColor(QPalette.Active,   QPalette.Button, QColor(28, 28, 28))
            self.fPalBlack.setColor(QPalette.Inactive, QPalette.Button, QColor(28, 28, 28))
            self.fPalBlack.setColor(QPalette.Disabled, QPalette.ButtonText, QColor(90, 90, 90))
            self.fPalBlack.setColor(QPalette.Active,   QPalette.ButtonText, QColor(240, 240, 240))
            self.fPalBlack.setColor(QPalette.Inactive, QPalette.ButtonText, QColor(240, 240, 240))
            self.fPalBlack.setColor(QPalette.Disabled, QPalette.BrightText, QColor(255, 255, 255))
            self.fPalBlack.setColor(QPalette.Active,   QPalette.BrightText, QColor(255, 255, 255))
            self.fPalBlack.setColor(QPalette.Inactive, QPalette.BrightText, QColor(255, 255, 255))
            self.fPalBlack.setColor(QPalette.Disabled, QPalette.Light, QColor(191, 191, 191))
            self.fPalBlack.setColor(QPalette.Active,   QPalette.Light, QColor(191, 191, 191))
            self.fPalBlack.setColor(QPalette.Inactive, QPalette.Light, QColor(191, 191, 191))
            self.fPalBlack.setColor(QPalette.Disabled, QPalette.Midlight, QColor(155, 155, 155))
            self.fPalBlack.setColor(QPalette.Active,   QPalette.Midlight, QColor(155, 155, 155))
            self.fPalBlack.setColor(QPalette.Inactive, QPalette.Midlight, QColor(155, 155, 155))
            self.fPalBlack.setColor(QPalette.Disabled, QPalette.Dark, QColor(129, 129, 129))
            self.fPalBlack.setColor(QPalette.Active,   QPalette.Dark, QColor(129, 129, 129))
            self.fPalBlack.setColor(QPalette.Inactive, QPalette.Dark, QColor(129, 129, 129))
            self.fPalBlack.setColor(QPalette.Disabled, QPalette.Mid, QColor(94, 94, 94))
            self.fPalBlack.setColor(QPalette.Active,   QPalette.Mid, QColor(94, 94, 94))
            self.fPalBlack.setColor(QPalette.Inactive, QPalette.Mid, QColor(94, 94, 94))
            self.fPalBlack.setColor(QPalette.Disabled, QPalette.Shadow, QColor(155, 155, 155))
            self.fPalBlack.setColor(QPalette.Active,   QPalette.Shadow, QColor(155, 155, 155))
            self.fPalBlack.setColor(QPalette.Inactive, QPalette.Shadow, QColor(155, 155, 155))
            self.fPalBlack.setColor(QPalette.Disabled, QPalette.Highlight, QColor(14, 14, 14))
            self.fPalBlack.setColor(QPalette.Active,   QPalette.Highlight, QColor(60, 60, 60))
            self.fPalBlack.setColor(QPalette.Inactive, QPalette.Highlight, QColor(34, 34, 34))
            self.fPalBlack.setColor(QPalette.Disabled, QPalette.HighlightedText, QColor(83, 83, 83))
            self.fPalBlack.setColor(QPalette.Active,   QPalette.HighlightedText, QColor(255, 255, 255))
            self.fPalBlack.setColor(QPalette.Inactive, QPalette.HighlightedText, QColor(240, 240, 240))
            self.fPalBlack.setColor(QPalette.Disabled, QPalette.Link, QColor(34, 34, 74))
            self.fPalBlack.setColor(QPalette.Active,   QPalette.Link, QColor(100, 100, 230))
            self.fPalBlack.setColor(QPalette.Inactive, QPalette.Link, QColor(100, 100, 230))
            self.fPalBlack.setColor(QPalette.Disabled, QPalette.LinkVisited, QColor(74, 34, 74))
            self.fPalBlack.setColor(QPalette.Active,   QPalette.LinkVisited, QColor(230, 100, 230))
            self.fPalBlack.setColor(QPalette.Inactive, QPalette.LinkVisited, QColor(230, 100, 230))
            self.fApp.setPalette(self.fPalBlack)

        elif proThemeColor == "blue":
            self.fPalBlue = QPalette()
            self.fPalBlue.setColor(QPalette.Disabled, QPalette.Window, QColor(32, 35, 39))
            self.fPalBlue.setColor(QPalette.Active,   QPalette.Window, QColor(37, 40, 45))
            self.fPalBlue.setColor(QPalette.Inactive, QPalette.Window, QColor(37, 40, 45))
            self.fPalBlue.setColor(QPalette.Disabled, QPalette.WindowText, QColor(89, 95, 104))
            self.fPalBlue.setColor(QPalette.Active,   QPalette.WindowText, QColor(223, 237, 255))
            self.fPalBlue.setColor(QPalette.Inactive, QPalette.WindowText, QColor(223, 237, 255))
            self.fPalBlue.setColor(QPalette.Disabled, QPalette.Base, QColor(48, 53, 60))
            self.fPalBlue.setColor(QPalette.Active,   QPalette.Base, QColor(55, 61, 69))
            self.fPalBlue.setColor(QPalette.Inactive, QPalette.Base, QColor(55, 61, 69))
            self.fPalBlue.setColor(QPalette.Disabled, QPalette.AlternateBase, QColor(60, 64, 67))
            self.fPalBlue.setColor(QPalette.Active,   QPalette.AlternateBase, QColor(69, 73, 77))
            self.fPalBlue.setColor(QPalette.Inactive, QPalette.AlternateBase, QColor(69, 73, 77))
            self.fPalBlue.setColor(QPalette.Disabled, QPalette.ToolTipBase, QColor(182, 193, 208))
            self.fPalBlue.setColor(QPalette.Active,   QPalette.ToolTipBase, QColor(182, 193, 208))
            self.fPalBlue.setColor(QPalette.Inactive, QPalette.ToolTipBase, QColor(182, 193, 208))
            self.fPalBlue.setColor(QPalette.Disabled, QPalette.ToolTipText, QColor(42, 44, 48))
            self.fPalBlue.setColor(QPalette.Active,   QPalette.ToolTipText, QColor(42, 44, 48))
            self.fPalBlue.setColor(QPalette.Inactive, QPalette.ToolTipText, QColor(42, 44, 48))
            self.fPalBlue.setColor(QPalette.Disabled, QPalette.Text, QColor(96, 103, 113))
            self.fPalBlue.setColor(QPalette.Active,   QPalette.Text, QColor(210, 222, 240))
            self.fPalBlue.setColor(QPalette.Inactive, QPalette.Text, QColor(210, 222, 240))
            self.fPalBlue.setColor(QPalette.Disabled, QPalette.Button, QColor(51, 55, 62))
            self.fPalBlue.setColor(QPalette.Active,   QPalette.Button, QColor(59, 63, 71))
            self.fPalBlue.setColor(QPalette.Inactive, QPalette.Button, QColor(59, 63, 71))
            self.fPalBlue.setColor(QPalette.Disabled, QPalette.ButtonText, QColor(98, 104, 114))
            self.fPalBlue.setColor(QPalette.Active,   QPalette.ButtonText, QColor(210, 222, 240))
            self.fPalBlue.setColor(QPalette.Inactive, QPalette.ButtonText, QColor(210, 222, 240))
            self.fPalBlue.setColor(QPalette.Disabled, QPalette.BrightText, QColor(255, 255, 255))
            self.fPalBlue.setColor(QPalette.Active,   QPalette.BrightText, QColor(255, 255, 255))
            self.fPalBlue.setColor(QPalette.Inactive, QPalette.BrightText, QColor(255, 255, 255))
            self.fPalBlue.setColor(QPalette.Disabled, QPalette.Light, QColor(59, 64, 72))
            self.fPalBlue.setColor(QPalette.Active,   QPalette.Light, QColor(63, 68, 76))
            self.fPalBlue.setColor(QPalette.Inactive, QPalette.Light, QColor(63, 68, 76))
            self.fPalBlue.setColor(QPalette.Disabled, QPalette.Midlight, QColor(48, 52, 59))
            self.fPalBlue.setColor(QPalette.Active,   QPalette.Midlight, QColor(51, 56, 63))
            self.fPalBlue.setColor(QPalette.Inactive, QPalette.Midlight, QColor(51, 56, 63))
            self.fPalBlue.setColor(QPalette.Disabled, QPalette.Dark, QColor(18, 19, 22))
            self.fPalBlue.setColor(QPalette.Active,   QPalette.Dark, QColor(20, 22, 25))
            self.fPalBlue.setColor(QPalette.Inactive, QPalette.Dark, QColor(20, 22, 25))
            self.fPalBlue.setColor(QPalette.Disabled, QPalette.Mid, QColor(28, 30, 34))
            self.fPalBlue.setColor(QPalette.Active,   QPalette.Mid, QColor(32, 35, 39))
            self.fPalBlue.setColor(QPalette.Inactive, QPalette.Mid, QColor(32, 35, 39))
            self.fPalBlue.setColor(QPalette.Disabled, QPalette.Shadow, QColor(13, 14, 16))
            self.fPalBlue.setColor(QPalette.Active,   QPalette.Shadow, QColor(15, 16, 18))
            self.fPalBlue.setColor(QPalette.Inactive, QPalette.Shadow, QColor(15, 16, 18))
            self.fPalBlue.setColor(QPalette.Disabled, QPalette.Highlight, QColor(32, 35, 39))
            self.fPalBlue.setColor(QPalette.Active,   QPalette.Highlight, QColor(14, 14, 17))
            self.fPalBlue.setColor(QPalette.Inactive, QPalette.Highlight, QColor(27, 28, 33))
            self.fPalBlue.setColor(QPalette.Disabled, QPalette.HighlightedText, QColor(89, 95, 104))
            self.fPalBlue.setColor(QPalette.Active,   QPalette.HighlightedText, QColor(217, 234, 253))
            self.fPalBlue.setColor(QPalette.Inactive, QPalette.HighlightedText, QColor(223, 237, 255))
            self.fPalBlue.setColor(QPalette.Disabled, QPalette.Link, QColor(79, 100, 118))
            self.fPalBlue.setColor(QPalette.Active,   QPalette.Link, QColor(156, 212, 255))
            self.fPalBlue.setColor(QPalette.Inactive, QPalette.Link, QColor(156, 212, 255))
            self.fPalBlue.setColor(QPalette.Disabled, QPalette.LinkVisited, QColor(51, 74, 118))
            self.fPalBlue.setColor(QPalette.Active,   QPalette.LinkVisited, QColor(64, 128, 255))
            self.fPalBlue.setColor(QPalette.Inactive, QPalette.LinkVisited, QColor(64, 128, 255))
            self.fApp.setPalette(self.fPalBlue)

    def createApp(self, appName):
        self.fApp = QApplication(sys.argv)
        self.fApp.setApplicationName(appName)
        self.fApp.setApplicationVersion(VERSION)
        self.fApp.setOrganizationName("falkTX")

        if appName.lower() == "carla-control":
            self.fApp.setWindowIcon(QIcon(":/scalable/carla-control.svg"))
        else:
            self.fApp.setWindowIcon(QIcon(":/scalable/carla.svg"))

        if MACOS:
            self.fApp.setAttribute(Qt.AA_DontShowIconsInMenus)

        print("Using \"%s\" theme" % self.fApp.style().objectName())

    def arguments(self):
        # FIXME - PyQt mishandles unicode characters, we'll use direct sys.argv for now
        return sys.argv
        return self.fApp.arguments()

    def exec_(self):
        return self.fApp.exec_()

    def exit_exec(self):
        return sys.exit(self.fApp.exec_())

    def getApp(self):
        return self.fApp

    def quit(self):
        self.fApp.quit()
Example #31
0
    QCoreApplication.setAttribute(QtCore.Qt.AA_X11InitThreads, True)

from PyQt5.QtWidgets import QApplication
app = QApplication(sys.argv)
app.setOrganizationName("Deepin")
app.setApplicationName("Deepin Screenshot")
app.setApplicationVersion("3.1.0")
app.setQuitOnLastWindowClosed(False)

from app_controller import AppController
from dbus_services import is_service_exist, register_object
from dbus_interfaces import screenshotInterface

if __name__ == "__main__":
    if is_service_exist():
        screenshotInterface.runWithArguments(app.arguments())
        # TODO: maybe there will never be a situation that
        # the following should be executed.
        # notificationsInterface.notify(_("Deepin Screenshot"),
        #     _("Deepin Screenshot has been started!"))
    else:
        controller = AppController()

        returncode = controller.runWithArguments(app.arguments())
        if returncode == 0:
            register_object(controller)
            signal.signal(signal.SIGINT, signal.SIG_DFL)
            sys.exit(app.exec_())
        else:
            sys.exit(1)
Example #32
0
    )
    parser.add_argument(  # Allow browser plugins
        "-g", "--allow_plugins", action="store_true", default=argparse.SUPPRESS,
        dest='allow_plugins',
        help="Allow the browser to use plugins like"
        " Flash or Java (if installed)"
    )
    parser.add_argument(  # Window size
        "--size", action="store", dest="window_size", default=None,
        help="Specify the default window size in pixels (widthxheight),"
        " or 'max' to maximize"
    )
    parser.add_argument(  # HTTP Proxy server
        "--proxy_server", action="store", dest="proxy_server", default=None,
        help="Specify a proxy server string, in the form host:port"
    )

    # rather than parse sys.argv here, we're parsing app.arguments
    # so that qt-specific args are removed.
    # we also need to remove argument 0.
    args = parser.parse_args([str(x) for x in list(app.arguments())][1:])
    DEBUG = args.DEBUG
    DEBUG_LOG = args.debug_log
    if not args.config_file:
        debug("No config file found or specified; using defaults.")

    # run the actual application
    mainwin = MainWindow(args)
    mainwin.show()
    app.exec_()
Example #33
0
from PyQt5 import QtCore
from PyQt5.QtCore import QCoreApplication
if os.name == 'posix':
    QCoreApplication.setAttribute(QtCore.Qt.AA_X11InitThreads, True)

from PyQt5.QtWidgets import QApplication
app = QApplication(sys.argv)
app.setOrganizationName("Deepin")
app.setApplicationName("Deepin Screenshot")
app.setApplicationVersion("3.0")
app.setQuitOnLastWindowClosed(False)

from app_controller import AppController
from dbus_services import is_service_exist, register_object
from dbus_interfaces import screenshotInterface

if __name__ == "__main__":
    if is_service_exist():
        screenshotInterface.runWithArguments(app.arguments())
        # TODO: maybe there will never be a situation that
        # the following should be executed.
        # notificationsInterface.notify(_("Deepin Screenshot"),
        #     _("Deepin Screenshot has been started!"))
    else:
        controller = AppController()
        controller.runWithArguments(app.arguments())
        register_object(controller)

        signal.signal(signal.SIGINT, signal.SIG_DFL)
        sys.exit(app.exec_())
Example #34
0
		else:
			self.browseSelectedTags()

	def browsePath(self, path):
		self.imageList.setFiles(os.path.join(path, f) for f in os.listdir(path))


def xdg_config():
	return os.getenv('XDG_CONFIG_HOME', os.getenv('HOME', '/') + '/.config')


def parse_options(args):
	import optparse
	parser = optparse.OptionParser()
	parser.add_option('-d', '--database', metavar='FILE', dest='db')
	parser.add_option('-p', '--path', dest='filespath')
	parser.set_defaults(filespath='/', db=xdg_config() + '/sit-tagger.sqlite')
	opts, _ = parser.parse_args(args)
	return opts


if __name__ == '__main__':
	if sys.excepthook is sys.__excepthook__:
		sys.excepthook = lambda *args: sys.__excepthook__(*args)

	app = QApplication(sys.argv)
	opts = parse_options(list(app.arguments()))
	win = Win(opts)
	win.show()
	app.exec_()
Example #35
0
<p style=\"-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"></p>\n
<p style=\"-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left
        :0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"></p>\n
<p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">This program is free software: you can redistribute it and/or modify</p>\n
<p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">it under the terms of the GNU General Public License as published </p>\n
<p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">by the Free Software Foundation, either version 3 of the License, </p>\n
<p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">or (at your option) any later version.</p>\n
<p style=\"-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"></p>\n
<p style=\" margin-top:0px; margin-botto
        m:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">This program is distributed in the hope that it will be useful,</p>\n
<p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">but WITHOUT ANY WARRANTY; without even the implied warranty of</p>\n
<p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the</p>\n
<p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">GNU General Public License for more details.</p>\n
<p style=\"-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"></p>\n
<p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">You should have received a copy of the GNU General Public License</p>\n
<p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">along with this program.  If not, see <a href=\"http://www.gnu.org/licenses/\">http://www.gnu.org/licenses/</a>.</p></body></html>"""
            ))


if __name__ == "__main__":
    app = QApplication(sys.argv)
    parser = argparse.ArgumentParser()
    parser.add_argument(dest="databaseName",
                        action="store",
                        help="the database name")
    args = parser.parse_args(app.arguments()[1:])
    databaseName = args.databaseName
    gui = FVK()
    gui.show()
    sys.exit(app.exec_())
Example #36
0
    def createEvaluationRichText(self, solutionGroups, inputGroups):
        richText = "<table align='center'><tr><td align='center'><pre>SENT</pre></td><td align='center'><pre>RECEIVED</pre></t></tr>"
        for idx, solutionGroup in enumerate(solutionGroups):
            richText += "<tr>"
            if idx >= len(inputGroups):
                inputGroups.append("")
            _, solutionMatched, inputMatched = global_matching(solutionGroups[idx], inputGroups[idx])
            colorSolution, colorInput = "", ""
            for idx, _ in enumerate(solutionMatched):
                if solutionMatched[idx] == inputMatched[idx]:
                    colorSolution += "<span style='color: green'>" + solutionMatched[idx] + "</span>"
                    colorInput += "<span style='color: green'>" + inputMatched[idx] + "</span>"
                else:
                    colorSolution += "<span style='color: red'>" + solutionMatched[idx] + "</span>"
                    colorInput += "<span style='color: red'>" + inputMatched[idx] + "</span>"
            richText += "<td align='center'><pre>" + colorSolution + "</pre></td><td align='center'><pre>" + colorInput + "</pre></td>"
            richText += "</tr>"
        richText += "</table>"
        return richText



if __name__ == "__main__":
    app = QApplication(sys.argv)
    mw = MainWindow()
    if "--debug" in app.arguments():
        print("Debug active...")
        mw.enableDebugMode()
    sys.exit(app.exec_())

Example #37
0
def main():
    app = QApplication(sys.argv)

    window = MainWindow(app.arguments())
    window.show()
    return app.exec_()
Example #38
0
      #do_wine_stuff()
      do_final_stuff()
      do_live_stuff()
      sys.exit(0)

    # App initialization
    app = QApplication(sys.argv)
    app.setApplicationName("Welcome")
    app.setOrganizationName("KXStudio")

    settings = QSettings("KXStudio", "Welcome")

    run = True
    firstRun = False
    fullscreen = False

    if "--first-run" in app.arguments():
      firstRun = settings.value("FirstRun", True, type=bool)
      run = firstRun
    if "--fullscreen" in app.arguments():
      fullscreen = True

    # Show GUI
    if run:
      gui = WelcomeW(firstRun)
      gui.show()
      app.exec_()

    # Always exit cleanly
    sys.exit(0)
Example #39
0
        dest='allow_plugins',
        help="Allow the browser to use plugins like"
        " Flash or Java (if installed)")
    parser.add_argument(  # Window size
        "--size",
        action="store",
        dest="window_size",
        default=None,
        help="Specify the default window size in pixels (widthxheight),"
        " 'max' to maximize, or 'full' for full-screen.")
    parser.add_argument(  # HTTP Proxy server
        "--proxy_server",
        action="store",
        dest="proxy_server",
        default=None,
        help="Specify a proxy server string, in the form host:port")

    # rather than parse sys.argv here, we're parsing app.arguments
    # so that qt-specific args are removed.
    # we also need to remove argument 0.
    args = parser.parse_args([str(x) for x in list(app.arguments())][1:])
    DEBUG = args.DEBUG
    DEBUG_LOG = args.debug_log
    if not args.config_file:
        debug("No config file found or specified; using defaults.")

    # run the actual application
    mainwin = MainWindow(args)
    mainwin.show()
    app.exec_()
Example #40
0
from PyQt5.QtWidgets import QApplication
from types.visualization.mainwindow import MainWindow

import sys
import fileinput

if __name__ == "__main__":
    app = QApplication(sys.argv)
    main_window = MainWindow()

    if len(app.arguments()) == 2 and app.arguments()[1] == "-":
        str_input = sys.stdin.read()
        main_window.set_clusters(str_input)

    main_window.showMaximized()

    sys.exit(app.exec())
Example #41
0
class CarlaApplication(object):
    def __init__(self, appName = "Carla2", libPrefix = None):
        object.__init__(self)

        # try to find styles dir
        stylesDir = ""

        CWDl = CWD.lower()

        if libPrefix is not None:
            stylesDir = os.path.join(libPrefix, "lib", "carla")

        elif CWDl.endswith("resources"):
            if CWDl.endswith("native-plugins%sresources" % os.sep):
                stylesDir = os.path.abspath(os.path.join(CWD, "..", "..", "..", "..", "bin"))
            elif "carla-native.lv2" in sys.argv[0]:
                stylesDir = os.path.abspath(os.path.join(CWD, "..", "..", "..", "lib", "lv2", "carla-native.lv2"))
            else:
                stylesDir = os.path.abspath(os.path.join(CWD, "..", "..", "..", "lib", "carla"))

        elif CWDl.endswith("source"):
            stylesDir = os.path.abspath(os.path.join(CWD, "..", "bin"))

        if stylesDir:
            QApplication.addLibraryPath(stylesDir)

        elif not config_UseQt5:
            self._createApp(appName)
            return

        # base settings
        settings    = QSettings("falkTX", appName)
        useProTheme = settings.value(CARLA_KEY_MAIN_USE_PRO_THEME, True, type=bool)

        if not useProTheme:
            self._createApp(appName)
            return

        if config_UseQt5:
            # set initial Qt stuff
            customFont = QFont("DejaVu Sans [Book]")
            customFont.setBold(False)
            customFont.setItalic(False)
            customFont.setOverline(False)
            customFont.setKerning(True)
            customFont.setHintingPreference(QFont.PreferFullHinting)
            customFont.setPixelSize(12)
            customFont.setWeight(QFont.Normal)

            QApplication.setDesktopSettingsAware(False)
            QApplication.setFont(customFont)

        # set style
        QApplication.setStyle("carla" if stylesDir else "fusion")

        # create app
        self._createApp(appName)

        if config_UseQt5:
            self.fApp.setFont(customFont)

        self.fApp.setStyle("carla" if stylesDir else "fusion")

        # set palette
        proThemeColor = settings.value(CARLA_KEY_MAIN_PRO_THEME_COLOR, "Black", type=str).lower()

        if proThemeColor == "black":
            self.fPalBlack = QPalette()
            self.fPalBlack.setColor(QPalette.Disabled, QPalette.Window, QColor(14, 14, 14))
            self.fPalBlack.setColor(QPalette.Active,   QPalette.Window, QColor(17, 17, 17))
            self.fPalBlack.setColor(QPalette.Inactive, QPalette.Window, QColor(17, 17, 17))
            self.fPalBlack.setColor(QPalette.Disabled, QPalette.WindowText, QColor(83, 83, 83))
            self.fPalBlack.setColor(QPalette.Active,   QPalette.WindowText, QColor(240, 240, 240))
            self.fPalBlack.setColor(QPalette.Inactive, QPalette.WindowText, QColor(240, 240, 240))
            self.fPalBlack.setColor(QPalette.Disabled, QPalette.Base, QColor(6, 6, 6))
            self.fPalBlack.setColor(QPalette.Active,   QPalette.Base, QColor(7, 7, 7))
            self.fPalBlack.setColor(QPalette.Inactive, QPalette.Base, QColor(7, 7, 7))
            self.fPalBlack.setColor(QPalette.Disabled, QPalette.AlternateBase, QColor(12, 12, 12))
            self.fPalBlack.setColor(QPalette.Active,   QPalette.AlternateBase, QColor(14, 14, 14))
            self.fPalBlack.setColor(QPalette.Inactive, QPalette.AlternateBase, QColor(14, 14, 14))
            self.fPalBlack.setColor(QPalette.Disabled, QPalette.ToolTipBase, QColor(4, 4, 4))
            self.fPalBlack.setColor(QPalette.Active,   QPalette.ToolTipBase, QColor(4, 4, 4))
            self.fPalBlack.setColor(QPalette.Inactive, QPalette.ToolTipBase, QColor(4, 4, 4))
            self.fPalBlack.setColor(QPalette.Disabled, QPalette.ToolTipText, QColor(230, 230, 230))
            self.fPalBlack.setColor(QPalette.Active,   QPalette.ToolTipText, QColor(230, 230, 230))
            self.fPalBlack.setColor(QPalette.Inactive, QPalette.ToolTipText, QColor(230, 230, 230))
            self.fPalBlack.setColor(QPalette.Disabled, QPalette.Text, QColor(74, 74, 74))
            self.fPalBlack.setColor(QPalette.Active,   QPalette.Text, QColor(230, 230, 230))
            self.fPalBlack.setColor(QPalette.Inactive, QPalette.Text, QColor(230, 230, 230))
            self.fPalBlack.setColor(QPalette.Disabled, QPalette.Button, QColor(24, 24, 24))
            self.fPalBlack.setColor(QPalette.Active,   QPalette.Button, QColor(28, 28, 28))
            self.fPalBlack.setColor(QPalette.Inactive, QPalette.Button, QColor(28, 28, 28))
            self.fPalBlack.setColor(QPalette.Disabled, QPalette.ButtonText, QColor(90, 90, 90))
            self.fPalBlack.setColor(QPalette.Active,   QPalette.ButtonText, QColor(240, 240, 240))
            self.fPalBlack.setColor(QPalette.Inactive, QPalette.ButtonText, QColor(240, 240, 240))
            self.fPalBlack.setColor(QPalette.Disabled, QPalette.BrightText, QColor(255, 255, 255))
            self.fPalBlack.setColor(QPalette.Active,   QPalette.BrightText, QColor(255, 255, 255))
            self.fPalBlack.setColor(QPalette.Inactive, QPalette.BrightText, QColor(255, 255, 255))
            self.fPalBlack.setColor(QPalette.Disabled, QPalette.Light, QColor(191, 191, 191))
            self.fPalBlack.setColor(QPalette.Active,   QPalette.Light, QColor(191, 191, 191))
            self.fPalBlack.setColor(QPalette.Inactive, QPalette.Light, QColor(191, 191, 191))
            self.fPalBlack.setColor(QPalette.Disabled, QPalette.Midlight, QColor(155, 155, 155))
            self.fPalBlack.setColor(QPalette.Active,   QPalette.Midlight, QColor(155, 155, 155))
            self.fPalBlack.setColor(QPalette.Inactive, QPalette.Midlight, QColor(155, 155, 155))
            self.fPalBlack.setColor(QPalette.Disabled, QPalette.Dark, QColor(129, 129, 129))
            self.fPalBlack.setColor(QPalette.Active,   QPalette.Dark, QColor(129, 129, 129))
            self.fPalBlack.setColor(QPalette.Inactive, QPalette.Dark, QColor(129, 129, 129))
            self.fPalBlack.setColor(QPalette.Disabled, QPalette.Mid, QColor(94, 94, 94))
            self.fPalBlack.setColor(QPalette.Active,   QPalette.Mid, QColor(94, 94, 94))
            self.fPalBlack.setColor(QPalette.Inactive, QPalette.Mid, QColor(94, 94, 94))
            self.fPalBlack.setColor(QPalette.Disabled, QPalette.Shadow, QColor(155, 155, 155))
            self.fPalBlack.setColor(QPalette.Active,   QPalette.Shadow, QColor(155, 155, 155))
            self.fPalBlack.setColor(QPalette.Inactive, QPalette.Shadow, QColor(155, 155, 155))
            self.fPalBlack.setColor(QPalette.Disabled, QPalette.Highlight, QColor(14, 14, 14))
            self.fPalBlack.setColor(QPalette.Active,   QPalette.Highlight, QColor(60, 60, 60))
            self.fPalBlack.setColor(QPalette.Inactive, QPalette.Highlight, QColor(34, 34, 34))
            self.fPalBlack.setColor(QPalette.Disabled, QPalette.HighlightedText, QColor(83, 83, 83))
            self.fPalBlack.setColor(QPalette.Active,   QPalette.HighlightedText, QColor(255, 255, 255))
            self.fPalBlack.setColor(QPalette.Inactive, QPalette.HighlightedText, QColor(240, 240, 240))
            self.fPalBlack.setColor(QPalette.Disabled, QPalette.Link, QColor(34, 34, 74))
            self.fPalBlack.setColor(QPalette.Active,   QPalette.Link, QColor(100, 100, 230))
            self.fPalBlack.setColor(QPalette.Inactive, QPalette.Link, QColor(100, 100, 230))
            self.fPalBlack.setColor(QPalette.Disabled, QPalette.LinkVisited, QColor(74, 34, 74))
            self.fPalBlack.setColor(QPalette.Active,   QPalette.LinkVisited, QColor(230, 100, 230))
            self.fPalBlack.setColor(QPalette.Inactive, QPalette.LinkVisited, QColor(230, 100, 230))
            self.fApp.setPalette(self.fPalBlack)

        elif proThemeColor == "blue":
            self.fPalBlue = QPalette()
            self.fPalBlue.setColor(QPalette.Disabled, QPalette.Window, QColor(32, 35, 39))
            self.fPalBlue.setColor(QPalette.Active,   QPalette.Window, QColor(37, 40, 45))
            self.fPalBlue.setColor(QPalette.Inactive, QPalette.Window, QColor(37, 40, 45))
            self.fPalBlue.setColor(QPalette.Disabled, QPalette.WindowText, QColor(89, 95, 104))
            self.fPalBlue.setColor(QPalette.Active,   QPalette.WindowText, QColor(223, 237, 255))
            self.fPalBlue.setColor(QPalette.Inactive, QPalette.WindowText, QColor(223, 237, 255))
            self.fPalBlue.setColor(QPalette.Disabled, QPalette.Base, QColor(48, 53, 60))
            self.fPalBlue.setColor(QPalette.Active,   QPalette.Base, QColor(55, 61, 69))
            self.fPalBlue.setColor(QPalette.Inactive, QPalette.Base, QColor(55, 61, 69))
            self.fPalBlue.setColor(QPalette.Disabled, QPalette.AlternateBase, QColor(60, 64, 67))
            self.fPalBlue.setColor(QPalette.Active,   QPalette.AlternateBase, QColor(69, 73, 77))
            self.fPalBlue.setColor(QPalette.Inactive, QPalette.AlternateBase, QColor(69, 73, 77))
            self.fPalBlue.setColor(QPalette.Disabled, QPalette.ToolTipBase, QColor(182, 193, 208))
            self.fPalBlue.setColor(QPalette.Active,   QPalette.ToolTipBase, QColor(182, 193, 208))
            self.fPalBlue.setColor(QPalette.Inactive, QPalette.ToolTipBase, QColor(182, 193, 208))
            self.fPalBlue.setColor(QPalette.Disabled, QPalette.ToolTipText, QColor(42, 44, 48))
            self.fPalBlue.setColor(QPalette.Active,   QPalette.ToolTipText, QColor(42, 44, 48))
            self.fPalBlue.setColor(QPalette.Inactive, QPalette.ToolTipText, QColor(42, 44, 48))
            self.fPalBlue.setColor(QPalette.Disabled, QPalette.Text, QColor(96, 103, 113))
            self.fPalBlue.setColor(QPalette.Active,   QPalette.Text, QColor(210, 222, 240))
            self.fPalBlue.setColor(QPalette.Inactive, QPalette.Text, QColor(210, 222, 240))
            self.fPalBlue.setColor(QPalette.Disabled, QPalette.Button, QColor(51, 55, 62))
            self.fPalBlue.setColor(QPalette.Active,   QPalette.Button, QColor(59, 63, 71))
            self.fPalBlue.setColor(QPalette.Inactive, QPalette.Button, QColor(59, 63, 71))
            self.fPalBlue.setColor(QPalette.Disabled, QPalette.ButtonText, QColor(98, 104, 114))
            self.fPalBlue.setColor(QPalette.Active,   QPalette.ButtonText, QColor(210, 222, 240))
            self.fPalBlue.setColor(QPalette.Inactive, QPalette.ButtonText, QColor(210, 222, 240))
            self.fPalBlue.setColor(QPalette.Disabled, QPalette.BrightText, QColor(255, 255, 255))
            self.fPalBlue.setColor(QPalette.Active,   QPalette.BrightText, QColor(255, 255, 255))
            self.fPalBlue.setColor(QPalette.Inactive, QPalette.BrightText, QColor(255, 255, 255))
            self.fPalBlue.setColor(QPalette.Disabled, QPalette.Light, QColor(59, 64, 72))
            self.fPalBlue.setColor(QPalette.Active,   QPalette.Light, QColor(63, 68, 76))
            self.fPalBlue.setColor(QPalette.Inactive, QPalette.Light, QColor(63, 68, 76))
            self.fPalBlue.setColor(QPalette.Disabled, QPalette.Midlight, QColor(48, 52, 59))
            self.fPalBlue.setColor(QPalette.Active,   QPalette.Midlight, QColor(51, 56, 63))
            self.fPalBlue.setColor(QPalette.Inactive, QPalette.Midlight, QColor(51, 56, 63))
            self.fPalBlue.setColor(QPalette.Disabled, QPalette.Dark, QColor(18, 19, 22))
            self.fPalBlue.setColor(QPalette.Active,   QPalette.Dark, QColor(20, 22, 25))
            self.fPalBlue.setColor(QPalette.Inactive, QPalette.Dark, QColor(20, 22, 25))
            self.fPalBlue.setColor(QPalette.Disabled, QPalette.Mid, QColor(28, 30, 34))
            self.fPalBlue.setColor(QPalette.Active,   QPalette.Mid, QColor(32, 35, 39))
            self.fPalBlue.setColor(QPalette.Inactive, QPalette.Mid, QColor(32, 35, 39))
            self.fPalBlue.setColor(QPalette.Disabled, QPalette.Shadow, QColor(13, 14, 16))
            self.fPalBlue.setColor(QPalette.Active,   QPalette.Shadow, QColor(15, 16, 18))
            self.fPalBlue.setColor(QPalette.Inactive, QPalette.Shadow, QColor(15, 16, 18))
            self.fPalBlue.setColor(QPalette.Disabled, QPalette.Highlight, QColor(32, 35, 39))
            self.fPalBlue.setColor(QPalette.Active,   QPalette.Highlight, QColor(14, 14, 17))
            self.fPalBlue.setColor(QPalette.Inactive, QPalette.Highlight, QColor(27, 28, 33))
            self.fPalBlue.setColor(QPalette.Disabled, QPalette.HighlightedText, QColor(89, 95, 104))
            self.fPalBlue.setColor(QPalette.Active,   QPalette.HighlightedText, QColor(217, 234, 253))
            self.fPalBlue.setColor(QPalette.Inactive, QPalette.HighlightedText, QColor(223, 237, 255))
            self.fPalBlue.setColor(QPalette.Disabled, QPalette.Link, QColor(79, 100, 118))
            self.fPalBlue.setColor(QPalette.Active,   QPalette.Link, QColor(156, 212, 255))
            self.fPalBlue.setColor(QPalette.Inactive, QPalette.Link, QColor(156, 212, 255))
            self.fPalBlue.setColor(QPalette.Disabled, QPalette.LinkVisited, QColor(51, 74, 118))
            self.fPalBlue.setColor(QPalette.Active,   QPalette.LinkVisited, QColor(64, 128, 255))
            self.fPalBlue.setColor(QPalette.Inactive, QPalette.LinkVisited, QColor(64, 128, 255))
            self.fApp.setPalette(self.fPalBlue)

        print("Using \"%s\" theme" % self.fApp.style().objectName())

    def _createApp(self, appName):
        self.fApp = QApplication(sys.argv)
        self.fApp.setApplicationName(appName)
        self.fApp.setApplicationVersion(VERSION)
        self.fApp.setOrganizationName("falkTX")

        if appName.lower() == "carla-control":
            self.fApp.setWindowIcon(QIcon(":/scalable/carla-control.svg"))
        else:
            self.fApp.setWindowIcon(QIcon(":/scalable/carla.svg"))

    def arguments(self):
        return self.fApp.arguments()

    def exec_(self):
        return self.fApp.exec_()

    def exit_exec(self):
        return sys.exit(self.fApp.exec_())

    def getApp(self):
        return self.fApp

    def quit(self):
        self.fApp.quit()
Example #42
0
import sys
from PyQt5.QtCore import *
from PyQt5.QtGui import *
from PyQt5.QtWidgets import QApplication, QLabel

if __name__ == "__main__":

    app = QApplication(sys.argv)

    # if len(app.arguments()) < 2:
    #     sys.stderr.write("Usage: %s <image file> <overlay file>\n" % sys.argv[0])
    #     sys.exit(1)

    image = QImage('patent.png')
    if image.isNull():
        sys.stderr.write("Failed to read image: %s\n" % app.arguments()[1])
        sys.exit(1)

    overlay = QImage('a.png')
    if overlay.isNull():
        sys.stderr.write("Failed to read image: %s\n" % app.arguments()[2])
        sys.exit(1)

    # if overlay.size() > image.size():
    #     overlay = overlay.scaled(image.size(), Qt.KeepAspectRatio)

    painter = QPainter()
    painter.begin(image)
    painter.drawImage(100, 100, overlay)
    painter.end()