Exemplo n.º 1
0
def main():

    # check if the user is running the program in batch mode
    batchmode = '-no-gui' in sys.argv

    # run PyAero in batch mode
    if batchmode:
        app = QtCore.QCoreApplication(sys.argv)

        # FIXME
        # FIXME check for proper batch control file
        # FIXME
        if sys.argv[-1] == '-no-gui':
            print('No batch control file specified.')
            sys.exit()

        # prepare logger
        Logger.log('file_only')

        batch_controlfile = sys.argv[-1]
        batchmode = BatchMode.Batch(app, batch_controlfile, __version__)
        batchmode.run_batch()

        return

    # main application (contains the main event loop)
    # run PyAero in GUI mode
    app = QtWidgets.QApplication(sys.argv)

    # set icon for the application ( upper left window icon and taskbar icon)
    # and add specialization icons per size
    # (needed depending on the operating system)
    app_icon = QtGui.QIcon(os.path.join(ICONS, 'app_image.png'))
    app_icon.addFile(os.path.join(ICONS, 'app_image_16x16.png'),
                     QtCore.QSize(16, 16))
    app_icon.addFile(os.path.join(ICONS, 'app_image_24x24.png'),
                     QtCore.QSize(24, 24))
    app_icon.addFile(os.path.join(ICONS, 'app_image_32x32.png'),
                     QtCore.QSize(32, 32))
    app_icon.addFile(os.path.join(ICONS, 'app_image_48x48.png'),
                     QtCore.QSize(48, 48))
    app_icon.addFile(os.path.join(ICONS, 'app_image_256x256.png'),
                     QtCore.QSize(256, 256))

    app.setWindowIcon(app_icon)

    if LOCALE == 'C':
        # set default locale to C, so that decimal separator is a
        # dot in spin boxes, etc.
        QtCore.QLocale.setDefault(QtCore.QLocale.c())

    # window style set in Settings.py
    window = MainWindow(app, STYLE)
    window.show()

    sys.exit(app.exec())
Exemplo n.º 2
0
    def __init__(self):
        self._reads = {}
        self._writes = {}
        self._notifiers = {}
        self._timer = QtCore.QTimer()
        self._timer.setSingleShot(True)
        self._timer.timeout.connect(self._qt_timeout)

        # noinspection PyArgumentList,PyArgumentList
        if QtCore.QCoreApplication.instance() is None:
            # Application Object has not been started yet
            self.qApp = QtCore.QCoreApplication([])
            self._ownApp = True
        else:
            self.qApp = QtCore.QCoreApplication.instance()
            self._ownApp = False
        self._blockApp = None

        QtCore.qInstallMessageHandler(msg_blast)

        super(QtReactor, self).__init__()