當前位置: 首頁>>代碼示例>>Python>>正文


Python QtWidgets.QApplication方法代碼示例

本文整理匯總了Python中qtpy.QtWidgets.QApplication方法的典型用法代碼示例。如果您正苦於以下問題:Python QtWidgets.QApplication方法的具體用法?Python QtWidgets.QApplication怎麽用?Python QtWidgets.QApplication使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在qtpy.QtWidgets的用法示例。


在下文中一共展示了QtWidgets.QApplication方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: test

# 需要導入模塊: from qtpy import QtWidgets [as 別名]
# 或者: from qtpy.QtWidgets import QApplication [as 別名]
def test():
    """測試函數"""
    import sys
    from datetime import datetime
    from qtpy import QtWidgets,QtCore
    
    def simpletest(event):
        print( u'處理每秒觸發的計時器事件:%s' % str(datetime.now()))
    
    app = QtWidgets.QApplication([])
    
    eventEngine = EventEngine2()
    #ee.register(EVENT_TIMER, simpletest)
    eventEngine.registerGeneralHandler(simpletest)
    eventEngine.start()
    
    app.exec_()
    
    
# 直接運行腳本可以進行測試 
開發者ID:birforce,項目名稱:vnpy_crypto,代碼行數:22,代碼來源:eventEngine.py

示例2: initQApplication

# 需要導入模塊: from qtpy import QtWidgets [as 別名]
# 或者: from qtpy.QtWidgets import QApplication [as 別名]
def initQApplication():
    """ Initializes the QtWidgets.QApplication instance. Creates one if it doesn't exist.

        Sets Argos specific attributes, such as the OrganizationName, so that the application
        persistent settings are read/written to the correct settings file/winreg. It is therefore
        important to call this function at startup. The ArgosApplication constructor does this.

        Returns the application.
    """
    # PyQtGraph recommends raster graphics system for OS-X.
    if 'darwin' in sys.platform:
        graphicsSystem = "raster" # raster, native or opengl
        os.environ.setdefault('QT_GRAPHICSSYSTEM', graphicsSystem)
        logger.info("Setting QT_GRAPHICSSYSTEM to: {}".format(graphicsSystem))

    app = QtWidgets.QApplication(sys.argv)
    initArgosApplicationSettings(app)
    return app 
開發者ID:titusjan,項目名稱:argos,代碼行數:20,代碼來源:misc.py

示例3: initArgosApplicationSettings

# 需要導入模塊: from qtpy import QtWidgets [as 別名]
# 或者: from qtpy.QtWidgets import QApplication [as 別名]
def initArgosApplicationSettings(app): # TODO: this is Argos specific. Move somewhere else.
    """ Sets Argos specific attributes, such as the OrganizationName, so that the application
        persistent settings are read/written to the correct settings file/winreg. It is therefore
        important to call this function at startup. The ArgosApplication constructor does this.
    """
    assert app, \
        "app undefined. Call QtWidgets.QApplication.instance() or QtCor.QApplication.instance() first."

    logger.debug("Setting Argos QApplication settings.")
    app.setApplicationName(info.REPO_NAME)
    app.setApplicationVersion(info.VERSION)
    app.setOrganizationName(info.ORGANIZATION_NAME)
    app.setOrganizationDomain(info.ORGANIZATION_DOMAIN)


######################
# Exception Handling #
###################### 
開發者ID:titusjan,項目名稱:argos,代碼行數:20,代碼來源:misc.py

示例4: get_focus_widget_properties

# 需要導入模塊: from qtpy import QtWidgets [as 別名]
# 或者: from qtpy.QtWidgets import QApplication [as 別名]
def get_focus_widget_properties(self):
        """Get properties of focus widget
        Returns tuple (widget, properties) where properties is a tuple of
        booleans: (is_console, not_readonly, readwrite_editor)"""
        widget = QApplication.focusWidget()
        from spyder.widgets.shell import ShellBaseWidget
        from spyder.widgets.editor import TextEditBaseWidget
        from spyder.widgets.ipythonconsole import ControlWidget

        # if focused widget isn't valid try the last focused
        if not isinstance(widget, (ShellBaseWidget, TextEditBaseWidget,
                                   ControlWidget)):
            widget = self.previous_focused_widget

        textedit_properties = None
        if isinstance(widget, (ShellBaseWidget, TextEditBaseWidget,
                               ControlWidget)):
            console = isinstance(widget, (ShellBaseWidget, ControlWidget))
            not_readonly = not widget.isReadOnly()
            readwrite_editor = not_readonly and not console
            textedit_properties = (console, not_readonly, readwrite_editor)
        return widget, textedit_properties 
開發者ID:sys-bio,項目名稱:tellurium,代碼行數:24,代碼來源:mainwindow.py

示例5: get_qapp

# 需要導入模塊: from qtpy import QtWidgets [as 別名]
# 或者: from qtpy.QtWidgets import QApplication [as 別名]
def get_qapp(icon_path=None):
    qapp = QtWidgets.QApplication.instance()
    if qapp is None:
        qapp = QtWidgets.QApplication([''])
    return qapp 
開發者ID:birforce,項目名稱:vnpy_crypto,代碼行數:7,代碼來源:test_patch_qcombobox.py

示例6: get_qapp

# 需要導入模塊: from qtpy import QtWidgets [as 別名]
# 或者: from qtpy.QtWidgets import QApplication [as 別名]
def get_qapp(icon_path=None):
    """
    Helper function to return a QApplication instance
    """
    qapp = QtWidgets.QApplication.instance()
    if qapp is None:
        qapp = QtWidgets.QApplication([''])
    return qapp 
開發者ID:birforce,項目名稱:vnpy_crypto,代碼行數:10,代碼來源:test_uic.py

示例7: createQApp

# 需要導入模塊: from qtpy import QtWidgets [as 別名]
# 或者: from qtpy.QtWidgets import QApplication [as 別名]
def createQApp():
    """創建PyQt應用對象"""
    # 創建Qt應用對象
    qApp = QtWidgets.QApplication([])

    # 設置Qt的皮膚
    if globalSetting['darkStyle']:
        try:
            import qdarkstyle
            qApp.setStyleSheet(qdarkstyle.load_stylesheet_pyqt5())
        except :
            print("Unexpected error when import darkStyle:", sys.exc_info()[0])

    # 設置Windows底部任務欄圖標
    if 'Windows' in platform.uname():
        import ctypes
        ctypes.windll.shell32.SetCurrentProcessExplicitAppUserModelID('vn.trader')

    # 設置Qt字體
    qApp.setFont(BASIC_FONT)

    # 設置Qt圖標
    qApp.setWindowIcon(QtGui.QIcon(loadIconPath('vnpy.ico')))

    # 返回創建好的QApp對象
    return qApp 
開發者ID:birforce,項目名稱:vnpy_crypto,代碼行數:28,代碼來源:uiQt.py

示例8: main

# 需要導入模塊: from qtpy import QtWidgets [as 別名]
# 或者: from qtpy.QtWidgets import QApplication [as 別名]
def main():
    import signal
    from .config import ROOT_LOG
    from .main_window import MainWindow
    from .resources import qCleanupResources
    from qtpy.QtGui import QIcon
    from qtpy.QtWidgets import QApplication

    app = QApplication(sys.argv)
    app.setWindowIcon(QIcon(':/cutelog.png'))
    mw = MainWindow(ROOT_LOG, app)
    signal.signal(signal.SIGINT, mw.signal_handler)

    sys.exit(app.exec_())
    qCleanupResources() 
開發者ID:busimus,項目名稱:cutelog,代碼行數:17,代碼來源:__main__.py

示例9: initialize

# 需要導入模塊: from qtpy import QtWidgets [as 別名]
# 或者: from qtpy.QtWidgets import QApplication [as 別名]
def initialize():
    """ patch figure and show to display the color chooser GUI """
    global app
    if app is None:
        app = QtWidgets.QApplication(sys.argv)
    plt.show = show
    plt.figure = figure 
開發者ID:rgerum,項目名稱:pylustrator,代碼行數:9,代碼來源:QtGui.py

示例10: initQCoreApplication

# 需要導入模塊: from qtpy import QtWidgets [as 別名]
# 或者: from qtpy.QtWidgets import QApplication [as 別名]
def initQCoreApplication():
    """ Initializes the QtCore.QApplication instance. Creates one if it doesn't exist.

        Sets Argos specific attributes, such as the OrganizationName, so that the application
        persistent settings are read/written to the correct settings file/winreg. It is therefore
        important to call this function (or initQApplication) at startup.

        Returns the application.
    """
    app = QtCore.QCoreApplication(sys.argv)
    initArgosApplicationSettings(app)
    return app 
開發者ID:titusjan,項目名稱:argos,代碼行數:14,代碼來源:misc.py

示例11: handleException

# 需要導入模塊: from qtpy import QtWidgets [as 別名]
# 或者: from qtpy.QtWidgets import QApplication [as 別名]
def handleException(exc_type, exc_value, exc_traceback):

    traceback.format_exception(exc_type, exc_value, exc_traceback)

    logger.critical("Bug: uncaught {}".format(exc_type.__name__),
                    exc_info=(exc_type, exc_value, exc_traceback))
    if info.DEBUGGING:
        logger.info("Quitting application with exit code 1")
        sys.exit(1)
    else:
        # Constructing a QApplication in case this hasn't been done yet.
        if not QtWidgets.qApp:
            _app = QtWidgets.QApplication()

        msgBox = ResizeDetailsMessageBox()
        msgBox.setText("Bug: uncaught {}".format(exc_type.__name__))
        msgBox.setInformativeText(str(exc_value))
        lst = traceback.format_exception(exc_type, exc_value, exc_traceback)
        msgBox.setDetailedText("".join(lst))
        msgBox.setIcon(QtWidgets.QMessageBox.Warning)
        msgBox.exec_()
        logger.info("Quitting application with exit code 1")
        sys.exit(1)



######################
# QSettings routines #
###################### 
開發者ID:titusjan,項目名稱:argos,代碼行數:31,代碼來源:misc.py

示例12: main

# 需要導入模塊: from qtpy import QtWidgets [as 別名]
# 或者: from qtpy.QtWidgets import QApplication [as 別名]
def main():
    app = QtWidgets.QApplication(sys.argv)

    # Enable High DPI display with PyQt5
    if hasattr(QtCore.Qt, 'AA_UseHighDpiPixmaps'):
        app.setAttribute(QtCore.Qt.AA_UseHighDpiPixmaps)

    QtCore.QTimer.singleShot(10000, app.exit)
    _ = AwesomeExample()
    sys.exit(app.exec_()) 
開發者ID:spyder-ide,項目名稱:qtawesome,代碼行數:12,代碼來源:example.py

示例13: _copyIconText

# 需要導入模塊: from qtpy import QtWidgets [as 別名]
# 或者: from qtpy.QtWidgets import QApplication [as 別名]
def _copyIconText(self):
        """
        Copy the name of the currently selected icon to the clipboard.
        """
        indexes = self._listView.selectedIndexes()
        if not indexes:
            return

        clipboard = QtWidgets.QApplication.instance().clipboard()
        clipboard.setText(indexes[0].data()) 
開發者ID:spyder-ide,項目名稱:qtawesome,代碼行數:12,代碼來源:icon_browser.py

示例14: run

# 需要導入模塊: from qtpy import QtWidgets [as 別名]
# 或者: from qtpy.QtWidgets import QApplication [as 別名]
def run():
    """
    Start the IconBrowser and block until the process exits.
    """
    app = QtWidgets.QApplication([])

    browser = IconBrowser()
    browser.show()

    sys.exit(app.exec_()) 
開發者ID:spyder-ide,項目名稱:qtawesome,代碼行數:12,代碼來源:icon_browser.py

示例15: load_window_settings

# 需要導入模塊: from qtpy import QtWidgets [as 別名]
# 或者: from qtpy.QtWidgets import QApplication [as 別名]
def load_window_settings(self, prefix, default=False, section='main'):
        """Load window layout settings from userconfig-based configuration
        with *prefix*, under *section*
        default: if True, do not restore inner layout"""
        get_func = CONF.get_default if default else CONF.get
        window_size = get_func(section, prefix+'size')
        prefs_dialog_size = get_func(section, prefix+'prefs_dialog_size')
        if default:
            hexstate = None
        else:
            hexstate = get_func(section, prefix+'state', None)
        pos = get_func(section, prefix+'position')
        
        # It's necessary to verify if the window/position value is valid 
        # with the current screen. See issue 3748
        width = pos[0]
        height = pos[1]
        screen_shape = QApplication.desktop().geometry()
        current_width = screen_shape.width()
        current_height = screen_shape.height()
        if current_width < width or current_height < height:
            pos = CONF.get_default(section, prefix+'position')
        
        is_maximized =  get_func(section, prefix+'is_maximized')
        is_fullscreen = get_func(section, prefix+'is_fullscreen')
        return hexstate, window_size, prefs_dialog_size, pos, is_maximized, \
               is_fullscreen 
開發者ID:sys-bio,項目名稱:tellurium,代碼行數:29,代碼來源:mainwindow.py


注:本文中的qtpy.QtWidgets.QApplication方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。