コード例 #1
0
class SplashScreen:
    def __init__(self, parent, image=None, after=None):
        self.app = parent
        image = QPixmap(image)
        image = image.scaled(500, 500, Qt.KeepAspectRatio,
                             Qt.SmoothTransformation)
        self.splash = QSplashScreen(
            image, Qt.FramelessWindowHint | Qt.WindowStaysOnTopHint)
        self.splash.setMask(image.mask())
        self.after = after

    def set_after(self, after):
        self.after = after

    def __enter__(self):
        self.splash.show()
        self.app.processEvents()
        return self

    def __exit__(self, exc_type, exc_value, traceback):
        self.after.show()
        self.splash.finish(self.after)

    def status_update(self, msg):
        self.splash.showMessage(msg,
                                alignment=Qt.AlignHCenter,
                                color=QColor(235, 239, 242))
        self.app.processEvents()
コード例 #2
0
def main():

    if sys.version_info < REQUIRED_PYTHON_VERSION:
        raise SystemExit("Python {}.{} or higher is required".format(
            REQUIRED_PYTHON_VERSION[0], REQUIRED_PYTHON_VERSION[1]))

#   QApplication.setAttribute(Qt.AA_ShareOpenGLContexts)
    app = Application(sys.argv)
    loop = quamash.QEventLoop(app)
    asyncio.set_event_loop(loop)

    pixmap = QPixmap('OptoStimLogo.jpeg')
    splash = QSplashScreen(pixmap)
    splash.show()

    w = OptoStimMainWindow()
    w.show()

    splash.finish(w)

    hook = ExceptHook(sentry_key=SENTRY_KEY,
                      non_exit_exceptions=[DeviceException, OptoStimException])

    sys.excepthook = hook.except_hook

    signal.signal(signal.SIGINT, w.clean_up)
    signal.signal(signal.SIGTERM, w.clean_up)

    try:
        with loop:
            sys.exit(loop.run_forever())
    finally:
        w.clean_up()
コード例 #3
0
def main():
    import time
    os.chdir(civiltools_path)
    app = QtWidgets.QApplication(sys.argv)
    splash_pix = QPixmap("./images/civil-engineering.jpg")
    splash = QSplashScreen(splash_pix, Qt.WindowStaysOnTopHint)
    splash.setWindowFlags(Qt.WindowStaysOnTopHint | Qt.FramelessWindowHint)
    splash.setEnabled(False)
    # adding progress bar
    progressBar = QProgressBar(splash)
    progressBar.setMaximum(10)
    progressBar.setGeometry(50, splash_pix.height() - 30, splash_pix.width() - 100, 20)

    splash.show()
    splash.showMessage("<h1><font color='DarkRed'>civiltools by Ebrahim Raeyat Roknabadi </font></h1>", Qt.AlignCenter | Qt.AlignCenter, Qt.black)

    for i in range(1, 11):
        progressBar.setValue(i)
        t = time.time()
        while time.time() < t + 0.1:
            app.processEvents()

    # Simulate something that takes time
    time.sleep(1)
    # translator = QtCore.QTranslator()
    # translator.load("main_form.qm")
    # app.installTranslator(translator)
    window = FormWidget()
    window.setWindowTitle(_appname + ' ' + _version)
    window.show()
    splash.finish(window)
    sys.exit(app.exec_())
コード例 #4
0
def run():

    app = QApplication(sys.argv)
    app.setWindowIcon(QIcon(':/icons/windows/deeplisten-logo.png'))

    # splash screen
    # Create and display the splash screen
    splash_pix = QPixmap(':/icons/windows/start.png')
    splash = QSplashScreen(splash_pix, Qt.WindowStaysOnTopHint)
    splash.setMask(splash_pix.mask())
    splash.show()
    app.processEvents()

    # Simulate something that takes time
    time.sleep(1)

    mw = MainWindow()
    mw.show()
    splash.finish(mw)

    ##setup stylesheet
    # import qdarkstyle
    # app.setStyleSheet(qdarkstyle.load_stylesheet_pyqt5())

    sys.exit(app.exec_())
コード例 #5
0
ファイル: tmain.py プロジェクト: robertoweller/estudos-python
def init():
    """
    Init gui.
    Concat all files from style directory and apply stylesheet.
    Run `bootstrap_function` to prepare app.
    """
    app = QApplication(sys.argv)
    app.setWindowIcon(QIcon('splash.png'))
    splash_img = QPixmap('splash.png')
    splash = QSplashScreen(splash_img)
    splash.show()
    app.processEvents()

    # items = bootstrap_function()
    items = ''

    style = []
    style_dir = 'style'
    for f in os.listdir(style_dir):
        if not f.endswith('.qss'):
            continue
        with open(os.path.join(style_dir, f), 'r') as qss:
            style.append(qss.read())
    app.setStyleSheet('\n'.join(style))

    mw = MainWindow(items)
    splash.finish(mw)

    sys.excepthook = mw.excepthook
    sys.exit(app.exec_())
コード例 #6
0
ファイル: MainWindow.py プロジェクト: ehbaker/fort-pymdwizard
def launch_main(xml_fname=None, introspect_fname=None):
    app = QApplication(sys.argv)

    import time
    start = time.time()
    splash_fname = utils.get_resource_path('icons/splash.jpg')
    splash_pix = QPixmap(splash_fname)

    size = splash_pix.size()*.35
    splash_pix = splash_pix.scaled(size, Qt.KeepAspectRatio,
                                transformMode=Qt.SmoothTransformation)

    # # below makes the pixmap half transparent
    painter = QPainter(splash_pix)
    painter.setCompositionMode(painter.CompositionMode_DestinationAtop)
    painter.end()

    splash = QSplashScreen(splash_pix, Qt.WindowStaysOnTopHint)
    splash.show()
    app.processEvents()
    time.sleep(2)

    app.processEvents()
    mdwiz = PyMdWizardMainForm()
    mdwiz.show()
    splash.finish(mdwiz)

    if xml_fname is not None and os.path.exists(xml_fname):
        mdwiz.open_file(xml_fname)

    if introspect_fname is not None and os.path.exists(introspect_fname):
        mdwiz.metadata_root.eainfo.detaileds[0].populate_from_fname(introspect_fname)
        mdwiz.metadata_root.eainfo.ui.fgdc_eainfo.setCurrentIndex(1)
    app.exec_()
コード例 #7
0
ファイル: main.py プロジェクト: aq1/Hospital-Helper-2
def init(bootstrap_function):
    """
    Init gui.
    Concat all files from style directory and apply stylesheet.
    Run `bootstrap_function` to prepare app.
    """
    app = QApplication(sys.argv)
    app.setWindowIcon(QIcon(os.path.join(options.STATIC_DIR, 'splash.png')))
    splash_img = QPixmap(os.path.join(options.STATIC_DIR, 'splash.png'))
    splash = QSplashScreen(splash_img)
    splash.show()
    app.processEvents()

    items = bootstrap_function()

    style = []
    style_dir = os.path.join(options.STATIC_DIR, 'style')
    for f in os.listdir(style_dir):
        if not f.endswith('.qss'):
            continue
        with open(os.path.join(style_dir, f), 'r') as qss:
            style.append(qss.read())
    app.setStyleSheet('\n'.join(style))

    mw = MainWindow(items)
    splash.finish(mw)
    sys.exit(app.exec_())
コード例 #8
0
ファイル: pdgui.py プロジェクト: parkerwray/PDielec
def main(sys):
    app = QApplication(sys.argv)
    show_splash = True
    for token in sys.argv:
        if token == '-nosplash' or token == '--nosplash':
            show_splash = False
        elif token == '-h' or token == '-help' or token == '--help':
            print('pdgui - graphical user interface to the PDielec package')
            print('pdgui [-help] [-debug] [program] [filename] [spreadsheet] [-script scriptname] [-nosplash] [-exit]')
            exit()

    if show_splash:
        dirname = os.path.dirname(os.path.realpath(sys.argv[0]))
        splashfile = os.path.join(dirname, 'Python/GUI/splash.png')
        pixmap = QPixmap(splashfile)
        splash = QSplashScreen(pixmap)
        progressbar = QProgressBar(splash)
        splash.show()
    else:
        progressbar = QProgressBar()
        progressbar = None
    ex = App(sys.argv, progressbar)
    ex.show()
    if show_splash:
        splash.finish(ex)
    sys.exit(app.exec_())
コード例 #9
0
ファイル: app.py プロジェクト: Cloudmage/mu
def run():
    """
    Creates all the top-level assets for the application, sets things up and
    then runs the application.
    """
    setup_logging()
    logging.info('Starting Mu {}'.format(__version__))
    # The app object is the application running on your computer.
    app = QApplication(sys.argv)
    # Display a friendly "splash" icon.
    splash = QSplashScreen(load_pixmap('icon'))
    splash.show()
    # Create the "window" we'll be looking at.
    editor_window = Window()
    # Create the "editor" that'll control the "window".
    editor = Editor(view=editor_window)
    # Setup the window.
    editor_window.closeEvent = editor.quit
    editor_window.setup(editor.theme)
    editor.restore_session()
    # Connect the various buttons in the window to the editor.
    button_bar = editor_window.button_bar
    button_bar.connect("new", editor.new, "Ctrl+N")
    button_bar.connect("load", editor.load, "Ctrl+O")
    button_bar.connect("save", editor.save, "Ctrl+S")
    button_bar.connect("flash", editor.flash)
    button_bar.connect("repl", editor.toggle_repl)
    button_bar.connect("zoom-in", editor.zoom_in)
    button_bar.connect("zoom-out", editor.zoom_out)
    button_bar.connect("theme", editor.toggle_theme)
    button_bar.connect("quit", editor.quit)
    # Finished starting up the application, so hide the splash icon.
    splash.finish(editor_window)
    # Stop the program after the application finishes executing.
    sys.exit(app.exec_())
コード例 #10
0
ファイル: Hitagi.py プロジェクト: gimu/hitagi-reader.py
def run(image_path = None):
    # Global exceptions
    sys.excepthook = excepthook

    app = QApplication(sys.argv) 

    # Splash screen
    splash_pix = QPixmap('resources/splash.jpg')
    splash = QSplashScreen(splash_pix)
    splash.setMask(splash_pix.mask())
    splash.show()
    
    app.processEvents()
    
    # Load translation
    locale_code = SettingsModel().get('Language', 'code')
    if locale_code != "en_US": # Standard language
        # Standard translator for the generated GUI
        translator = QTranslator()
        translator.load('localization/' + locale_code + '.qm')
        app.installTranslator(translator)

        # Translator for various GUI elements
        translator_2 = QTranslator()
        translator_2.load('localization/' + locale_code + '_2.qm')
        app.installTranslator(translator_2)

    # Start
    m = Hitagi(image_path) # Pass image path
    
    splash.finish(m)
    sys.exit(app.exec())
コード例 #11
0
ファイル: app.py プロジェクト: kushaldas/mu
def run():
    """
    Creates all the top-level assets for the application, sets things up and
    then runs the application.
    """
    # The app object is the application running on your computer.
    app = QApplication(sys.argv)
    # Display a friendly "splash" icon.
    splash = QSplashScreen(load_pixmap('icon'))
    splash.show()
    # Create the "window" we'll be looking at.
    editor_window = Window()
    # Create the "editor" that'll control the "window".
    editor = Editor(view=editor_window)
    # Setup the window.
    editor_window.closeEvent = editor.quit
    editor_window.setup(editor.theme)
    editor.restore_session()
    # Connect the various buttons in the window to the editor.
    button_bar = editor_window.button_bar
    button_bar.connect("new", editor.new, "Ctrl+N")
    button_bar.connect("load", editor.load, "Ctrl+O")
    button_bar.connect("save", editor.save, "Ctrl+S")
    button_bar.connect("flash", editor.flash)
    button_bar.connect("repl", editor.toggle_repl)
    button_bar.connect("zoom-in", editor.zoom_in)
    button_bar.connect("zoom-out", editor.zoom_out)
    button_bar.connect("theme", editor.toggle_theme)
    button_bar.connect("quit", editor.quit)
    # Finished starting up the application, so hide the splash icon.
    splash.finish(editor_window)
    # Stop the program after the application finishes executing.
    sys.exit(app.exec_())
コード例 #12
0
ファイル: iocontrol.py プロジェクト: linux4sam/iocontrol
def main():
    signal(SIGINT, SIG_DFL)
    app = QApplication(sys.argv)
    sys.excepthook = excepthook

    splash_pix = QPixmap(path.join(path.dirname(__file__), 'loading.png'))
    splash = QSplashScreen(splash_pix)
    splash.show()
    splash.raise_()
    app.processEvents()

    with open(path.join(path.dirname(__file__), "style.qss"), 'r') as f:
        app.setStyleSheet(f.read())

    win = MainWindow()

    from argparse import ArgumentParser
    parser = ArgumentParser(description='Microchip Peripheral I/O Control')
    parser.add_argument('--fullscreen', dest='fullscreen', action='store_true',
                        help='show the main window in fullscreen')
    parser.set_defaults(fullscreen=False)

    # ignore unknown arguments, necessary for ignoring only -smallresolution
    args, unknown = parser.parse_known_args()

    if args.fullscreen:
        win.setFixedSize(QApplication.desktop().size())
        win.showFullScreen()
    else:
        win.show()
    win.setFocus()

    splash.finish(win)
    sys.exit(app.exec_())
コード例 #13
0
    def openDialog(self):

        # Only single instance of Plugin
        if self.exists == True: return
        else: self.exists = True

        self.resources = Resources(self.plugin_dir)
        self.dlg = PlanHeatDMMDialog(self)
        self.data = Data(plugin=False)

        splash = QSplashScreen(
            QtGui.QPixmap(self.plugin_dir + os.path.sep +
                          'resources/PlanHeatPrincipal.png'),
            QtCore.Qt.WindowStaysOnTopHint)
        splash.setWindowFlags(QtCore.Qt.WindowStaysOnTopHint
                              | QtCore.Qt.FramelessWindowHint)
        splash.setEnabled(False)
        splash.show()

        # Run the dialog event loop
        self.run()
        splash.finish(self.dlg)
        self.dlg.show()

        result = self.dlg.exec_()

        self.exists = False

        # See if OK was pressed
        if result:
            # Do something useful here
            pass
        else:
            pass
コード例 #14
0
def main():
    # define command line parameters
    parser = ArgumentParser()
    parser.add_argument("--no-splash", dest="splash", action="store_false")
    args = parser.parse_args()

    app = QApplication(sys.argv)

    # create splash screen with sponsors
    # default splash=True, use "-s" or "--splash" to set splash=False
    window = MainWindow()
    if args.splash:
        pixmap = QPixmap(os.path.join("resources","splash", "splash.jpg"))
        splash = QSplashScreen(pixmap)
        splash.showMessage("  Version: " + __version__, Qt.AlignBottom)

        # show the splash screen for 3 seconds
        splash.show()
        app.processEvents()
        QThread.sleep(3)
        window.show()
        splash.finish(window)
    else:
        window.show()

    sys.exit(app.exec())
コード例 #15
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_())
コード例 #16
0
class MainWindow(QMainWindow):
    def __init__(self, irises, settings, parent=None, chan=None, **kwargs):
        QMainWindow.__init__(self, parent)
        self._splash = QSplashScreen(self, QPixmap('data/logo.tif'))
        self._splash.show()
        self.setAttribute(Qt.WA_DeleteOnClose)
        self.setWindowTitle("CBRS Array Monitor")
        self.setMinimumSize(800, 600)
        self._settings = settings

        self.addDockWidget(
            Qt.TopDockWidgetArea,
            TopLevelControlPanel(irises=irises, settings=settings,
                                 parent=self))

        #start the window
        self.setCentralWidget(
            MainStatusWindow(irises=irises, parent=self, chan=chan))

        #load previous settings
        print("Loading %s" % self._settings.fileName())
        if self._settings.contains("MainWindow/geometry"):
            self.restoreGeometry(self._settings.value("MainWindow/geometry"))
        if self._settings.contains("MainWindow/state"):
            self.restoreState(self._settings.value("MainWindow/state"))

        #load complete
        self._splash.finish(self)

    def closeEvent(self, event):

        #stash settings
        self._settings.setValue("MainWindow/geometry", self.saveGeometry())
        self._settings.setValue("MainWindow/state", self.saveState())
コード例 #17
0
ファイル: __main__.py プロジェクト: dpgeorge/puppy
def main():
    # The app object is the application running on your computer.
    app = QApplication(sys.argv)
    app.setStyleSheet(load_stylesheet('puppy.css'))

    # A splash screen is a logo that appears when you start up the application.
    # The image to be "splashed" on your screen is in the resources/images
    # directory.
    splash = QSplashScreen(load_pixmap('splash'))
    # Show the splash.
    splash.show()

    # Make the editor with the Puppy class defined above.
    the_editor = Puppy()

    proj_root = os.path.join(ROOT, 'hello_world')
    proj = HelloWorld(proj_root, {})
    if not os.path.isdir(proj_root):
        proj.init_files()
    the_editor.add_project(proj)

    the_editor.show()
    the_editor.autosize_window()

    # Remove the splash when the_editor has finished setting itself up.
    splash.finish(the_editor)

    # Stop the program after application finishes executing.
    sys.exit(app.exec_())
コード例 #18
0
def main():
    QtWidgets.QApplication.setAttribute(Qt.AA_EnableHighDpiScaling,
                                        True)  # enable highdpi scaling
    Qt.HighDpiScaleFactorRoundingPolicy.Round
    scaleFactor = ctypes.windll.shcore.GetScaleFactorForDevice(0) / 100
    if scaleFactor >= 1.5:
        os.environ["QT_SCREEN_SCALE_FACTORS"] = "1.5"
    else:
        os.environ[
            "QT_SCREEN_SCALE_FACTORS"] = "scaleFactor"  # das ist der richtige Skalierungsfaktor
    #os.environ["QT_AUTO_SCREEN_SCALE_FACTOR"] = "-1"
    #QT_SCREEN_SCALE_FACTORS
    #os.environ["QT_SCALE_FACTOR"] = "1.4"
    #os.environ["QT_DEVICE_PIXEL_RATIO"] = "0.5"
    app = QApplication(sys.argv)
    pixmap = QPixmap(os.path.dirname(sys.argv[0]) + "/pics/splesh.JPG")
    splash = QSplashScreen(pixmap)
    splash.show()
    splash.showMessage("Module werden geladen...")
    app.processEvents()
    app.setStyle("Fusion")
    time.sleep(3)
    window11 = myTab5.myTab5()
    #window11.setFixedSize(1100, 600)
    #window11.resize(window11.minimumSizeHint())
    splash.finish(window11)
    showForUpdates(version, "https://digital-ies.de/wp-content/uploads", app,
                   window11)
    app.exec_()
コード例 #19
0
class MainWindow(QMainWindow):
    def __init__(self, settings, parent=None, **kwargs):
        QMainWindow.__init__(self, parent)
        self._splash = QSplashScreen(self, QPixmap('data/logo.tif'))
        self._splash.show()
        self.setAttribute(Qt.WA_DeleteOnClose)
        self.setWindowTitle("Iris Snooper GUI - %s" %
                            kwargs['handle']['label'])
        self.setMinimumSize(800, 600)
        self._settings = settings

        #load previous settings
        print("Loading %s" % self._settings.fileName())
        if self._settings.contains("MainWindow/geometry"):
            self.restoreGeometry(self._settings.value("MainWindow/geometry"))
        if self._settings.contains("MainWindow/state"):
            self.restoreState(self._settings.value("MainWindow/state"))

        #start the window
        self._plotters = PlotterWidgets(parent=self, **kwargs)
        self.setCentralWidget(self._plotters)

        #load complete
        self._splash.finish(self)

    def closeEvent(self, event):

        #stash settings
        self._settings.setValue("MainWindow/geometry", self.saveGeometry())
        self._settings.setValue("MainWindow/state", self.saveState())

        self._plotters.closeEvent(event)
コード例 #20
0
ファイル: __init__.py プロジェクト: vistamou/lxa5
def main():
    app = QApplication(sys.argv)
    app.setStyle('cleanlooks')
    app.setApplicationName("Linguistica")

    # Get screen resolution
    # Why do we need to know screen resolution?
    # Because this information is useful for setting the size of particular
    # widgets, e.g., the webview for visualizing the word neighbor manifold
    # (the bigger the webview size, the better it is for visualization!)
    resolution = app.desktop().screenGeometry()
    screen_width = resolution.width()
    screen_height = resolution.height()

    # create and display splash screen
    splash_image_path = os.path.join(os.path.dirname(__file__),
                                     'lxa_splash_screen.png')
    splash_image = QPixmap(splash_image_path)
    splash_screen = QSplashScreen(splash_image, Qt.WindowStaysOnTopHint)
    splash_screen.setMask(splash_image.mask())
    splash_screen.show()
    app.processEvents()
    time.sleep(2)

    # launch graphical user interface
    form = MainWindow(screen_height, screen_width, __version__)
    form.show()
    splash_screen.finish(form)
    app.exec_()
コード例 #21
0
ファイル: demo.py プロジェクト: ivanchenph/Karken-KMB
def demo_run():
    app = QApplication(sys.argv)
    # get screen size.
    desktop = QApplication.desktop().screenGeometry()
    ratio = QApplication.desktop().screen().devicePixelRatio()
    width = desktop.width()
    height = desktop.height()
    # setting up welcome screen.
    screen = QPixmap(icon["SCREEN"])
    screen.setDevicePixelRatio(ratio)
    if ratio == 2:
        # under Mac Retina
        screen = screen.scaled(height * 0.9, height * 0.9)
    else:
        # under Windows and Linux
        screen = screen.scaled(height * 0.5, height * 0.5)
    splash = QSplashScreen(screen)
    splash.show()
    # handle the main process event.
    qApp.processEvents()
    # setting up main window.
    size = (width * 0.8, height * 0.8)
    editor = KMBMainWindow(size)
    stylesheet = load_stylesheet(SS_COMMON)
    app.setStyleSheet(stylesheet)
    # Mac: set the icon in dock.
    app.setWindowIcon(editor.win_icon)
    # compatible with Mac Retina screen.
    app.setAttribute(Qt.AA_UseHighDpiPixmaps, True)
    app.setAttribute(Qt.AA_EnableHighDpiScaling, True)
    # editor show up
    editor.show()
    splash.finish(editor)
    sys.exit(app.exec_())
コード例 #22
0
    def run(self):
        """Run method that performs all the real work"""
        try:
            # locale.setlocale(locale.LC_ALL, 'en-GB')
            # Only single instance of Plugin
            if self.exists == True:
                return
            else:
                self.exists = True

            self.dlg = PlanHeatDMMDialog(self)
            self.resources = Resources(self.plugin_dir)
            self.data = Data(plugin=True)

            # Name of project
            self.data.projectName = master_mapping_config.CURRENT_PROJECT_NAME

            # Redirection
            dmm_folder = os.path.join(master_mapping_config.CURRENT_MAPPING_DIRECTORY,
                                                    master_mapping_config.DMM_FOLDER)
            os.makedirs(dmm_folder, exist_ok=True)
            self.data.outputSaveFile = os.path.join(dmm_folder, master_mapping_config.DMM_PREFIX)


            splash = QSplashScreen(QtGui.QPixmap(self.plugin_dir + os.path.sep + 'resources/PlanHeatPrincipal.png'), QtCore.Qt.WindowStaysOnTopHint)
            splash.setWindowFlags(QtCore.Qt.WindowStaysOnTopHint | QtCore.Qt.FramelessWindowHint)
            splash.setEnabled(False)
            splash.show()

            # Run the dialog event loop
            initWindowStatus(self)
            self.resources.loadAppResources()
            initWindowbehavior(self)

            # Deserialize the module
            DMMSerializer.deserialize(self)

            splash.finish(self.dlg)

            # show the dialog
            self.dlg.show()

            # Run the dialog event loop
            result = self.dlg.exec_()

            self.exists = False

            # See if OK was pressed
            if result:
                # Do something useful here -
                pass
            else:
                pass



        except Exception as e:
            self.exists = False
            print(str(e))
コード例 #23
0
def main(args=None):

    # supply path to qgis install location
    QgsApplication.setPrefixPath("/usr", True)

    # create a reference to the QgsApplication
    # setting the second argument to True enables the IquaView GUI,
    # which we need to do since this is a custom application
    qgs = QgsApplication([], True)

    # init splash screen
    splash_pix = QPixmap(':/resources/iquaview.png')
    splash = QSplashScreen(splash_pix, Qt.WindowStaysOnTopHint)
    splash.setMask(splash_pix.mask())

    light_blue = QColor(165, 197, 192)
    dark_blue = QColor(11, 52, 70)
    # adding progress bar
    progress_bar = QProgressBar(splash)
    p = progress_bar.palette()
    p.setColor(QPalette.Highlight, light_blue)
    p.setColor(QPalette.HighlightedText, dark_blue)
    progress_bar.setPalette(p)
    progress_bar.setMaximum(10)
    progress_bar.setGeometry(0,
                             splash_pix.height() - 50, splash_pix.width(), 20)

    splash.show()
    splash.showMessage("Initializing interface...",
                       Qt.AlignBottom | Qt.AlignCenter, light_blue)

    # progress bar...
    for i in range(1, 11):
        progress_bar.setValue(i)
        t = time()
        if i == 5:
            splash.showMessage("Loading providers...",
                               Qt.AlignBottom | Qt.AlignCenter, light_blue)
            # load providers
            qgs.initQgis()
            LOGGER.info(qgs.showSettings())
        if i == 10:
            # exec iquaview window
            window = MainWindow()
            window.setWindowIcon(QIcon(":/resources/iquaview_vector.svg"))
            splash.showMessage("IQUAview ready!",
                               Qt.AlignBottom | Qt.AlignCenter, light_blue)

        while time() < t + 0.1:
            qgs.processEvents()

    window.showMaximized()
    splash.finish(window)

    qgs.exec_()
    window.deleteLater()
    # when app terminates, call exitQgis() to remove the provider and layer registries from memory
    qgs.exitQgis()
コード例 #24
0
def launch():
    frmmain = None
    log_path = os.path.join(USER_DATA_PATH, 'LOG.log')
    if os.path.isfile(log_path):
        file_size = os.stat(log_path).st_size
        if file_size > MAXIMUM_LOGFILE_SIZE:
            with open(log_path, 'rb') as f:
                file_contents = f.read()
            file_contents = file_contents[file_size - MAXIMUM_LOGFILE_SIZE:]
            with open(log_path, 'wb') as f:
                f.write(file_contents)
    elif os.path.isdir(log_path):
        print('Log file cannot be a directory.')
        sys.exit(1)
    tee = utils.Tee(log_path, 'a')
    print('Starting: ' + str(time.time()))
    try:
        sys.stdout = tee
        #os.environ['QTWEBENGINE_CHROMIUM_FLAGS'] = '--remote-debugging-port=4867 --reduced-referrer-granularity --disable-site-isolation-trials --disable-features=NetworkService,NetworkServiceInProcess'
        app = QApplication(sys.argv)
        splash = QSplashScreen(pix[BS_CHEER])
        splash.show()
        app.processEvents()
        #app
        # Basic app theme here
        app.setStyle(QStyleFactory.create('Fusion'))
        app.setPalette(get_dark_palette())

        # Initialize main window
        frmmain = Frm_Main(app, RELEASE_VER)
        Qt_common.check_win_icon('RAM.EnhOpt.Grave.1', app, frmmain,
                                 relative_path_covnert("favicon.ico"))
        #frmmain.load_file(common.DEFAULT_SETTINGS_PATH)

        frmmain.show()
        splash.finish(frmmain)
        app.setQuitOnLastWindowClosed(False)
        status_code = app.exec_()
        imgs.kill_pool()
        sys.exit(status_code)
    except Exception as e:
        exec_info = sys.exc_info()[0]
        if not exec_info is SystemExit:
            print("Traceback: ", exec_info)
            print(utils.getStackTrace())
        print(e)
    except:
        exec_info = sys.exc_info()[0]
        if not exec_info is SystemExit:
            print("Unexpected error: ", exec_info)
            print(utils.getStackTrace())
    finally:
        tee.flush()
        tee.file.close()
        if frmmain is not None:
            dlg_login = frmmain.dlg_login
            if dlg_login.connection_pool is not None:
                dlg_login.connection_pool.close()
コード例 #25
0
 def start_process(self):
     splash = QSplashScreen(QtGui.QPixmap(os.path.join(self.root_dir,"logo/logo-upper.ico")))
     splash.showMessage("... 0%", QtCore.Qt.AlignHCenter | QtCore.Qt.AlignBottom, QtCore.Qt.black)
     splash.resize(200,90)
     splash.show()
     QtWidgets.qApp.processEvents()
     self.progress(splash)
     splash.show()
     splash.finish(self)
コード例 #26
0
def main():
    app = QApplication(sys.argv)
    ash = QSplashScreen(QtGui.QPixmap("UI/NUI.png"))
    ash.setFont(QtGui.QFont('Microsoft YaHei UI',20))
    ash.show()
    ash.showMessage("系统启动中,请稍候",QtCore.Qt.AlignLeft | QtCore.Qt.AlignBottom, QtCore.Qt.green)
    main_window = MainWindow()
    # app.setStyleSheet(qdarkstyle.load_stylesheet_pyqt5())
    main_window.show()
    ash.finish(main_window)
    sys.exit(app.exec_())
コード例 #27
0
    def show_splash(self):
        image = QPixmap(':/loading_image')
        splash = QSplashScreen(image)
        splash.setAttribute(Qt.WA_DeleteOnClose)
        splash.setMask(image.mask())
        splash.show()

        QCoreApplication.processEvents()
        Parser([])

        splash.finish(self)
コード例 #28
0
def launch_data_downloader(path):
    app = QApplication(sys.argv)
    splash_pix = QPixmap('icons/xigmanas_conf_backup_icon.svg')
    splash = QSplashScreen(splash_pix)
    splash.setMask(splash_pix.mask())
    splash.show()
    config_dict = configparser.ConfigParser()
    if not os.path.exists(os.path.join(path, 'xigmanas_backup.ini')):
        config_dict['LOG'] = {'level': 'INFO', 'path': ''}
        config_dict['OPTIONS'] = {
            'language': 'english',
            'check_update': 'False'
        }
        config_dict['CREDENTIALS'] = {
            'password': '',
            'username': '',
            'folder': '',
            'target': '',
            'target_port': '22'
        }
        with open(os.path.join(path, 'xigmanas_backup.ini'),
                  'w') as configfile:
            config_dict.write(configfile)
    config_dict.read(os.path.join(path, 'xigmanas_backup.ini'))
    path_exist = True
    if not config_dict.get('LOG', 'path'):
        log_filename = os.path.join(path, 'xigmanas_backup_log.out')
    else:
        path_exist = os.path.isdir(config_dict.get('LOG', 'path'))
        if path_exist:
            log_filename = os.path.join(config_dict.get('LOG', 'path'),
                                        'xigmanas_backup_log.out')
        else:
            log_filename = os.path.join(path, 'xigmanas_backup_log.out')
    logging.getLogger('').handlers = []
    logging.basicConfig(filename=log_filename,
                        level=getattr(logging, config_dict.get('LOG',
                                                               'level')),
                        filemode='w',
                        format='%(asctime)s : %(levelname)s : %(message)s')
    formatter = logging.Formatter('%(levelname)s : %(message)s')
    console = logging.StreamHandler()
    console.setLevel(logging.DEBUG)
    console.setFormatter(formatter)
    logging.getLogger('').addHandler(console)
    logging.info('*****************************************')
    logging.info('XigmaNAS Conf Backup ' + _backup_version +
                 ' is starting ...')
    logging.info('*****************************************')
    ui = MainWindow(path, config_dict)
    ui.show()
    splash.finish(ui)
    sys.exit(app.exec_())
コード例 #29
0
def main():
    """The main routine."""
    environ["LIBOVERLAY_SCROLLBAR"] = "0"
    parser = argparse.ArgumentParser(
                prog=__title__,
                description=__title__ + ' is a 2d RPG game maker.',
                epilog=__copyright__ + ", " + __license__ +".")
    parser.add_argument('-v', '--version', action='store_true', default=False, help='get software version.')
    parser.add_argument('-c', '--clean', action='store_true', default=False, help='cleans software settings.')
    parser.add_argument('-p', '--palette', action='store_true', default=False, help='loads exclusively the palette editor.')
    parser.add_argument('mapfile', nargs='?', default='check_no_map', help='a single .map.json file')
    args = parser.parse_args()

    if args.clean == True:
        settings = QSettings("FGMK", "fgmkEditor")
        for key in settings.allKeys():
            settings.remove(key) #guarantee to eliminate all
        settings.sync() #writes to disk
        exit()

    if args.palette == True:
        a = QApplication([])
        m = palette_editor.main()
        a.processEvents()
        m.show()
        m.raise_()
        exit(a.exec_())

    if args.version == True:
        print(__title__ + "  v " + __version__ )
        exit()

    a = QApplication([])
    start = time()
    splash_pix = Editor.Icon()
    splash = QSplashScreen(splash_pix, Qt.WindowStaysOnTopHint)
    splash.setMask(splash_pix.mask())
    splash.show()
    while time() - start < 1:
        sleep(0.001)
        a.processEvents()

    mw_arg=[]
    if 'mapfile' in args:
        mw_arg = [args.mapfile]

    mw = Editor.MainWindow(mw_arg)
    a.processEvents()
    mw.show()
    splash.finish(mw)
    mw.raise_()
    mw.afterInit()
    exit(a.exec_())
コード例 #30
0
def main():
    app = QApplication(sys.argv)

    import time
    start = time.time()
    splash_fname = utils.get_resource_path('icons/splash_ducks.jpg')
    splash_pix = QPixmap(splash_fname)

    size = splash_pix.size()*.55
    splash_pix = splash_pix.scaled(size, Qt.KeepAspectRatio,
                                transformMode=Qt.SmoothTransformation)

    # below makes the pixmap half transparent
    painter = QPainter(splash_pix)
    painter.setCompositionMode(painter.CompositionMode_DestinationAtop)

    painter.fillRect(splash_pix.rect(), QColor(0, 0, 0, 100))

    font = QFont()
    font.setFamily('Arial')
    font.setPointSize(40)
    font.setBold(True)
    painter.setFont(font)

    painter.setPen(QColor(250, 250, 250))
    painter.drawText(splash_pix.rect(), Qt.AlignCenter,
                 "Metadata Wizard")

    font = QFont()
    font.setFamily('Arial')
    font.setPointSize(19)
    font.setBold(True)
    painter.setFont(font)

    painter.setPen(QColor(150, 150, 150, 200))
    painter.drawText(splash_pix.rect().adjusted(20, -20, -20, -20), Qt.AlignBottom,
                     "version 0.0.0 pre-pre Alpha")
    painter.end()

    splash = QSplashScreen(splash_pix, Qt.WindowStaysOnTopHint)
    splash.show()
    app.processEvents()
    time.sleep(2)

    app.processEvents()
    mdwiz = PyMdWizardMainForm()
    mdwiz.show()
    splash.finish(mdwiz)
    app.exec_()
コード例 #31
0
def main():
    app = QApplication(sys.argv)

    # Create and display the splash screen
    splash_pix = PyQt5.QtGui.QPixmap("./res/logo.png")
    splash = QSplashScreen(splash_pix, Qt.WindowStaysOnTopHint)
    splash.setMask(splash_pix.mask())
    splash.show()

    time.sleep(1)

    management_panel = ManagementPanel()
    management_panel.show()
    splash.finish(management_panel)
    sys.exit(app.exec_())
コード例 #32
0
    def showSplash(self):
        # Create and display the splash screen
        splash_pix = QPixmap(
            'C:\\Users\\vcone\\Desktop\\Cosas\\CS\\Software2\\GUI test\\pick-tool-team13-the-bombs\\loading.png'
        )
        splash = QSplashScreen(splash_pix, Qt.WindowStaysOnTopHint)
        splash.setMask(splash_pix.mask())
        # Show a message at the center of the dialog
        splash.showMessage("Cleansing", 0x0084)
        splash.show()
        app.processEvents()

        # Simulate something that takes time
        time.sleep(2)
        splash.finish(self)
コード例 #33
0
def main():
    app = QApplication(sys.argv)

    # Create and display the splash screen
    splash_pix = QPixmap("./res/logo.png")
    splash = QSplashScreen(splash_pix, Qt.WindowStaysOnTopHint)
    splash.setMask(splash_pix.mask())
    splash.show()

    time.sleep(2)

    registration_window = RegistrationWindow()
    registration_window.show()
    splash.finish(registration_window)
    sys.exit(app.exec_())
コード例 #34
0
ファイル: app.py プロジェクト: alistair-broomhead/mu
def main():
    # The app object is the application running on your computer.
    app = QApplication(sys.argv)
    app.setStyleSheet(load_stylesheet('mu.css'))

    # A splash screen is a logo that appears when you start up the application.
    # The image to be "splashed" on your screen is in the resources/images
    # directory.
    splash = QSplashScreen(load_pixmap('icon'))
    splash.show()

    # Make the editor with the Mu class defined above.
    the_editor = Mu()
    the_editor.show()
    the_editor.autosize_window()

    # Remove the splash when the_editor has finished setting itself up.
    splash.finish(the_editor)

    # Stop the program after the application finishes executing.
    sys.exit(app.exec_())
コード例 #35
0
ファイル: app.py プロジェクト: willingc/mu
def run():
    """
    Creates all the top-level assets for the application, sets things up and
    then runs the application. Specific tasks include:

    - set up logging
    - create an application object
    - create an editor window and status bar
    - display a splash screen while starting
    - close the splash screen after startup timer ends
    """
    setup_logging()
    logging.info('\n\n-----------------\n\nStarting Mu {}'.format(__version__))
    logging.info(platform.uname())
    logging.info('Python path: {}'.format(sys.path))

    # The app object is the application running on your computer.
    app = QApplication(sys.argv)
    app.setAttribute(Qt.AA_DontShowIconsInMenus)

    # Create the "window" we'll be looking at.
    editor_window = Window()
    # Create the "editor" that'll control the "window".
    editor = Editor(view=editor_window)
    editor.setup(setup_modes(editor, editor_window))
    # Setup the window.
    editor_window.closeEvent = editor.quit
    editor_window.setup(editor.debug_toggle_breakpoint, editor.theme)
    # Restore the previous session along with files passed by the os
    editor.restore_session(sys.argv[1:])
    # Connect the various UI elements in the window to the editor.
    editor_window.connect_tab_rename(editor.rename_tab, 'Ctrl+Shift+S')
    status_bar = editor_window.status_bar
    status_bar.connect_logs(editor.show_admin, 'Ctrl+Shift+D')

    # Display a friendly "splash" icon.
    splash = QSplashScreen(load_pixmap('splash-screen'))
    splash.show()

    # Finished starting up the application, so hide the splash icon.
    splash_be_gone = QTimer()
    splash_be_gone.timeout.connect(lambda: splash.finish(editor_window))
    splash_be_gone.setSingleShot(True)
    splash_be_gone.start(5000)

    # Stop the program after the application finishes executing.
    sys.exit(app.exec_())
コード例 #36
0
ファイル: app.py プロジェクト: lordmauve/mu
def run():
    """
    Creates all the top-level assets for the application, sets things up and
    then runs the application.
    """
    setup_logging()
    logging.info('\n\n-----------------\n\nStarting Mu {}'.format(__version__))
    logging.info(platform.uname())
    logging.info('Python path: {}'.format(sys.path))
    # The app object is the application running on your computer.
    app = QApplication(sys.argv)
    # Create the "window" we'll be looking at.
    editor_window = Window()
    # Create the "editor" that'll control the "window".
    editor = Editor(view=editor_window)
    editor.setup(setup_modes(editor, editor_window))
    # Setup the window.
    editor_window.closeEvent = editor.quit
    editor_window.setup(editor.debug_toggle_breakpoint, editor.theme)
    # capture the filename passed by the os, if there was one
    passed_filename = sys.argv[1] if len(sys.argv) > 1 else None
    editor.restore_session(passed_filename)
    # Connect the various UI elements in the window to the editor.
    editor_window.connect_tab_rename(editor.rename_tab, 'Ctrl+Shift+S')
    status_bar = editor_window.status_bar
    status_bar.connect_logs(editor.show_logs, 'Ctrl+Shift+D')
    status_bar.connect_mode(editor.select_mode, 'Ctrl+Shift+M')
    # Display a friendly "splash" icon.
    splash = QSplashScreen(load_pixmap('splash-screen'))
    splash.show()
    # Finished starting up the application, so hide the splash icon.
    splash_be_gone = QTimer()
    splash_be_gone.timeout.connect(lambda: splash.finish(editor_window))
    splash_be_gone.setSingleShot(True)
    splash_be_gone.start(5000)
    # Stop the program after the application finishes executing.
    sys.exit(app.exec_())
コード例 #37
0
def start_ide(app, filenames, projects_path, extra_plugins, linenos):
    """Load all the settings necessary before loading the UI, and start IDE."""
    QCoreApplication.setOrganizationName('NINJA-IDE')
    QCoreApplication.setOrganizationDomain('NINJA-IDE')
    QCoreApplication.setApplicationName('NINJA-IDE')
    app.setWindowIcon(QIcon(":img/icon"))

    # Check if there is another session of ninja-ide opened
    # and in that case send the filenames and projects to that session
    running = ipc.is_running()
    start_server = not running[0]
    if running[0] and (filenames or projects_path):
        sended = ipc.send_data(running[1], filenames, projects_path, linenos)
        running[1].close()
        if sended:
            sys.exit()
    else:
        running[1].close()

    # Create and display the splash screen
    splash_pix = QPixmap(":img/splash")
    splash = QSplashScreen(splash_pix, Qt.WindowStaysOnTopHint)
    splash.setMask(splash_pix.mask())
    splash.show()
    app.processEvents()

    # Set the cursor to unblinking
    #if not settings.IS_WINDOWS:
        #app.setCursorFlashTime(0)

    #Set the codec for strings (QString)
    ##QTextCodec.setCodecForCStrings(QTextCodec.codecForName('utf-8'))

    #Translator
    qsettings = ide.IDE.ninja_settings()
    data_qsettings = ide.IDE.data_settings()
    language = QLocale.system().name()
    lang = qsettings.value('preferences/interface/language',
                           defaultValue=language, type='QString') + '.qm'
    lang_path = file_manager.create_path(resources.LANGS, lang)
    if file_manager.file_exists(lang_path):
        settings.LANGUAGE = lang_path
    translator = QTranslator()
    if settings.LANGUAGE:
        translator.load(settings.LANGUAGE)
        app.installTranslator(translator)

        qtTranslator = QTranslator()
        qtTranslator.load(
            "qt_" + language,
            QLibraryInfo.location(QLibraryInfo.TranslationsPath))
        app.installTranslator(qtTranslator)

    #Loading Syntax
    splash.showMessage("Loading Syntax", Qt.AlignRight | Qt.AlignTop, Qt.black)
    json_manager.load_syntax()

    #Read Settings
    splash.showMessage("Loading Settings", Qt.AlignRight | Qt.AlignTop,
                       Qt.black)

    #Set Stylesheet
    style_applied = False
    print(settings.NINJA_SKIN)
    if settings.NINJA_SKIN not in ('Default'):
        file_name = ("%s.qss" % settings.NINJA_SKIN)
        qss_file = file_manager.create_path(resources.NINJA_THEME_DOWNLOAD,
                                            file_name)
        if file_manager.file_exists(qss_file):
            with open(qss_file) as fileaccess:
                qss = fileaccess.read()
                app.setStyleSheet(qss)
                style_applied = True
    if not style_applied:
        if settings.NINJA_SKIN == 'Default':
            with open(resources.NINJA_THEME) as fileaccess:
                qss = fileaccess.read()
        app.setStyleSheet(qss)

    #Loading Schemes
    splash.showMessage("Loading Schemes",
                       Qt.AlignRight | Qt.AlignTop, Qt.black)
    scheme = qsettings.value('preferences/editor/scheme', "default",
                             type='QString')
    if scheme != 'default':
        scheme = file_manager.create_path(resources.EDITOR_SKINS,
                                          scheme + '.color')
        if file_manager.file_exists(scheme):
            resources.CUSTOM_SCHEME = json_manager.parse(open(scheme))

    #Loading Shortcuts
    resources.load_shortcuts()
    #Loading GUI
    splash.showMessage("Loading GUI", Qt.AlignRight | Qt.AlignTop, Qt.black)
    ninjaide = ide.IDE(start_server)

    #Showing GUI
    ninjaide.show()
    #OSX workaround for ninja window not in front
    try:
        ninjaide.raise_()
    except:
        pass  # I really dont mind if this fails in any form
    #Loading Session Files
    splash.showMessage("Loading Files and Projects",
                       Qt.AlignRight | Qt.AlignTop, Qt.black)

    #First check if we need to load last session files
    if qsettings.value('preferences/general/loadFiles', True, type=bool):
        #Files in Main Tab
        files = data_qsettings.value('lastSession/openedFiles', [])
        tempFiles = []
        if files:
            for file_ in files:
                fileData = tuple(file_)
                if fileData:
                    tempFiles.append(fileData)
        files = tempFiles

        # Recent Files
        recent_files = data_qsettings.value('lastSession/recentFiles', [])
        #Current File
        current_file = data_qsettings.value(
            'lastSession/currentFile', '', type='QString')
        #Projects
        projects = data_qsettings.value('lastSession/projects', [])
    else:
        files = []
        recent_files = []
        current_file = ''
        projects = []

    #Include files received from console args
    file_with_nro = list([(f[0], (f[1] - 1, 0), 0)
                         for f in zip(filenames, linenos)])
    file_without_nro = list([(f, (0, 0), 0) for f in filenames[len(linenos):]])
    files += file_with_nro + file_without_nro
    #Include projects received from console args
    if projects_path:
        projects += projects_path
    #FIXME: IMPROVE THIS WITH THE NEW WAY OF DO IT
    ninjaide.load_session_files_projects(files, projects,
                                         current_file, recent_files)
    #Load external plugins
    #if extra_plugins:
        #ninjaide.load_external_plugins(extra_plugins)

    splash.finish(ninjaide)
    ninjaide.notify_plugin_errors()
    ninjaide.show_python_detection()
コード例 #38
0
ファイル: CellAnnotator.py プロジェクト: manerotoni/afw
    parser = argparse.ArgumentParser(\
        description='Test script for tiled graphicview widget')
    parser.add_argument('--file', '-f', help='hdf file to load', default=None)
    args = parser.parse_args()

    if args.file is not None and not os.path.isfile(args.file):
        raise SystemExit("File does not exist!")

    app = QApplication(sys.argv)

    # windows always sucks!!
    if sys.platform.startswith("win"):
        sqldrivers = join(dirname(QtGui.__file__), "plugins")
        app.addLibraryPath(sqldrivers)


    splash_pix = QPixmap(':annotationtool_about.png')
    splash = QSplashScreen(splash_pix, Qt.WindowStaysOnTopHint)
    splash.setMask(splash_pix.mask())
    splash.show()
    splash.showMessage(version.information,
                       alignment=Qt.AnchorHorizontalCenter|
                       Qt.AnchorVerticalCenter)
    app.processEvents()
    mw = AtMainWindow(args.file)
    mw.show()
    app.thread().msleep(1000)
    splash.finish(mw)

    sys.exit(app.exec_())
コード例 #39
0
ファイル: analyzer.py プロジェクト: whmrtm/friture
def main():
    print("Platform is %s (%s)" %(platform.system(), sys.platform))

    if platform.system() == "Windows":
        print("Applying Windows-specific setup")
        # On Windows, redirect stderr to a file
        import imp
        import ctypes
        if (hasattr(sys, "frozen") or  # new py2exe
                hasattr(sys, "importers") or  # old py2exe
                imp.is_frozen("__main__")):  # tools/freeze
            sys.stderr = open(os.path.expanduser("~/friture.exe.log"), "w")
        # set the App ID for Windows 7 to properly display the icon in the
        # taskbar.
        myappid = 'Friture.Friture.Friture.current'  # arbitrary string
        try:
            ctypes.windll.shell32.SetCurrentProcessExplicitAppUserModelID(myappid)
        except:
            print("Could not set the app model ID. If the plaftorm is older than Windows 7, this is normal.")

    app = QApplication(sys.argv)

    if platform.system() == "Darwin":
        if hasattr(sys, "frozen"): #py2app
            sys.stdout = open(os.path.expanduser("~/friture.out.txt"), "w")
            sys.stderr = open(os.path.expanduser("~/friture.err.txt"), "w")

        print("Applying Mac OS-specific setup")
        # help the py2app-packaged application find the Qt plugins (imageformats and platforms)
        pluginsPath = os.path.normpath(os.path.join(QApplication.applicationDirPath(), os.path.pardir, 'PlugIns'))
        print("Adding the following to the Library paths: " + pluginsPath)
        QApplication.addLibraryPath(pluginsPath)

    # Splash screen
    pixmap = QPixmap(":/images/splash.png")
    splash = QSplashScreen(pixmap)
    splash.show()
    splash.showMessage("Initializing the audio subsystem")
    app.processEvents()

    # Logger class
    logger = Logger()

    window = Friture(logger)
    window.show()
    splash.finish(window)

    profile = "no"  # "python" or "kcachegrind" or anything else to disable

    if len(sys.argv) > 1:
        if sys.argv[1] == "--python":
            profile = "python"
        elif sys.argv[1] == "--kcachegrind":
            profile = "kcachegrind"
        elif sys.argv[1] == "--no":
            profile = "no"
        else:
            print("command-line arguments (%s) not recognized" % sys.argv[1:])

    if profile == "python":
        import cProfile
        import pstats

        cProfile.runctx('app.exec_()', globals(), locals(), filename="friture.cprof")

        stats = pstats.Stats("friture.cprof")
        stats.strip_dirs().sort_stats('time').print_stats(20)
        stats.strip_dirs().sort_stats('cumulative').print_stats(20)

        sys.exit(0)
    elif profile == "kcachegrind":
        import cProfile
        import lsprofcalltree

        p = cProfile.Profile()
        p.run('app.exec_()')

        k = lsprofcalltree.KCacheGrind(p)
        with open('cachegrind.out.00000', 'wb') as data:
            k.output(data)

        sys.exit(0)
    else:
        sys.exit(app.exec_())
コード例 #40
0
ファイル: ide.py プロジェクト: Salmista-94/Ninja_PyQt5
def start(filenames=None, projects_path=None,
          extra_plugins=None, linenos=None):
    app = QApplication(sys.argv)
    QCoreApplication.setOrganizationName('NINJA-IDE')
    QCoreApplication.setOrganizationDomain('NINJA-IDE')
    QCoreApplication.setApplicationName('NINJA-IDE')
    app.setWindowIcon(QIcon(resources.IMAGES['icon']))

    # Check if there is another session of ninja-ide opened
    # and in that case send the filenames and projects to that session
    running = ipc.is_running()
    start_server = not running[0]
    if running[0] and (filenames or projects_path):
        sended = ipc.send_data(running[1], filenames, projects_path, linenos)
        running[1].close()
        if sended:
            sys.exit()
    else:
        running[1].close()

    # Create and display the splash screen
    splash_pix = QPixmap(resources.IMAGES['splash'])
    splash = QSplashScreen(splash_pix, Qt.WindowStaysOnTopHint)
    splash.setMask(splash_pix.mask())
    splash.show()
    app.processEvents()

    # Set the cursor to unblinking
    if sys.platform != 'win32':
        app.setCursorFlashTime(0)

    #Set the codec for strings (QString)
    print("codec:", QTextCodec.codecForName('utf-8'))
    #QTextCodec.setCodecForCStrings(QTextCodec.codecForName('utf-8'))

    #Translator
    #qsettings = QSettings()
    qsettings = QSettings(resources.SETTINGS_PATH, QSettings.IniFormat)
    language = QLocale.system().name()
    lang = qsettings.value('preferences/interface/language',
        defaultValue=language, type='QString') + '.qm'
    lang_path = file_manager.create_path(resources.LANGS, lang)
    if file_manager.file_exists(lang_path):
        settings.LANGUAGE = lang_path
    elif file_manager.file_exists(file_manager.create_path(
      resources.LANGS_DOWNLOAD, lang)):
        settings.LANGUAGE = file_manager.create_path(
            resources.LANGS_DOWNLOAD, lang)
    translator = QTranslator()
    if settings.LANGUAGE:
        translator.load(settings.LANGUAGE)
        app.installTranslator(translator)

        qtTranslator = QTranslator()
        qtTranslator.load("qt_" + language,
            QLibraryInfo.location(QLibraryInfo.TranslationsPath))
        app.installTranslator(qtTranslator)

    #Loading Syntax
    splash.showMessage("Loading Syntax", Qt.AlignRight | Qt.AlignTop, Qt.black)
    json_manager.load_syntax()

    #Read Settings
    splash.showMessage("Loading Settings", Qt.AlignRight | Qt.AlignTop,
        Qt.black)
    settings.load_settings()

    #Set Stylesheet
    style_applied = False
    if settings.NINJA_SKIN not in ('Default', 'Classic Theme'):
        file_name = ("%s.qss" % settings.NINJA_SKIN)
        qss_file = file_manager.create_path(resources.NINJA_THEME_DOWNLOAD,
            file_name)
        if file_manager.file_exists(qss_file):
            with open(qss_file) as f:
                qss = f.read()
                app.setStyleSheet(qss)
                style_applied = True
    if not style_applied:
        if settings.NINJA_SKIN == 'Default':
            with open(resources.NINJA_THEME) as f:
                qss = f.read()
        else:
            with open(resources.NINJA__THEME_CLASSIC) as f:
                qss = f.read()
        app.setStyleSheet(qss)

    #Loading Schemes
    splash.showMessage("Loading Schemes",
        Qt.AlignRight | Qt.AlignTop, Qt.black)
    scheme = qsettings.value('preferences/editor/scheme', "default",
        type='QString')
    if scheme != 'default':
        scheme = file_manager.create_path(resources.EDITOR_SKINS,
            scheme + '.color')
        if file_manager.file_exists(scheme):
            resources.CUSTOM_SCHEME = json_manager.parse(open(scheme))

    #Loading Shortcuts
    resources.load_shortcuts()
    #Loading GUI
    splash.showMessage("Loading GUI", Qt.AlignRight | Qt.AlignTop, Qt.black)
    ide = IDE(start_server)

    #Showing GUI
    ide.show()

    #Loading Session Files
    splash.showMessage("Loading Files and Projects",
        Qt.AlignRight | Qt.AlignTop, Qt.black)
    #Files in Main Tab
    main_files = qsettings.value('openFiles/mainTab', [])
    if main_files is not None:
        mainFiles = list(main_files)
    else:
        mainFiles = list()
    tempFiles = []
    for file_ in mainFiles:
        fileData = list(file_)
        if fileData:
            lineno = fileData[1]
            tempFiles.append((fileData[0], lineno))
    mainFiles = tempFiles
    #Files in Secondary Tab
    sec_files = qsettings.value('openFiles/secondaryTab', [])
    if sec_files is not None:
        secondaryFiles = list(sec_files)
    else:
        secondaryFiles = list()
    tempFiles = []
    for file_ in secondaryFiles:
        fileData = list(file_)
        lineno = fileData[1]
        tempFiles.append((fileData[0], lineno))
    secondaryFiles = tempFiles
    # Recent Files
    recent = qsettings.value('openFiles/recentFiles', [])
    if recent is not None:
        recent_files = list(recent)
    else:
        recent_files = list()
    recent_files = [file_ for file_ in recent_files]
    #Current File
    current_file = qsettings.value('openFiles/currentFile', '', type='QString')
    #Projects
    projects_list = qsettings.value('openFiles/projects', [])
    if projects_list is not None:
        projects = list(projects_list)
    else:
        projects = list()
    projects = [project for project in projects]
    #Include files received from console args
    file_with_nro = list([(f[0], f[1] - 1) for f in zip(filenames, linenos)])
    file_without_nro = list([(f, 0) for f in filenames[len(linenos):]])
    mainFiles += file_with_nro + file_without_nro
    #Include projects received from console args
    if projects_path:
        projects += projects_path
    ide.load_session_files_projects(mainFiles, secondaryFiles, projects,
        current_file, recent_files)
    #Load external plugins
    if extra_plugins:
        ide.load_external_plugins(extra_plugins)

    splash.finish(ide)
    ide.notify_plugin_errors()
    ide.show_python_detection()
    sys.exit(app.exec_())
コード例 #41
0
ファイル: app.py プロジェクト: ZanderBrown/mu
def run():
    """
    Creates all the top-level assets for the application, sets things up and
    then runs the application. Specific tasks include:

    - set up logging
    - create an application object
    - create an editor window and status bar
    - display a splash screen while starting
    - close the splash screen after startup timer ends
    """
    setup_logging()
    logging.info('\n\n-----------------\n\nStarting Mu {}'.format(__version__))
    logging.info(platform.uname())
    logging.info('Python path: {}'.format(sys.path))
    logging.info('Language code: {}'.format(language_code))

    # The app object is the application running on your computer.
    app = QApplication(sys.argv)
    # By default PyQt uses the script name (run.py)
    app.setApplicationName('mu')
    # Set hint as to the .desktop files name
    app.setDesktopFileName('mu.codewith.editor')
    app.setApplicationVersion(__version__)
    app.setAttribute(Qt.AA_DontShowIconsInMenus)
    # Images (such as toolbar icons) aren't scaled nicely on retina/4k displays
    # unless this flag is set
    app.setAttribute(Qt.AA_UseHighDpiPixmaps)

    # Create the "window" we'll be looking at.
    editor_window = Window()

    @editor_window.load_theme.connect
    def load_theme(theme):
        if theme == 'contrast':
            app.setStyleSheet(CONTRAST_STYLE)
        elif theme == 'night':
            app.setStyleSheet(NIGHT_STYLE)
        else:
            app.setStyleSheet(DAY_STYLE)

    # Make sure all windows have the Mu icon as a fallback
    app.setWindowIcon(load_icon(editor_window.icon))
    # Create the "editor" that'll control the "window".
    editor = Editor(view=editor_window)
    editor.setup(setup_modes(editor, editor_window))
    # Setup the window.
    editor_window.closeEvent = editor.quit
    editor_window.setup(editor.debug_toggle_breakpoint, editor.theme)
    # Restore the previous session along with files passed by the os
    editor.restore_session(sys.argv[1:])
    # Connect the various UI elements in the window to the editor.
    editor_window.connect_tab_rename(editor.rename_tab, 'Ctrl+Shift+S')
    editor_window.connect_find_replace(editor.find_replace, 'Ctrl+F')
    editor_window.connect_toggle_comments(editor.toggle_comments, 'Ctrl+K')
    status_bar = editor_window.status_bar
    status_bar.connect_logs(editor.show_admin, 'Ctrl+Shift+D')

    # Display a friendly "splash" icon.
    splash = QSplashScreen(load_pixmap('splash-screen'))
    splash.show()

    # Hide the splash icon.
    splash_be_gone = QTimer()
    splash_be_gone.timeout.connect(lambda: splash.finish(editor_window))
    splash_be_gone.setSingleShot(True)
    splash_be_gone.start(2000)

    # Stop the program after the application finishes executing.
    sys.exit(app.exec_())
コード例 #42
0
ファイル: main.py プロジェクト: ajoros/ves
        self.schlumbergerLayout = False
        self.wennerLayout = True


    def schlumberger(self):
        """Define Schlumberger layout is True"""
        self.schlumbergerLayout = True
        self.wennerLayout = False


if __name__ == '__main__':

    app = QApplication(sys.argv)
    app.setWindowIcon(QIcon('hand_drill.png'))

    splashPix = QPixmap('splash.png')
    splashScreen = QSplashScreen(splashPix, Qt.WindowStaysOnTopHint)

    splashScreen.setMask(splashPix.mask())
    splashScreen.show()
    app.processEvents()

    time.sleep(3)

    startup = StartupWindow(tableData, headers, colors, old_coefficients)
    startup.show()

    splashScreen.finish(startup)

    sys.exit(app.exec_())
コード例 #43
0
ファイル: analyzer.py プロジェクト: claypipkin/friture
def main():
	if platform.system() == "Windows":
		print("Running on Windows")
		# On Windows, redirect stderr to a file
		import imp, ctypes
		if (hasattr(sys, "frozen") or # new py2exe
			hasattr(sys, "importers") or # old py2exe
			imp.is_frozen("__main__")): # tools/freeze
				sys.stderr = open(os.path.expanduser("~/friture.exe.log"), "w")
		# set the App ID for Windows 7 to properly display the icon in the
		# taskbar.
		myappid = 'Friture.Friture.Friture.current' # arbitrary string
		try:
			ctypes.windll.shell32.SetCurrentProcessExplicitAppUserModelID(myappid)
		except:
			print("Could not set the app model ID. If the plaftorm is older than Windows 7, this is normal.")

	app = QApplication(sys.argv)

	# Splash screen
	pixmap = QPixmap(":/images/splash.png")
	splash = QSplashScreen(pixmap)
	splash.show()
	splash.showMessage("Initializing the audio subsystem")
	app.processEvents()
	
	# Set the separator stylesheet here
	# As of Qt 4.6, separator width is not handled correctly
	# when the stylesheet is applied directly to the QMainWindow instance.
	# QtCreator workarounds it with a "minisplitter" special class
	app.setStyleSheet(STYLESHEET)
	
	# Logger class
	logger = Logger()
	
	window = Friture(logger)
	window.show()
	splash.finish(window)
	
	profile = "no" # "python" or "kcachegrind" or anything else to disable

	if len(sys.argv) > 1:
		if sys.argv[1] == "--python":
			profile = "python"
		#elif sys.argv[1] == "--kcachegrind":
			#profile = "kcachegrind"
		elif sys.argv[1] == "--no":
			profile = "no"
		else:
			print("command-line arguments (%s) not recognized" %sys.argv[1:])

	if profile == "python":
		import cProfile
		import pstats
		
		cProfile.runctx('app.exec_()', globals(), locals(), filename="friture.cprof")
		
		stats = pstats.Stats("friture.cprof")
		stats.strip_dirs().sort_stats('time').print_stats(20)
		stats.strip_dirs().sort_stats('cumulative').print_stats(20)  

		sys.exit(0)
	#elif profile == "kcachegrind":
		#import cProfile
		#import lsprofcalltree

		#p = cProfile.Profile()
		#p.run('app.exec_()')
		
		#k = lsprofcalltree.KCacheGrind(p)
		#data = open('cachegrind.out.00000', 'wb')
		#k.output(data)
		#data.close()

		## alternative code with pyprof2calltree instead of lsprofcalltree
		##import pyprof2calltree
		##pyprof2calltree.convert(p.getstats(), "cachegrind.out.00000") # save
		
		#sys.exit(0)
	else:
		sys.exit(app.exec_())
コード例 #44
0
ファイル: main.py プロジェクト: Tinkerforge/brickv
def main():
    try:
        locale.setlocale(locale.LC_ALL, '')
    except locale.Error:
        pass # ignore this as it might fail on macOS, we'll fallback to UTF-8 in that case

    if config.get_use_fusion_gui_style():
        sys.argv += ['-style', 'fusion']

    if '--error-report' in sys.argv:
        sys.exit(error_report_main())

    # Catch all uncaught exceptions and show an error message for them.
    # PyQt5 does not silence exceptions in slots (as did PyQt4), so there
    # can be slots which try to (for example) send requests but don't wrap
    # them in an async call with error handling.
    argv = deepcopy(sys.argv) # Deep copy because QApplication (i.e. BrickViewer) constructor parses away Qt args and we want to know the style.
    if '--no-error-reporter' not in sys.argv:
        ExceptionReporter(argv)

    # Exceptions that happen before the event loop runs (f.e. syntax errors) kill the brickv so fast, that the error reporter thread
    # (which is daemonized) can not report the error before it is killed. Report them manually.
    try:
        # importing the MainWindow after creating the QApplication instance triggers this warning
        #
        #  Qt WebEngine seems to be initialized from a plugin. Please set Qt::AA_ShareOpenGLContexts
        #  using QCoreApplication::setAttribute before constructing QGuiApplication.
        #
        # do what the warnings says to avoid it
        QApplication.setAttribute(Qt.AA_ShareOpenGLContexts)

        brick_viewer = BrickViewer(sys.argv)

        if sys.platform == 'darwin':
            # workaround macOS QTBUG-61562
            from brickv.mac_pasteboard_mime_fixed import MacPasteboardMimeFixed
            mac_pasteboard_mime_fixed = MacPasteboardMimeFixed()

        splash = QSplashScreen(load_pixmap('splash.png'), Qt.WindowStaysOnTopHint)
        splash.show()

        message = 'Starting Brick Viewer ' + config.BRICKV_VERSION

        if config.INTERNAL != None:
            message += '~{}'.format(config.INTERNAL)

        splash.showMessage(message, Qt.AlignHCenter | Qt.AlignBottom, Qt.white)

        brick_viewer.processEvents()

        from brickv.mainwindow import MainWindow

        main_window = MainWindow()
        main_window.show()

        splash.finish(main_window)
    except:
        if '--no-error-reporter' in sys.argv:
            raise

        etype, value, tb = sys.exc_info()
        error = "".join(traceback.format_exception(etype, value, tb))
        error = "The following error is fatal. Exiting now.\n\n" + error

        traceback.print_exception(etype, value, tb)

        try:
            splash.close()
        except:
            pass

        # Either sys.executable is /path/to/python, then run calls /path/to/python /path/to/main.py --error-report,
        # or sys.executable is brickv[.exe], then the --error-report flag ensures, that the path to main.py is ignored.
        subprocess.run([sys.executable, os.path.realpath(__file__), "--error-report"] + argv, input=error, universal_newlines=True)
        sys.exit(1)

    sys.exit(brick_viewer.exec_())