当前位置: 首页>>代码示例>>Python>>正文


Python QApplication.exec_方法代码示例

本文整理汇总了Python中qtpy.QtWidgets.QApplication.exec_方法的典型用法代码示例。如果您正苦于以下问题:Python QApplication.exec_方法的具体用法?Python QApplication.exec_怎么用?Python QApplication.exec_使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在qtpy.QtWidgets.QApplication的用法示例。


在下文中一共展示了QApplication.exec_方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: main

# 需要导入模块: from qtpy.QtWidgets import QApplication [as 别名]
# 或者: from qtpy.QtWidgets.QApplication import exec_ [as 别名]
def main():
    from qtpy.QtCore import Qt, QCoreApplication
    from qtpy.QtWidgets import QApplication
    from qtpy import API

    import hyperspyui.info
    from hyperspyui.settings import Settings

    QCoreApplication.setAttribute(Qt.AA_ShareOpenGLContexts)
    # Need to set early to make QSettings accessible
    QCoreApplication.setApplicationName("HyperSpyUI")
    QCoreApplication.setOrganizationName("Hyperspy")
    QCoreApplication.setApplicationVersion(hyperspyui.info.__version__)

    # First, clear all default settings!
    # TODO: This will cause a concurrency issue with multiple launch
    Settings.clear_defaults()
    # Setup default for single/multi-instance
    settings = Settings(group="General")
    settings.set_default('allow_multiple_instances', False)
    if settings['allow_multiple_instances', bool]:
        # Using multiple instances, get a new application
        app = QApplication(sys.argv)
    else:
        # Make sure we only have a single instance
        from hyperspyui.singleapplication import get_app
        app = get_app('hyperspyui')

    splash = get_splash()

    log_file = _get_logfile()
    if log_file:
        sys.stdout = sys.stderr = log_file
    else:
        @contextmanager
        def dummy_context_manager(*args, **kwargs):
            yield
        log_file = dummy_context_manager()

    with log_file:
        # Need to have import here, since QApplication needs to be called first
        from hyperspyui.mainwindow import MainWindow

        form = MainWindow(splash=splash)
        if not settings['allow_multiple_instances', bool]:
            if "pyqt" in API:
                app.messageAvailable.connect(form.handleSecondInstance)
            elif API == 'pyside':
                app.messageReceived.connect(form.handleSecondInstance)
        form.showMaximized()

        form.splash.hide()
        form.load_complete.emit()
        # Ensure logging is OK
        import hyperspy.api as hs
        hs.set_log_level(LOGLEVEL)

        app.exec_()
开发者ID:hyperspy,项目名称:hyperspyUI,代码行数:60,代码来源:__main__.py

示例2: run

# 需要导入模块: from qtpy.QtWidgets import QApplication [as 别名]
# 或者: from qtpy.QtWidgets.QApplication import exec_ [as 别名]
def run():
    import sys
    from qtpy.QtWidgets import QApplication

    def selection():
        print('hello')

    app = QApplication(sys.argv)
    dialog = PeriodicTableDialog(None)
    dialog.selectionChanged.connect(selection)
    dialog.exec_()
    print(dialog.selection())
    app.exec_()
开发者ID:pyhmsa,项目名称:pyhmsa-gui,代码行数:15,代码来源:periodictable.py

示例3: main

# 需要导入模块: from qtpy.QtWidgets import QApplication [as 别名]
# 或者: from qtpy.QtWidgets.QApplication import exec_ [as 别名]
def main(args=sys.argv):
    app = QApplication(args)

    widget = SpellCheckTextEdit('Type here')
    widget.show()
    widget.raise_()

    return app.exec_()
开发者ID:blackkensai,项目名称:git-cola,代码行数:10,代码来源:spellcheck.py

示例4: test

# 需要导入模块: from qtpy.QtWidgets import QApplication [as 别名]
# 或者: from qtpy.QtWidgets.QApplication import exec_ [as 别名]
def test(nr):
    if nr == 1:
        MyMainWindow().start()
    elif nr == 2:
        MyDialog(None, True).start()
    elif nr == 3:
        app = QApplication(sys.argv)
        w = WidgetWindow()
        print (w)
        app.exec_()
    if nr == 4:
        app = QApplication(sys.argv)
        window = QMainWindow()
        w = MyWidget(window)
        print (w)
        window.show()
        app.exec_()
    if nr == 5:
        MyMainWindowWithMenu().start()
    if nr == 6:
        MyCombinationWindow().start()
开发者ID:madsmpedersen,项目名称:MMPE,代码行数:23,代码来源:UseQtGuiLoader.py

示例5: open_in_window

# 需要导入模块: from qtpy.QtWidgets import QApplication [as 别名]
# 或者: from qtpy.QtWidgets.QApplication import exec_ [as 别名]
def open_in_window(widget_name, script):
    """
    Displays a widget in a window.
    :param widget_name:  A qualified name of a widget, ie mantidqt.mywidget.MyWidget
    :param script: A qualified name of a test function that can be run after the
        widget is created. The test function must have the signature:

            def test(widget):
                ...

        where argument widget is an instance of the tested widget.
        The test function can yield from time to time after which the widget can update itself.
        This will make the test non-blocking and changes can be viewed as the script runs.
        If the test yields an integer it is interpreted as the number of seconds to wait
        until the next step.
    """
    raw_input('Please attach the Debugger now if required. Press any key to continue')
    setup_library_paths()
    app = QApplication([""])
    w = create_widget(widget_name)
    w.setWindowTitle(widget_name)
    w.show()

    if script is not None:
        try:
            # If script is a generator script_iter allows non-blocking
            # test execution
            script_iter = iter(run_script(script, w))
            pause_timer = QTimer()
            pause_timer.setSingleShot(True)

            def idle():
                if not pause_timer.isActive():
                    try:
                        # Run test script until the next 'yield'
                        pause_sec = script_iter.next()
                        if pause_sec is not None:
                            # Start non-blocking pause in seconds
                            pause_timer.start(int(pause_sec * 1000))
                    except StopIteration:
                        pass
                    except:
                        traceback.print_exc()
            timer = QTimer()
            # Zero-timeout timer runs idle() between Qt events
            timer.timeout.connect(idle)
            timer.start()
        except:
            pass

    sys.exit(app.exec_())
开发者ID:DanNixon,项目名称:mantid,代码行数:53,代码来源:run_test_app.py

示例6: test

# 需要导入模块: from qtpy.QtWidgets import QApplication [as 别名]
# 或者: from qtpy.QtWidgets.QApplication import exec_ [as 别名]
def test():
    """ """
    app = QApplication([])
    win = TourTestWindow()
    win.show()
    app.exec_()
开发者ID:0xBADCA7,项目名称:spyder,代码行数:8,代码来源:tour.py

示例7: xmax

# 需要导入模块: from qtpy.QtWidgets import QApplication [as 别名]
# 或者: from qtpy.QtWidgets.QApplication import exec_ [as 别名]
    @xmax.setter
    def xmax(self, value):
        xmin = self.ax1.get_xlim()[0]
        self.ax1.set_xlim(xmin, value)

    # ymin property
    @property
    def ymin(self):
        return self.ax1.get_ylim()[0]

    @ymin.setter
    def ymin(self, value):
        ymax = self.ax1.get_ylim()[1]
        self.ax1.set_ylim(value, ymax)

    # ymax property
    @property
    def ymax(self):
        return self.ax1.get_ylim()[1]

    @ymax.setter
    def ymax(self, value):
        ymin = self.ax1.get_ylim()[0]
        self.ax1.set_ylim(ymin, value)

if __name__ == "__main__":
    app = QApplication(sys.argv)
    w = PlotWidget()
    w.show()
    app.exec_()
开发者ID:MrLeeh,项目名称:jsonwatchqt,代码行数:32,代码来源:plotwidget.py

示例8: ModalTester

# 需要导入模块: from qtpy.QtWidgets import QApplication [as 别名]
# 或者: from qtpy.QtWidgets.QApplication import exec_ [as 别名]
class ModalTester(object):
    """
    Helper class for testing modal widgets (dialogs).
    """
    def __init__(self, creator, tester):
        """
        Initialise ModalTester.
        :param creator: Function without arguments that creates a modal widget. Can be a class name.
            A modal widget must have exec_() method.
        :param tester: A function taking a widget as its argument that does testing.
        """
        self.app = QApplication.instance()
        if self.app is None:
            self.app = QApplication([''])
        self.creator = creator
        self.tester = tester
        self.widget = None
        self.timer = None
        self.passed = False

    def __call__(self):
        """
        Initialise testing.
        """
        try:
            self.widget = self.creator()
        except:
            traceback.print_exc()
            self.app.exit(0)
        if self.widget is not None:
            self.widget.exec_()

    def _idle(self):
        """
        This function runs every time in QApplication's event loop.
        Call the testing function.
        """
        modal_widget = self.app.activeModalWidget()
        if modal_widget is not None:
            if self.widget is modal_widget:
                try:
                    self.tester(self.widget)
                    self.passed = True
                except:
                    traceback.print_exc()
            if modal_widget.isVisible():
                modal_widget.close()

    def start(self):
        """
        Start this tester.
        """
        self.timer = QTimer()
        # Connecting self.idle to a QTimer with 0 time delay
        # makes it called when there are no events to process
        self.timer.timeout.connect(self._idle)
        self.timer.start()
        # This calls __call__() method
        QTimer.singleShot(0, self)
        # Start the event loop
        self.app.exec_()
开发者ID:DanNixon,项目名称:mantid,代码行数:63,代码来源:modal_tester.py

示例9: Exception

# 需要导入模块: from qtpy.QtWidgets import QApplication [as 别名]
# 或者: from qtpy.QtWidgets.QApplication import exec_ [as 别名]
        if hdu is None:
            raise Exception("Could not make cutout. "
                "Object may be out of the image's range.")

        if self.session is not None:
            iv = StandaloneImageViewer(hdu.data)
            iv.setWindowFlags(iv.windowFlags() | Qt.Tool)
            iv.show()
        else:
            import matplotlib.pyplot as plt
            plt.imshow(hdu.data)
            plt.show()


@menubar_plugin("Cutout Tool (JWST/NIRSpec MSA)")
def nIRSpec_cutout_tool(session, data_collection):
    ex = NIRSpecCutoutTool(session)
    return

@menubar_plugin("General Purpose Cutout Tool")
def general_cutout_tool(session, data_collection):
    ex = GeneralCutoutTool(session)
    return

if __name__ == "__main__":
    app = QApplication(sys.argv)
    ex1 = NIRSpecCutoutTool()
    ex2 = GeneralCutoutTool()
    sys.exit(app.exec_())
开发者ID:spacetelescope,项目名称:mosviz,代码行数:31,代码来源:cutout_tool.py

示例10: main

# 需要导入模块: from qtpy.QtWidgets import QApplication [as 别名]
# 或者: from qtpy.QtWidgets.QApplication import exec_ [as 别名]
def main():
    app = QApplication(sys.argv)
    window = MainWindow()
    window.show()
    app.exec_()
开发者ID:ccordoba12,项目名称:conda-manager,代码行数:7,代码来源:main.py

示例11: main

# 需要导入模块: from qtpy.QtWidgets import QApplication [as 别名]
# 或者: from qtpy.QtWidgets.QApplication import exec_ [as 别名]
def main():
    app = QApplication([])
    main_window = MainWindow()
    main_window.show()
    app.exec_()
开发者ID:jim109,项目名称:PyCalcLED,代码行数:7,代码来源:calculadoraAhorrosLed.py

示例12: test

# 需要导入模块: from qtpy.QtWidgets import QApplication [as 别名]
# 或者: from qtpy.QtWidgets.QApplication import exec_ [as 别名]
def test():
    """Run conda packages widget test"""
    app = QApplication([])
    widget = TestWidget(None)
    widget.show()
    sys.exit(app.exec_())
开发者ID:spyder-ide,项目名称:conda-api-q,代码行数:8,代码来源:conda_api_q.py

示例13: new_figure_manager_given_figure

# 需要导入模块: from qtpy.QtWidgets import QApplication [as 别名]
# 或者: from qtpy.QtWidgets.QApplication import exec_ [as 别名]
def new_figure_manager_given_figure(num, figure):
    """
    Create a new figure manager instance for the given figure.
    """
    canvas = FigureCanvasQTAgg(figure)
    manager = FigureManagerWorkbench(canvas, num)
    return manager


if __name__ == '__main__':
    # testing code
    import numpy as np
    qapp = QApplication([' '])
    qapp.setAttribute(Qt.AA_UseHighDpiPixmaps)
    if hasattr(Qt, 'AA_EnableHighDpiScaling'):
        qapp.setAttribute(Qt.AA_EnableHighDpiScaling, True)

    x = np.linspace(0, 10*np.pi, 1000)
    cx, sx = np.cos(x), np.sin(x)
    fig_mgr_1 = new_figure_manager(1)
    fig1 = fig_mgr_1.canvas.figure
    ax = fig1.add_subplot(111)
    ax.set_title("Test title")
    ax.set_xlabel("$\mu s$")
    ax.set_ylabel("Counts")

    ax.plot(x, cx)
    fig1.show()
    qapp.exec_()
开发者ID:samueljackson92,项目名称:mantid,代码行数:31,代码来源:figuremanager.py

示例14: main

# 需要导入模块: from qtpy.QtWidgets import QApplication [as 别名]
# 或者: from qtpy.QtWidgets.QApplication import exec_ [as 别名]
def main():
    app = QApplication(sys.argv)
    win = ManiWindow()
    win.show()
    sys.exit(app.exec_())
开发者ID:kozintsev,项目名称:ResearchPythonOCC,代码行数:7,代码来源:TestQtBackendNative.py


注:本文中的qtpy.QtWidgets.QApplication.exec_方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。