def main():
    application = QApplication(sys.argv)
    model = MainWindowModel()
    controller = MainWindowController(model)
    font = QFont("Consolas", 16, QFont.StyleItalic)
    application.setFont(font)
    application.exec()
def run_app():
    # Handle high resolution displays:
    if hasattr(Qt, 'AA_EnableHighDpiScaling'):
        QApplication.setAttribute(Qt.AA_EnableHighDpiScaling, True)
    if hasattr(Qt, 'AA_UseHighDpiPixmaps'):
        QApplication.setAttribute(Qt.AA_UseHighDpiPixmaps, True)
    app = QApplication(sys.argv)
    app.setApplicationName("Offline Docs")
    app.setWindowIcon(QIcon('resources/assets/images/logo.png'))
    app_font = RegularFont()
    app.setFont(app_font)
    my_style = MyProxyStyle('Fusion')
    app.setStyle(my_style)
    screen = app.primaryScreen()
    rect = screen.availableGeometry()
    screen_center = screen.availableGeometry().center()
    print('Available: %dx%d' % (rect.width(), rect.height()))
    SessionWrapper.screen_dim = ('%dx%d' % (rect.width(), rect.height()))
    SessionWrapper.screen_width = rect.width()
    SessionWrapper.screen_height = rect.height()
    # print('Screen: %s' % screen.name())
    # size = screen.size()
    # print('Size: %d x %d' % (size.width(), size.height()))

    css_file = "resources/assets/css/style.qss"
    app.setStyleSheet(open(css_file, "r").read())
    login = Login()
    ############################################################
    # if login succeed start the main page                     #
    ############################################################
    login_result = login.exec_()
    if login_result == QDialog.Accepted and login.status == "Done":
        window = LandingForm()
        window.show()
        sys.exit(app.exec_())
Example #3
0
def main():


    # start QT UI
    sargv = sys.argv + ['--style', 'material']
    app = QApplication(sargv)
    font = QFont()
    font.setFamily("Ariel")

    app.setFont(font)
    # manually detect lid open close event from the start

    ui_view = QQuickView()
    
    ui_view.setSource(QUrl.fromLocalFile('RobotPanelSelect.qml'))
    ui_view.setWidth(800)
    ui_view.setHeight(480)
    ui_view.setMaximumHeight(480)
    ui_view.setMaximumWidth(800)
    ui_view.setMinimumHeight(480)
    ui_view.setMinimumWidth(800)
    # ui_view = UIController.get_ui()
    ui_view.show()

    ret = app.exec_()

    # Teminate
    sys.exit(ret)
Example #4
0
def main():
    path = os.path.dirname(__file__)
    with open(os.path.join(path, 'config.json'), encoding='utf-8') as f:
        conf = json.load(f)

    if os.path.exists(os.path.join(path, 'logs')):
        logfile = os.path.join(path, 'logs', 'mkepub.log')
    else:
        logfile = os.path.expanduser(os.path.join('~', 'mkepub.log'))

    logging.basicConfig(level=logging.INFO,
                        filename=logfile,
                        filemode='w',
                        format='%(levelname)-8s %(message)s')

    app = QApplication(sys.argv)
    font = QFont('宋体')
    pointsize = font.pointSize()
    font.setPixelSize(pointsize * 90 / 72)
    app.setFont(font)

    win = MainWindow(conf)
    sys.excepthook = win.exceptHook
    win.show()

    try:
        ret = app.exec_()
    except Exception:
        logging.exception('Unhandle exception')
        ret = 1
    sys.exit(ret)
Example #5
0
def run_gui(config: CoreConfig):
    logger.info("Starting UI")

    app = QApplication([])
    app.setOrganizationName("Scille")
    app.setOrganizationDomain("parsec.cloud")
    app.setApplicationName("Parsec")

    f = QFont("Arial")
    app.setFont(f)

    # splash = QSplashScreen(QPixmap(':/logos/images/logos/parsec.png'))
    # splash.show()
    # app.processEvents()

    lang.switch_language()

    win = MainWindow(core_config=config)

    # QTimer wakes up the event loop periodically which allows us to close
    # the window even when it is in background.
    signal.signal(signal.SIGINT, kill_window(win))
    timer = QTimer()
    timer.start(400)
    timer.timeout.connect(lambda: None)

    win.showMaximized()
    # splash.finish(win)

    return app.exec_()
def guiInitiate():
    app = QApplication(sys.argv)
    app.setStyle("Fusion")
    app.setFont(QFont("Bahnschrift Light", 10))
    program = SENSOR_TEST()
    program.setWindowTitle("Sensor Testing Program")
    app.exec()
Example #7
0
def main():
    parser = argparse.ArgumentParser(description=globals()["__doc__"])

    parser.add_argument("source",
                        nargs="*",
                        help="zero or more source file(s) to preview")
    parser.add_argument(
        "--font",
        help="specify application font (default: {})".format(DEFAULT_FONT),
        default=DEFAULT_FONT)
    parser.add_argument(
        "--import-path",
        "-I",
        metavar="PATH",
        action="append",
        dest="import_paths",
        help="Add PATH to the list of QML import paths. Can be specified "
        "multiple times",
    )

    cl_arguments = parser.parse_args()

    app = QApplication([])

    font = QFont()
    font.setFamily(cl_arguments.font)
    app.setFont(font)

    window = PreviewWindow(*cl_arguments.source,
                           import_paths=cl_arguments.import_paths)
    window.show()
    sys.exit(app.exec_())
Example #8
0
    def __init__(self, parent=None):
        super(MainWindow, self).__init__(parent)
        self.setWindowTitle(u'台鐵訂票助手')

        app_icon = QIcon()
        app_icon.addFile('img/train.png', QtCore.QSize(16, 16))
        app_icon.addFile('img/train.png', QtCore.QSize(24, 24))
        app_icon.addFile('img/train.png', QtCore.QSize(32, 32))
        app_icon.addFile('img/train.png', QtCore.QSize(48, 48))
        app_icon.addFile('img/train.png', QtCore.QSize(256, 256))
        self.setWindowIcon(app_icon)

        self.form_widget = FormWidget(self)
        self.font_size = 12
        font_label_standard = QFont('微軟正黑體', self.font_size)
        QApplication.setFont(font_label_standard)
        # 加入form_widget 表單主體
        self.setCentralWidget(self.form_widget)

        # 加入vpn設定
        VPNAction = QAction(u'VPN設定', self)
        VPNAction.triggered.connect(
            lambda: self.form_widget.showVPNdialog(self.form_widget))
        # 加入menu bar 幫助
        AboutAction = QAction(u'關於', self)
        AboutAction.triggered.connect(self.form_widget.showAbout)

        menubar = self.menuBar()
        AboutMenu = menubar.addMenu(u'選單')
        AboutMenu.addAction(VPNAction)
        AboutMenu.addAction(AboutAction)
Example #9
0
def main(test_func):
    from pyminer2 import pmutil
    app = QApplication(sys.argv)
    path_logo = os.path.join(pmutil.get_root_dir(),
                             r'ui\source\icons\logo.png')
    app.setWindowIcon(QIcon(path_logo))  # 设置应用logo

    path_splash = os.path.join(pmutil.get_root_dir(),
                               r'ui\source\images\splash.png')
    splash = QSplashScreen(QPixmap(path_splash))
    splash.showMessage("正在加载pyminer... 0%", Qt.AlignHCenter | Qt.AlignBottom,
                       Qt.black)
    splash.show()  # 显示启动界面

    pmutil._application = app
    load_fonts(app)
    load_translator(app)
    # font = os.path.join(os.path.dirname(__file__), 'ui', 'source', 'font', 'SourceCodePro-Regular.ttf')
    app.default_font = 'Deng'
    f = QFont(app.default_font, 10)
    app.setFont(f)
    demo = MainWindow()
    demo.events_ready_signal.connect(test_func)
    splash.finish(demo)  # 修复故障 I1VYVO 程序启动完成后,关闭启动界面   liugang 20200921
    id(demo)

    sys.exit(app.exec_())
Example #10
0
def setup_gui(app: QtWidgets.QApplication, options: Values) -> None:
    """Configure GUI app."""
    from pineboolib.core.utils.utils_base import filedir
    from PyQt5 import QtGui

    noto_fonts = [
        "NotoSans-BoldItalic.ttf",
        "NotoSans-Bold.ttf",
        "NotoSans-Italic.ttf",
        "NotoSans-Regular.ttf",
    ]
    for fontfile in noto_fonts:
        QtGui.QFontDatabase.addApplicationFont(
            filedir("./core/fonts/Noto_Sans", fontfile))

    style_app: str = settings.config.value("application/style", "Fusion")
    app.setStyle(style_app)  # type: ignore

    default_font = settings.config.value("application/font", None)
    if default_font is None:
        font = QtGui.QFont("Noto Sans", 9)
        font.setBold(False)
        font.setItalic(False)
    else:
        # FIXME: FLSettings.readEntry does not return an array
        font = QtGui.QFont(default_font[0], int(default_font[1]),
                           int(default_font[2]), default_font[3] == "true")

    app.setFont(font)
Example #11
0
    def __init__(self):
        self.Result = 0
        super(MainWindow, self).__init__()
        uic.loadUi(appContext.get_resource('ui/mainWindow.ui'), self)
        self.fontDB = QtGui.QFontDatabase()
        self.fontID = self.fontDB.addApplicationFont(":Resources/BenSenHandwriting.ttf")
        self.font = QFont('BenSenHandwriting')
        QApplication.setFont(self.font)
        self.btn = self.findChild(QPushButton, 'startBtn')
        self.listen_txt = self.findChild(QPlainTextEdit, 'listenText')
        self.output_txt = self.findChild(QPlainTextEdit,'outputText')
        self.progress_bar = self.findChild(QProgressBar,'progressBar')
        self.status_bar = self.findChild(QStatusBar,'statusbar')

        self.help = self.findChild(QAction, 'actionhelp')
        self.settings = self.findChild(QAction,'actionSettings')
        self.about = self.findChild(QAction, 'actionabout')
        self.exit = self.findChild(QAction, 'actionExit')

        self.progress_bar.setVisible(False)

        self.help.triggered.connect(self.ShowHelp)
        self.settings.triggered.connect(self.ShowSettings)
        self.exit.triggered.connect(self.close)
        self.about.triggered.connect(self.OpenAbout)
        self.btn.clicked.connect(self.BtnClicked)
Example #12
0
def main(config_file=None):
    """ parse args """
    # argument parsing with argparse here for access to functions later
    # update to more formal implementation
    if config_file is None:
        # check for config file from command line
        args = sys.argv[1:]
        if len(args) > 0:
            file = args[0]
            if os.path.isfile(file):
                config_file = file

    if config_file is None:
        # load the default config file from safas module
        config_file = os.path.join(safas.__path__[0], 'config.yml')

    app = QApplication([])
    f = app.font()
    f.setFamily("Monaco")
    f.setPointSize(9)
    app.setFont(f)

    window = MainPanel(config_file)
    logging.basicConfig(stream=sys.stdout,
                        level=logging.INFO)  # global, once for the app
    app.exec_()
Example #13
0
def main():
    import sys
    app = QApplication(sys.argv)
    translator = QTranslator()
    locale = QLocale.system().name()
    translateFile = os.path.join(BASEDIR, 'i18n\\translations', '{}.qm'.format(locale))
    if translator.load(translateFile):
        app.installTranslator(translator)

    # QApplication.setStyle(QStyleFactory.create('Fusion'))

    if boolean(conf.value('General/LargeFont')):
        font = QFont('Courier New', 14)
        app.setFont(font)

    serverName = 'Tafor'
    socket = QLocalSocket()
    socket.connectToServer(serverName)

    # 如果连接成功,表明server已经存在,当前已有实例在运行
    if socket.waitForConnected(500):
        return(app.quit())

    # 没有实例运行,创建服务器     
    localServer = QLocalServer()
    localServer.listen(serverName)

    try:          
        window = MainWindow()
        window.show()
        sys.exit(app.exec_())
    except Exception as e:
        logger.error(e, exc_info=True)
    finally:  
        localServer.close()
Example #14
0
def run():
    app = QApplication(sys.argv)

    # load global stylesheet
    with open(uiresource.getResourcePath('main.qss'), 'r',
              encoding='utf-8') as inf:
        app.setStyleSheet(inf.read())

    # load ui font
    font.loadFontFamily(uiresource.getResourcePath('fonts/open-sans'))

    # load icon font
    font.loadIconFont(
        uiresource.getResourcePath('fonts/icofont/icofont.ttf'),
        uiresource.getResourcePath('fonts/icofont/icofont-map.json'))

    # set global default font
    # defaultFont = QFont("Arial")
    defaultFont = QFont("Open Sans")
    defaultFont.setStyleHint(QFont.Helvetica)
    QApplication.setFont(defaultFont)

    # create and display main window
    window = CalculatorWindow()
    window.show()

    app.exec_()
Example #15
0
def main():
    app = QApplication(sys.argv)
    app.setFont(QFont('Meiryo'))
    w = DirViewer()
    w.setWindowTitle('DirViewer')
    w.show()
    w.raise_()
    app.exec_()
Example #16
0
def main():
    app = QApplication([])
    app.setWindowIcon(QIcon(get_path(PATH_ICON)))
    load_style_sheet(get_path(PATH_STYLE), app)
    font = QFont('Arial', 11, QFont.Bold)
    app.setFont(font)
    main_ctrl = MainController()
    app.exec_()
Example #17
0
def main():
    app = QApplication([])
    app.setWindowIcon(QIcon(utils.get_path('ambientlight/resources/icons/app_icon.svg')))
    utils.load_style_sheet(utils.get_path('ambientlight/resources/style/style.css'), app)
    font = QFont('Arial', 11, QFont.Bold)
    app.setFont(font)
    main_ctrl = MainController()
    app.exec_()
Example #18
0
def main():
    app = QApplication(sys.argv)
    app.setFont(QFont('Meiryo'))
    w = Main()
    w.setWindowTitle('img2pdf')
    w.show()
    w.raise_()
    app.exec_()
Example #19
0
def main():
    app = QApplication(sys.argv)
    app.setFont(QFont('Consolas', 10))
    app.setStyleSheet(stylesheets)

    wid = func.widgets.MainWindow()
    wid.show()
    app.exec()
Example #20
0
 def updateAppFont(self):
     """Update application default font from settings.
     """
     appFont = QFont(self.systemFont)
     appFontName = globalref.miscOptions['AppFont']
     if appFontName:
         appFont.fromString(appFontName)
     QApplication.setFont(appFont)
Example #21
0
def main():
    app = QApplication(sys.argv)
    font = QFont("Meiryo")
    app.setFont(font)
    w = Main()
    w.setWindowTitle("title")
    w.show()
    w.raise_()
    app.exec_()
Example #22
0
def set_window_style(app: QApplication) -> None:
    """
    Sets style of a QMainWindow
    """
    QtGui.QFontDatabase.addApplicationFont('assets/fonts/UBUNTU-BOLD.ttf')
    ubuntu = QtGui.QFont('Ubuntu')
    ubuntu.setBold(True)
    app.setFont(ubuntu)
    app.setStyleSheet(qdarkstyle.load_stylesheet(qt_api='pyqt5'))
Example #23
0
def main():
    app = QApplication(sys.argv)

    app.setFont(QFont('WenQuanYi Micro Hei Mono'))

    main_window = MainWindow()

    app.setStyleSheet(qdarkstyle.load_stylesheet_pyqt5())

    sys.exit(app.exec())
Example #24
0
def main():
    # sys.excepthook = trap_exc_during_debug
    app = QApplication(sys.argv)
    app.setAttribute(Qt.AA_UseStyleSheetPropagationInWidgetStyles, True)
    app.setStyleSheet(darkmode.style)
    font = QFont("Verdana", 12)
    app.setFont(font)
    # window = App(sys.argv[1])
    window = App()
    sys.exit(app.exec())
Example #25
0
def main():
    mainApp = QApplication(['ارز ایران'])

    fontdata = QFontDatabase()
    vazirfont = fontdata.addApplicationFont('Vazir.ttf')
    mainApp.setFont(QFont('Vazir'))

    mainWindow = App()
    mainWindow.show()
    mainApp.exec_()
Example #26
0
def main() -> None:
    """Application main

    :return: None
    """

    app = QApplication([])
    app.setStyle("macintosh")
    app.setFont(QFont(C.FONT_FACE, C.FONT_POINT_SIZE))
    _ = MainWindow()
    sys.exit(app.exec_())
def main():
    # sys.excepthook = trap_exc_during_debug
    app = QApplication(sys.argv)

    font = QFont("Verdana", 12)
    # timer = QTimer()
    # timer.timeout.connect(lambda: None)
    # timer.start(100)
    app.setFont(font)
    window = App(sys.argv[1])
    # window = App()
    sys.exit(app.exec())
Example #28
0
    def initUI(self):
        # Look and feel
        antiAliasedFont = QApplication.font()
        antiAliasedFont.setStyleStrategy(QFont.PreferAntialias)
        QApplication.setFont(antiAliasedFont)

        self.setWindowTitle('Open Chess')
        path = constants.RESOURCES_PATH + '/icon.png'
        self.setWindowIcon(QIcon(path))

        # Geometry
        """This will make the window the correct aspect ratio"""
        screenGeo = QDesktopWidget().availableGeometry()
        idealWidth = constants.IDEAL_RESOLUTION['width']
        idealHeight = constants.IDEAL_RESOLUTION['height']
        # TODO: maybe there is a good way to get this value?
        guessedFrame = 2
        titlebarHeight = QApplication.style().pixelMetric(
                            QStyle.PM_TitleBarHeight) + guessedFrame
        widthDisparity = screenGeo.width() - idealWidth
        heightDisparity = screenGeo.height() - idealHeight
        if widthDisparity < 0 and widthDisparity < heightDisparity:
            width = idealWidth + widthDisparity
            ratio = float(idealHeight) / idealWidth
            height = int(ratio * (idealWidth + widthDisparity))
            self.setGeometry(0, 0, width - guessedFrame * 2,
                             height - titlebarHeight)
        elif heightDisparity < 0 and heightDisparity < widthDisparity:
            ratio = float(idealWidth) / idealHeight
            width = int(ratio * (idealHeight + heightDisparity))
            height = idealHeight + heightDisparity
            self.setGeometry(0, 0, width - guessedFrame * 2,
                             height - titlebarHeight)
        else:
            self.setGeometry(0, 0, idealWidth, idealHeight)
        print("window geometry is", self.geometry())

        # Widget
        self.centralWidget = CentralWidget(self)
        self.setCentralWidget(self.centralWidget)

        self.createActions()
        self.createMenus()

        # Center the window on the desktop
        # TODO: Add option for setting startup xy and saving layout in general
        # qr = self.frameGeometry()
        # cp = QDesktopWidget().geometry().center()
        # qr.moveCenter(cp)
        frameGeo = self.geometry()
        frameGeo.setHeight(frameGeo.height() + titlebarHeight + guessedFrame)
        frameGeo.setWidth(frameGeo.width() + guessedFrame * 2)
        self.move(QDesktopWidget().screenGeometry().center() - frameGeo.center())
Example #29
0
def start(hostname=None):
    # Install message handler for Qt messages
    qInstallMessageHandler(gui_msg_handler)

    # Start the Qt main object
    app = QApplication([])

    # Explicitly set font to avoid font loading warning dialogs
    app.setFont(QFont('Sans'))

    # Start the bluesky network client
    client = GuiClient()

    # Enable HiDPI support (Qt5 only)
    if QT_VERSION_STR[0] == '5' and QT_VERSION >= 0x050000:
        app.setAttribute(Qt.AA_UseHighDpiPixmaps)

    splash = Splash()

    # Register our custom pan/zoom event
    for etype in range(1000, 1000 + NUMCUSTOMEVENTS):
        reg_etype = QEvent.registerEventType(etype)
        if reg_etype != etype:
            print((
                'Warning: Registered event type differs from requested type id (%d != %d)'
                % (reg_etype, etype)))

    splash.show()

    # Install error message handler
    # handler = QErrorMessage.qtHandler()
    # handler.setWindowFlags(Qt.WindowType.WindowStaysOnTopHint)

    splash.showMessage('Constructing main window')
    app.processEvents()
    win = MainWindow(bs.mode)
    win.show()
    splash.showMessage('Done!')
    app.processEvents()
    splash.finish(win)
    # If this instance of the gui is started in client-only mode, show
    # server selection dialog
    if bs.mode == 'client' and hostname is None:
        dialog = DiscoveryDialog(win)
        dialog.show()
        bs.net.start_discovery()

    else:
        client.connect(hostname=hostname)

    # Start the Qt main loop
    # app.exec_()
    app.exec()
Example #30
0
 def __init__(self):
     app = QApplication(sys.argv)
     app.setStyle('Fusion')
     super(MainGui, self).__init__()
     self.font = QFont('Sans Serif', 12)
     app.setFont(self.font)
     self.title = 'AWG control'
     self.left = 200
     self.top = 50
     self.width = 300
     self.height = 500
     self.initUI()
     sys.exit(app.exec_())
Example #31
0
def main(args):
    uavcan.load_dsdl(args.dsdl)

    app = QApplication(sys.argv)
    app.setFont(QFont('Open Sans', pointSize=20))

    node = UavcanNode(interface=args.interface, node_id=args.node_id)

    pub = SetpointPublisherWidget(node)
    pub.show()

    node.spin()
    sys.exit(app.exec_())
Example #32
0
def main():
    app = QApplication(sys.argv)
    if sys.platform == "win32":
        app.setFont(QFont("Tahoma", 9))
    app.setOrganizationName("Besteam")
    app.setOrganizationDomain("besteam.im")
    app.setApplicationName("QuickPanel")
    app.setQuitOnLastWindowClosed(False)
    app.setWindowIcon(QIcon(":/images/angelfish.png"))
    #app.setStyle(QStyleFactory.create("qtcurve"))
    platform = Platform()
    platform.start()
    try:
        getattr(app, "exec")()
    except AttributeError:
        getattr(app, "exec_")()
Example #33
0
def main():
    # Create and parse the command-line arguments
    parser = argparse.ArgumentParser(description='Linux Show Player')
    parser.add_argument('-f', '--file', default='', help="Session file path")
    parser.add_argument('-l', '--log', choices=['debug', 'info', 'warning'],
                        default='warning', help='Log level')

    args = parser.parse_args()

    # Set the logging level
    if args.log == 'debug':
        log = logging.DEBUG
    elif args.log == 'info':
        log = logging.INFO
    else:
        log = logging.WARNING

    logging.basicConfig(format='%(levelname)s:: %(message)s', level=log)

    # Create the QApplication
    app = QApplication(sys.argv)
    app.setApplicationName('Linux Show Player')
    app.setQuitOnLastWindowClosed(True)

    # Force light font, for environment with "bad" QT support.
    appFont = app.font()
    appFont.setWeight(QFont.Light)
    app.setFont(appFont)
    # Set icons and theme from the application configuration
    QIcon.setThemeSearchPaths(styles.IconsThemePaths)
    QIcon.setThemeName(config['Theme']['icons'])
    styles.apply_style(config['Theme']['theme'])

    # Create the application
    LiSP_app = Application()
    # Load modules and plugins
    modules.load_modules()
    plugins.load_plugins()
    # Start the application
    LiSP_app.start(session_file=args.file)

    # Start the application
    sys.exit(_exec(app, LiSP_app))
Example #34
0
    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())
Example #35
0
import sys
from PyQt5.QtCore import QUrl
from PyQt5.QtGui import QFont
from PyQt5.QtWidgets import QApplication
from PyQt5.QtQml import QQmlApplicationEngine, qmlRegisterType
from data_source import DataSource

# Main Function
if __name__ == '__main__':
    # Create main app
    app = QApplication(sys.argv)

    app.setFont(QFont("Droid Sans"))

    qmlRegisterType(DataSource, 'DataSource', 1, 0, 'DataSource')

    engine = QQmlApplicationEngine()
    engine.load(QUrl('main.qml'))

    app.exec_()
    sys.exit()
Example #36
0
# from math import *



class Form(QDialog):
	def __init__(self,parent=None):
		super(Form,self).__init__(parent)
		self.browser = QTextBrowser()
		self.browser.setFont(QFont("Consolas",12,QFont.StyleItalic))
		self.lineedit = QLineEdit('Type an express and press Enter')
		self.lineedit.selectAll()
		layout = QVBoxLayout()
		layout.addWidget(self.browser)
		layout.addWidget(self.lineedit)
		self.setLayout(layout)
		self.lineedit.setFocus()
		# self.connect(self.lineedit,SIGNAL('returnPressed()'),self.updateUi)
		self.lineedit.returnPressed.connect(self.updateUi)
		self.setWindowTitle('Calculate')
	def updateUi(self):
		try:
			text = self.lineedit.text()
			self.browser.append('%s = %s' % (text, eval(text)))
		except:
			self.browser.append('%s is invalid!' % text)
app = QApplication(sys.argv)
app.setFont(QFont("Consolas",10,italic=1))
form = Form()
form.show()
app.exec_()
Example #37
0
File: main.py Project: jopohl/urh
def main():
    fix_windows_stdout_stderr()

    if sys.version_info < (3, 4):
        print("You need at least Python 3.4 for this application!")
        sys.exit(1)

    urh_exe = sys.executable if hasattr(sys, 'frozen') else sys.argv[0]
    urh_exe = os.readlink(urh_exe) if os.path.islink(urh_exe) else urh_exe

    urh_dir = os.path.join(os.path.dirname(os.path.realpath(urh_exe)), "..", "..")
    prefix = os.path.abspath(os.path.normpath(urh_dir))

    src_dir = os.path.join(prefix, "src")
    if os.path.exists(src_dir) and not prefix.startswith("/usr") and not re.match(r"(?i)c:\\program", prefix):
        # Started locally, not installed -> add directory to path
        sys.path.insert(0, src_dir)

    if len(sys.argv) > 1 and sys.argv[1] == "--version":
        import urh.version
        print(urh.version.VERSION)
        sys.exit(0)

    if GENERATE_UI and not hasattr(sys, 'frozen'):
        try:
            sys.path.insert(0, os.path.join(prefix))
            from data import generate_ui
            generate_ui.gen()
        except (ImportError, FileNotFoundError):
            # The generate UI script cannot be found so we are most likely in release mode, no problem here.
            pass

    from urh.util import util
    util.set_shared_library_path()

    try:
        import urh.cythonext.signal_functions
        import urh.cythonext.path_creator
        import urh.cythonext.util
    except ImportError:
        if hasattr(sys, "frozen"):
            print("C++ Extensions not found. Exiting...")
            sys.exit(1)
        print("Could not find C++ extensions, trying to build them.")
        old_dir = os.path.realpath(os.curdir)
        os.chdir(os.path.join(src_dir, "urh", "cythonext"))

        from urh.cythonext import build
        build.main()

        os.chdir(old_dir)

    from urh.controller.MainController import MainController
    from urh import constants

    if constants.SETTINGS.value("theme_index", 0, int) > 0:
        os.environ['QT_QPA_PLATFORMTHEME'] = 'fusion'

    app = QApplication(["URH"] + sys.argv[1:])
    app.setWindowIcon(QIcon(":/icons/icons/appicon.png"))

    util.set_icon_theme()

    font_size = constants.SETTINGS.value("font_size", 0, int)
    if font_size > 0:
        font = app.font()
        font.setPointSize(font_size)
        app.setFont(font)

    constants.SETTINGS.setValue("default_theme", app.style().objectName())

    if constants.SETTINGS.value("theme_index", 0, int) > 0:
        app.setStyle(QStyleFactory.create("Fusion"))

        if constants.SETTINGS.value("theme_index", 0, int) == 2:
            palette = QPalette()
            background_color = QColor(56, 60, 74)
            text_color = QColor(211, 218, 227).lighter()
            palette.setColor(QPalette.Window, background_color)
            palette.setColor(QPalette.WindowText, text_color)
            palette.setColor(QPalette.Base, background_color)
            palette.setColor(QPalette.AlternateBase, background_color)
            palette.setColor(QPalette.ToolTipBase, background_color)
            palette.setColor(QPalette.ToolTipText, text_color)
            palette.setColor(QPalette.Text, text_color)

            palette.setColor(QPalette.Button, background_color)
            palette.setColor(QPalette.ButtonText, text_color)

            palette.setColor(QPalette.BrightText, Qt.red)
            palette.setColor(QPalette.Disabled, QPalette.Text, Qt.darkGray)
            palette.setColor(QPalette.Disabled, QPalette.ButtonText, Qt.darkGray)

            palette.setColor(QPalette.Highlight, QColor(200, 50, 0))
            palette.setColor(QPalette.HighlightedText, text_color)
            app.setPalette(palette)

    # use system colors for painting
    widget = QWidget()
    bg_color = widget.palette().color(QPalette.Background)
    fg_color = widget.palette().color(QPalette.Foreground)
    selection_color = widget.palette().color(QPalette.Highlight)
    constants.BGCOLOR = bg_color
    constants.LINECOLOR = fg_color
    constants.SELECTION_COLOR = selection_color
    constants.SEND_INDICATOR_COLOR = selection_color

    main_window = MainController()
    # allow usage of prange (OpenMP) in Processes
    multiprocessing.set_start_method("spawn")

    if sys.platform == "darwin":
        menu_bar = main_window.menuBar()
        menu_bar.setNativeMenuBar(False)
    elif sys.platform == "win32":
        # Ensure we get the app icon in windows taskbar
        import ctypes
        ctypes.windll.shell32.SetCurrentProcessExplicitAppUserModelID("jopohl.urh")

    main_window.showMaximized()
    # main_window.setFixedSize(1920, 1080 - 30)  # Youtube

    if "autoclose" in sys.argv[1:]:
        # Autoclose after 1 second, this is useful for automated testing
        timer = QTimer()
        timer.timeout.connect(app.quit)
        timer.start(1000)

    return_code = app.exec_()
    app.closeAllWindows()
    os._exit(return_code)  # sys.exit() is not enough on Windows and will result in crash on exit
Example #38
0
        fpath, ftype = QFileDialog.getSaveFileName(
                self, 'Save the combine dataset to file', fpath, '*.csv')

        if fpath:
            self._workdir = os.path.dirname(fpath)
            data_merger.setDeleteInputFiles(
                    self._del_input_files_ckbox.isChecked())
            data_merger.save_to_csv(fpath)
            self.close()

    def show(self):
        super(WXDataMergerWidget, self).show()
        self.setFixedSize(self.size())


if __name__ == '__main__':                                   # pragma: no cover
    import platform
    import sys

    app = QApplication(sys.argv)

    if platform.system() == 'Windows':
        app.setFont(QFont('Segoe UI', 11))
    elif platform.system() == 'Linux':
        app.setFont(QFont('Ubuntu', 11))

    merger_widget = WXDataMergerWidget()
    merger_widget.show()

    sys.exit(app.exec_())
Example #39
0
    def __init__(self, *args, mode=None):
        QApplication.__init__(self, *args)

        # Log some basic system info
        try:
            v = openshot.GetVersion()
            log.info("openshot-qt version: %s" % info.VERSION)
            log.info("libopenshot version: %s" % v.ToString())
            log.info("platform: %s" % platform.platform())
            log.info("processor: %s" % platform.processor())
            log.info("machine: %s" % platform.machine())
            log.info("python version: %s" % platform.python_version())
            log.info("qt5 version: %s" % QT_VERSION_STR)
            log.info("pyqt5 version: %s" % PYQT_VERSION_STR)
        except:
            pass

        # Setup appication
        self.setApplicationName('openshot')
        self.setApplicationVersion(info.SETUP['version'])

        # Init settings
        self.settings = settings.SettingStore()
        try:
            self.settings.load()
        except Exception as ex:
            log.error("Couldn't load user settings. Exiting.\n{}".format(ex))
            exit()

        # Init translation system
        language.init_language()

        # Tests of project data loading/saving
        self.project = project_data.ProjectDataStore()

        # Init Update Manager
        self.updates = updates.UpdateManager()

        # It is important that the project is the first listener if the key gets update
        self.updates.add_listener(self.project)

        # Load ui theme if not set by OS
        ui_util.load_theme()

        # Start libopenshot logging thread
        self.logger_libopenshot = logger_libopenshot.LoggerLibOpenShot()
        self.logger_libopenshot.start()

        # Track which dockable window received a context menu
        self.context_menu_object = None

        # Set unique install id (if blank)
        if not self.settings.get("unique_install_id"):
            self.settings.set("unique_install_id", str(uuid4()))

            # Track 1st launch metric
            import classes.metrics
            classes.metrics.track_metric_screen("initial-launch-screen")

        # Set Font for any theme
        if self.settings.get("theme") != "No Theme":
            # Load embedded font
            try:
                log.info("Setting font to %s" % os.path.join(info.IMAGES_PATH, "fonts", "Ubuntu-R.ttf"))
                font_id = QFontDatabase.addApplicationFont(os.path.join(info.IMAGES_PATH, "fonts", "Ubuntu-R.ttf"))
                font_family = QFontDatabase.applicationFontFamilies(font_id)[0]
                font = QFont(font_family)
                font.setPointSizeF(10.5)
                QApplication.setFont(font)
            except Exception as ex:
                log.error("Error setting Ubuntu-R.ttf QFont: %s" % str(ex))

        # Set Experimental Dark Theme
        if self.settings.get("theme") == "Humanity: Dark":
            # Only set if dark theme selected
            log.info("Setting custom dark theme")
            self.setStyle(QStyleFactory.create("Fusion"))

            darkPalette = self.palette()
            darkPalette.setColor(QPalette.Window, QColor(53, 53, 53))
            darkPalette.setColor(QPalette.WindowText, Qt.white)
            darkPalette.setColor(QPalette.Base, QColor(25, 25, 25))
            darkPalette.setColor(QPalette.AlternateBase, QColor(53, 53, 53))
            darkPalette.setColor(QPalette.ToolTipBase, Qt.white)
            darkPalette.setColor(QPalette.ToolTipText, Qt.white)
            darkPalette.setColor(QPalette.Text, Qt.white)
            darkPalette.setColor(QPalette.Button, QColor(53, 53, 53))
            darkPalette.setColor(QPalette.ButtonText, Qt.white)
            darkPalette.setColor(QPalette.BrightText, Qt.red)
            darkPalette.setColor(QPalette.Highlight, QColor(42, 130, 218))
            darkPalette.setColor(QPalette.HighlightedText, Qt.black)
            darkPalette.setColor(QPalette.Disabled, QPalette.Text, QColor(104, 104, 104))
            self.setPalette(darkPalette)
            self.setStyleSheet("QToolTip { color: #ffffff; background-color: #2a82da; border: 0px solid white; }")

        # Create main window
        from windows.main_window import MainWindow
        self.window = MainWindow(mode)

        log.info('Process command-line arguments: %s' % args)
        if len(args[0]) == 2:
            path = args[0][1]
            if ".osp" in path:
                # Auto load project passed as argument
                self.window.open_project(path)
            else:
                # Auto import media file
                self.window.filesTreeView.add_file(path)

        # Reset undo/redo history
        self.updates.reset()
        self.window.updateStatusChanged(False, False)
Example #40
0
            cp = QDesktopWidget().availableGeometry().center()

        qr.moveCenter(cp)
        self.move(qr.topLeft())
        self.setMinimumSize(self.size())
        self.setFixedSize(self.size())


# %% if __name__ == '__main__'

if __name__ == '__main__':
    from projet.manager_data import DataManager
    from projet.reader_projet import ProjetReader
    app = QApplication(sys.argv)

    ft = app.font()
    ft.setFamily('Segoe UI')
    ft.setPointSize(11)
    app.setFont(ft)

    pf = 'C:/Users/jsgosselin/GWHAT/Projects/Example/Example.gwt'
    pr = ProjetReader(pf)
    dm = DataManager()
    dm.set_projet(pr)

    Hydroprint = HydroprintGUI(dm)
    Hydroprint.show()
    Hydroprint.wldset_changed()

    sys.exit(app.exec_())
Example #41
0
    def __init__(self, *args, mode=None):
        QApplication.__init__(self, *args)

        # Log some basic system info
        try:
            v = openshot.GetVersion()
            log.info("openshot-qt version: %s" % info.VERSION)
            log.info("libopenshot version: %s" % v.ToString())
            log.info("platform: %s" % platform.platform())
            log.info("processor: %s" % platform.processor())
            log.info("machine: %s" % platform.machine())
            log.info("python version: %s" % platform.python_version())
            log.info("qt5 version: %s" % QT_VERSION_STR)
            log.info("pyqt5 version: %s" % PYQT_VERSION_STR)
        except:
            pass

        # Setup application
        self.setApplicationName('openshot')
        self.setApplicationVersion(info.SETUP['version'])

        # Init settings
        self.settings = settings.SettingStore()
        self.settings.load()

        # Init and attach exception handler
        from classes import exceptions
        sys.excepthook = exceptions.ExceptionHandler

        # Init translation system
        language.init_language()

        # Detect minimum libopenshot version
        _ = self._tr
        libopenshot_version = openshot.GetVersion().ToString()
        if mode != "unittest" and libopenshot_version < info.MINIMUM_LIBOPENSHOT_VERSION:
            QMessageBox.warning(None, _("Wrong Version of libopenshot Detected"),
                                      _("<b>Version %(minimum_version)s is required</b>, but %(current_version)s was detected. Please update libopenshot or download our latest installer.") %
                                {"minimum_version": info.MINIMUM_LIBOPENSHOT_VERSION, "current_version": libopenshot_version})
            # Stop launching and exit
            sys.exit()

        # Tests of project data loading/saving
        self.project = project_data.ProjectDataStore()

        # Init Update Manager
        self.updates = updates.UpdateManager()

        # It is important that the project is the first listener if the key gets update
        self.updates.add_listener(self.project)

        # Load ui theme if not set by OS
        ui_util.load_theme()

        # Start libopenshot logging thread
        self.logger_libopenshot = logger_libopenshot.LoggerLibOpenShot()
        self.logger_libopenshot.start()

        # Track which dockable window received a context menu
        self.context_menu_object = None

        # Set Font for any theme
        if self.settings.get("theme") != "No Theme":
            # Load embedded font
            try:
                log.info("Setting font to %s" % os.path.join(info.IMAGES_PATH, "fonts", "Ubuntu-R.ttf"))
                font_id = QFontDatabase.addApplicationFont(os.path.join(info.IMAGES_PATH, "fonts", "Ubuntu-R.ttf"))
                font_family = QFontDatabase.applicationFontFamilies(font_id)[0]
                font = QFont(font_family)
                font.setPointSizeF(10.5)
                QApplication.setFont(font)
            except Exception as ex:
                log.error("Error setting Ubuntu-R.ttf QFont: %s" % str(ex))

        # Set Experimental Dark Theme
        if self.settings.get("theme") == "Humanity: Dark":
            # Only set if dark theme selected
            log.info("Setting custom dark theme")
            self.setStyle(QStyleFactory.create("Fusion"))

            darkPalette = self.palette()
            darkPalette.setColor(QPalette.Window, QColor(53, 53, 53))
            darkPalette.setColor(QPalette.WindowText, Qt.white)
            darkPalette.setColor(QPalette.Base, QColor(25, 25, 25))
            darkPalette.setColor(QPalette.AlternateBase, QColor(53, 53, 53))
            darkPalette.setColor(QPalette.ToolTipBase, Qt.white)
            darkPalette.setColor(QPalette.ToolTipText, Qt.white)
            darkPalette.setColor(QPalette.Text, Qt.white)
            darkPalette.setColor(QPalette.Button, QColor(53, 53, 53))
            darkPalette.setColor(QPalette.ButtonText, Qt.white)
            darkPalette.setColor(QPalette.BrightText, Qt.red)
            darkPalette.setColor(QPalette.Highlight, QColor(42, 130, 218))
            darkPalette.setColor(QPalette.HighlightedText, Qt.black)
            darkPalette.setColor(QPalette.Disabled, QPalette.Text, QColor(104, 104, 104))
            self.setPalette(darkPalette)
            self.setStyleSheet("QToolTip { color: #ffffff; background-color: #2a82da; border: 0px solid white; }")

        # Create main window
        from windows.main_window import MainWindow
        self.window = MainWindow(mode)

        # Reset undo/redo history
        self.updates.reset()
        self.window.updateStatusChanged(False, False)

        log.info('Process command-line arguments: %s' % args)
        if len(args[0]) == 2:
            path = args[0][1]
            if ".osp" in path:
                # Auto load project passed as argument
                self.window.OpenProjectSignal.emit(path)
            else:
                # Auto import media file
                self.window.filesTreeView.add_file(path)
        else:
            # Recover backup file (this can't happen until after the Main Window has completely loaded)
            self.window.RecoverBackup.emit()
Example #42
0
    def __init__(self, *args):
        QApplication.__init__(self, *args)

        # Setup appication
        self.setApplicationName('openshot')
        self.setApplicationVersion(info.SETUP['version'])

        # Init settings
        self.settings = settings.SettingStore()
        try:
            self.settings.load()
        except Exception as ex:
            log.error("Couldn't load user settings. Exiting.\n{}".format(ex))
            exit()

        # Init translation system
        language.init_language()

        # Tests of project data loading/saving
        self.project = project_data.ProjectDataStore()

        # Init Update Manager
        self.updates = updates.UpdateManager()

        # It is important that the project is the first listener if the key gets update
        self.updates.add_listener(self.project)

        # Load ui theme if not set by OS
        ui_util.load_theme()

        # Track which dockable window received a context menu
        self.context_menu_object = None

        # Set Font for any theme
        if self.settings.get("theme") != "No Theme":
            # Load embedded font
            log.info("Setting font to %s" % os.path.join(info.IMAGES_PATH, "fonts", "Ubuntu-R.ttf"))
            font_id = QFontDatabase.addApplicationFont(os.path.join(info.IMAGES_PATH, "fonts", "Ubuntu-R.ttf"))
            font_family = QFontDatabase.applicationFontFamilies(font_id)[0]
            font = QFont(font_family)
            font.setPointSizeF(10.5)
            QApplication.setFont(font)

        # Set Experimental Dark Theme
        if self.settings.get("theme") == "Humanity: Dark":
            # Only set if dark theme selected
            log.info("Setting custom dark theme")
            self.setStyle(QStyleFactory.create("Fusion"))

            darkPalette = self.palette()
            darkPalette.setColor(QPalette.Window, QColor(53, 53, 53))
            darkPalette.setColor(QPalette.WindowText, Qt.white)
            darkPalette.setColor(QPalette.Base, QColor(25, 25, 25))
            darkPalette.setColor(QPalette.AlternateBase, QColor(53, 53, 53))
            darkPalette.setColor(QPalette.ToolTipBase, Qt.white)
            darkPalette.setColor(QPalette.ToolTipText, Qt.white)
            darkPalette.setColor(QPalette.Text, Qt.white)
            darkPalette.setColor(QPalette.Button, QColor(53, 53, 53))
            darkPalette.setColor(QPalette.ButtonText, Qt.white)
            darkPalette.setColor(QPalette.BrightText, Qt.red)
            darkPalette.setColor(QPalette.Highlight, QColor(42, 130, 218))
            darkPalette.setColor(QPalette.HighlightedText, Qt.black)
            self.setPalette(darkPalette)
            self.setStyleSheet("QToolTip { color: #ffffff; background-color: #2a82da; border: 0px solid white; }")

        # Create main window
        from windows.main_window import MainWindow
        self.window = MainWindow()
        self.window.show()

        # Load new/blank project (which sets default profile)
        self.project.load("")

        log.info('Process command-line arguments: %s' % args)
        if len(args[0]) == 2:
            path = args[0][1]
            if ".osp" in path:
                # Auto load project passed as argument
                self.window.open_project(path)
            else:
                # Auto import media file
                self.window.filesTreeView.add_file(path)
Example #43
0
# !/usr/bin/env python3
# -*- coding: utf-8 -*-


import sys
from PyQt5.QtWidgets import QApplication
from app.ui.main_window import MainWindow

from app.ui.icon_rc import *

__author__ = 'InG_byr'

if __name__ == '__main__':
    app = QApplication(sys.argv)
    font = app.font()
    font.setPointSize(11)
    app.setFont(font)
    ui = MainWindow()
    ui.main_window.show()
    sys.exit(app.exec_())
Example #44
0
def prepare(tests=False):
    app = QApplication(sys.argv)
    app.setOrganizationName("manuskript"+("_tests" if tests else ""))
    app.setOrganizationDomain("www.theologeek.ch")
    app.setApplicationName("manuskript"+("_tests" if tests else ""))
    app.setApplicationVersion(getVersion())

    print("Running manuskript version {}.".format(getVersion()))
    icon = QIcon()
    for i in [16, 32, 64, 128, 256, 512]:
        icon.addFile(appPath("icons/Manuskript/icon-{}px.png".format(i)))
    qApp.setWindowIcon(icon)

    app.setStyle("Fusion")

    # Load style from QSettings
    settings = QSettings(app.organizationName(), app.applicationName())
    if settings.contains("applicationStyle"):
        style = settings.value("applicationStyle")
        app.setStyle(style)

    # Translation process
    locale = QLocale.system().name()

    appTranslator = QTranslator(app)
    # By default: locale

    def extractLocale(filename):
        # len("manuskript_") = 13, len(".qm") = 3
        return filename[11:-3] if len(filename) >= 16 else ""

    def tryLoadTranslation(translation, source):
        if appTranslator.load(appPath(os.path.join("i18n", translation))):
            app.installTranslator(appTranslator)
            print(app.tr("Loaded translation from {}: {}.").format(source, translation))
            return True
        else:
            print(app.tr("Note: No translator found or loaded from {} for locale {}.").
                  format(source, extractLocale(translation)))
            return False

    # Load translation from settings
    translation = ""
    if settings.contains("applicationTranslation"):
        translation = settings.value("applicationTranslation")
        print("Found translation in settings:", translation)

    if (translation != "" and not tryLoadTranslation(translation, "settings")) or translation == "":
        # load from settings failed or not set, fallback
        translation = "manuskript_{}.qm".format(locale)
        tryLoadTranslation(translation, "system locale")

    QIcon.setThemeSearchPaths(QIcon.themeSearchPaths() + [appPath("icons")])
    QIcon.setThemeName("NumixMsk")

    # Font siue
    if settings.contains("appFontSize"):
        f = qApp.font()
        f.setPointSize(settings.value("appFontSize", type=int))
        app.setFont(f)

    # Main window
    from manuskript.mainWindow import MainWindow

    MW = MainWindow()
    # We store the system default cursor flash time to be able to restore it
    # later if necessary
    MW._defaultCursorFlashTime = qApp.cursorFlashTime()

    # Command line project
    if len(sys.argv) > 1 and sys.argv[1][-4:] == ".msk":
        if os.path.exists(sys.argv[1]):
            path = os.path.abspath(sys.argv[1])
            MW._autoLoadProject = path

    return app, MW