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


Python QtWidgets.QApplication方法代碼示例

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


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

示例1: start_gui

# 需要導入模塊: from PyQt5 import QtWidgets [as 別名]
# 或者: from PyQt5.QtWidgets import QApplication [as 別名]
def start_gui(args):
    app = QtWidgets.QApplication(args)
    #app.setAttribute(QtCore.Qt.AA_UseDesktopOpenGL)
    #app.setAttribute(QtCore.Qt.AA_UseSoftwareOpenGL)
    #app.setAttribute(QtCore.Qt.AA_UseOpenGLES)
    sys.excepthook = except_hook
    ex = TDCS_GUI()
    ex.show()
    if len(args) > 1:
        if args[1].endswith(".mat"):
            ex.openSimnibsFile(args[1])
        elif args[1].endswith(".msh"):
            ex.loadHeadModel(args[1])
        else:
            raise IOError('simnibs_gui can only load .mat and .msh files')
    sys.exit(app.exec_()) 
開發者ID:simnibs,項目名稱:simnibs,代碼行數:18,代碼來源:main_gui.py

示例2: loadMesh

# 需要導入模塊: from PyQt5 import QtWidgets [as 別名]
# 或者: from PyQt5.QtWidgets import QApplication [as 別名]
def loadMesh(self, mesh_fn):
        print("reading ", mesh_fn)
        self.skin_surf = 'Loading'
        self.gm_surf = 'Loading'
        self.mesh_fn = mesh_fn
        self.loadStage.emit(0)
        QtWidgets.QApplication.processEvents()
        mesh_struct = mesh_io.read_msh(mesh_fn)

        self.loadStage.emit(1)
        QtWidgets.QApplication.processEvents()
        self.skin_surf = surface.Surface(mesh_struct, [5,1005])

        self.loadStage.emit(2)
        QtWidgets.QApplication.processEvents()
        self.gm_surf = surface.Surface(mesh_struct, [2,1002])
        self.loadStage.emit(3)
        
        QtWidgets.QApplication.processEvents()

        self.skin_surf.mesh_name = mesh_fn 
開發者ID:simnibs,項目名稱:simnibs,代碼行數:23,代碼來源:head_model_OGL.py

示例3: get_dAdtField

# 需要導入模塊: from PyQt5 import QtWidgets [as 別名]
# 或者: from PyQt5.QtWidgets import QApplication [as 別名]
def get_dAdtField(self, matsimnibs, fn_coil):
        #Try getting the values for plotting dA/dt
        if fn_coil.endswith('.nii') or fn_coil.endswith('.nii.gz'):
            M = numpy.array(matsimnibs)
            if self.skin_surf is not None:
                field_skin = coil._get_field(fn_coil, self.skin_surf.nodes, M, get_norm=True)*1e7
            if self.gm_surf is not None:
                field_gm = coil._get_field(fn_coil, self.gm_surf.nodes, M, get_norm=True)*1e7

            self.hasField = True
            if self.skin_surf is not None:
                self.skin_model_field = self.drawModel('Skin', field_skin)
            QtWidgets.QApplication.processEvents()
            if self.gm_surf is not None:
                self.gm_model_field = self.drawModel('GM', field_gm)
            QtWidgets.QApplication.processEvents()
            self.selectRenderSurface(self.currenSurface)
            self.update()

        else:
            return None 
開發者ID:simnibs,項目名稱:simnibs,代碼行數:23,代碼來源:head_model_OGL.py

示例4: launch

# 需要導入模塊: from PyQt5 import QtWidgets [as 別名]
# 或者: from PyQt5.QtWidgets import QApplication [as 別名]
def launch():
    """
    Basic startup process.
    """
    from PyQt5 import QtCore, QtWidgets
    from pyweed.gui.SplashScreenHandler import SplashScreenHandler
    import pyweed.gui.qrc  # NOQA

    # See https://stackoverflow.com/questions/31952711/
    QtCore.QCoreApplication.setAttribute(QtCore.Qt.AA_X11InitThreads)

    fix_locale()

    app = QtWidgets.QApplication(sys.argv)
    splashScreenHandler = SplashScreenHandler()
    app.processEvents()
    pyweed = get_pyweed()
    splashScreenHandler.finish(pyweed.mainWindow)
    sys.exit(app.exec_()) 
開發者ID:iris-edu,項目名稱:pyweed,代碼行數:21,代碼來源:pyweed_launcher.py

示例5: convert

# 需要導入模塊: from PyQt5 import QtWidgets [as 別名]
# 或者: from PyQt5.QtWidgets import QApplication [as 別名]
def convert(lines):
    """Convert compiled .ui file from PySide2 to Qt.py

    Arguments:
        lines (list): Each line of of .ui file

    Usage:
        >> with open("myui.py") as f:
        ..   lines = convert(f.readlines())

    """

    def parse(line):
        line = line.replace("from PySide2 import", "from Qt import")
        line = line.replace("QtWidgets.QApplication.translate",
                            "Qt.QtCompat.translate")
        return line

    parsed = list()
    for line in lines:
        line = parse(line)
        parsed.append(line)

    return parsed 
開發者ID:liorbenhorin,項目名稱:pipeline,代碼行數:26,代碼來源:Qt.py

示例6: __init__

# 需要導入模塊: from PyQt5 import QtWidgets [as 別名]
# 或者: from PyQt5.QtWidgets import QApplication [as 別名]
def __init__(self, app=None, set_running_loop=True):
        self.__app = app or QApplication.instance()
        assert self.__app is not None, 'No QApplication has been instantiated'
        self.__is_running = False
        self.__debug_enabled = False
        self.__default_executor = None
        self.__exception_handler = None
        self._read_notifiers = {}
        self._write_notifiers = {}
        self._timer = _SimpleTimer()

        self.__call_soon_signaller = signaller = _make_signaller(QtCore, object, tuple)
        self.__call_soon_signal = signaller.signal
        signaller.signal.connect(lambda callback, args: self.call_soon(callback, *args))

        assert self.__app is not None
        super().__init__()

        if set_running_loop:
            asyncio.events._set_running_loop(self) 
開發者ID:gmarull,項目名稱:asyncqt,代碼行數:22,代碼來源:__init__.py

示例7: main

# 需要導入模塊: from PyQt5 import QtWidgets [as 別名]
# 或者: from PyQt5.QtWidgets import QApplication [as 別名]
def main():
	app = QApplication(sys.argv)
	autoTransferGui = AutoTransferGUI()
	sys.exit(app.exec_()) 
開發者ID:VinylChloride,項目名稱:BaiduNetDiskAutoTransfer,代碼行數:6,代碼來源:mainPrgGui.py

示例8: __init__

# 需要導入模塊: from PyQt5 import QtWidgets [as 別名]
# 或者: from PyQt5.QtWidgets import QApplication [as 別名]
def __init__(self, filename=None):
        QtWidgets.QApplication.__init__(self, ['Talpa'])

        splash_img = QtGui.QPixmap(
            get_resource('talpa_splash.png'))\
            .scaled(QtCore.QSize(400, 250), QtCore.Qt.KeepAspectRatio)
        self.splash = QtWidgets.QSplashScreen(
            splash_img, QtCore.Qt.WindowStaysOnTopHint)
        self.updateSplashMessage('Talpa')
        self.splash.show()
        self.processEvents()

        self.talpa_win = TalpaMainWindow(filename=filename)

        self.talpa_win.actionExit.triggered.connect(self.exit)
        self.aboutToQuit.connect(self.talpa_win.sandbox.worker_thread.quit)
        self.aboutToQuit.connect(self.talpa_win.sandbox.deleteLater)
        self.aboutToQuit.connect(self.splash.deleteLater)
        self.aboutToQuit.connect(self.deleteLater)

        self.talpa_win.show()

        self.splash.finish(self.talpa_win)
        rc = self.exec_()
        sys.exit(rc) 
開發者ID:pyrocko,項目名稱:kite,代碼行數:27,代碼來源:talpa.py

示例9: gui_fname

# 需要導入模塊: from PyQt5 import QtWidgets [as 別名]
# 或者: from PyQt5.QtWidgets import QApplication [as 別名]
def gui_fname(dir=None):
    """
    Select a file via a dialog and return the file name.
    """
    try:
        from PyQt5.QtWidgets import QApplication, QFileDialog
    except ImportError:
        try:
            from PyQt4.QtGui import QApplication, QFileDialog
        except ImportError:
            from PySide.QtGui import QApplication, QFileDialog

    if dir is None:
        dir = './'

    app = QApplication([dir])
    fname = QFileDialog.getOpenFileName(None, "Select a file...",
                                        dir, filter="All files (*)")

    if isinstance(fname, tuple):
        return fname[0]
    else:
        return str(fname) 
開發者ID:tritemio,項目名稱:FRETBursts,代碼行數:25,代碼來源:gui.py

示例10: mainPyQt4Simple

# 需要導入模塊: from PyQt5 import QtWidgets [as 別名]
# 或者: from PyQt5.QtWidgets import QApplication [as 別名]
def mainPyQt4Simple():
    # 必要なモジュールのimport
    from PyQt4.QtCore import QUrl
    from PyQt4.QtGui import QApplication
    from PyQt4.QtWebKit import QWebView

    url = 'https://github.com/tody411/PyIntroduction'

    app = QApplication(sys.argv)

    # QWebViewによるWebページ表示
    browser = QWebView()
    browser.load(QUrl(url))
    browser.show()

    sys.exit(app.exec_())

## PyQt4でのWebブラウザー作成(Youtube用). 
開發者ID:tody411,項目名稱:PyIntroduction,代碼行數:20,代碼來源:web_browser.py

示例11: mainPyQt5

# 需要導入模塊: from PyQt5 import QtWidgets [as 別名]
# 或者: from PyQt5.QtWidgets import QApplication [as 別名]
def mainPyQt5():
    # 必要なモジュールのimport
    from PyQt5.QtWidgets import QApplication
    from PyQt5.QtCore import QUrl
    from PyQt5.QtWebEngineWidgets import QWebEngineView

    url = 'https://github.com/tody411/PyIntroduction'

    app = QApplication(sys.argv)

    # QWebEngineViewによるWebページ表示
    browser = QWebEngineView()
    browser.load(QUrl(url))
    browser.show()

    sys.exit(app.exec_()) 
開發者ID:tody411,項目名稱:PyIntroduction,代碼行數:18,代碼來源:web_browser.py

示例12: runcatCPU

# 需要導入模塊: from PyQt5 import QtWidgets [as 別名]
# 或者: from PyQt5.QtWidgets import QApplication [as 別名]
def runcatCPU():
    app = QApplication(sys.argv)
    # 最後一個可視的窗口退出時程序不退出
    app.setQuitOnLastWindowClosed(False)
    icon = QSystemTrayIcon()
    icon.setIcon(QIcon('icons/0.png'))
    icon.setVisible(True)
    cpu_percent = psutil.cpu_percent(interval=1) / 100
    cpu_percent_update_fps = 20
    fps_count = 0
    while True:
        fps_count += 1
        if fps_count > cpu_percent_update_fps:
            cpu_percent = psutil.cpu_percent(interval=1) / 100
            fps_count = 0
        # 開口向上的拋物線, 左邊遞減
        time_interval = (cpu_percent * cpu_percent - 2 * cpu_percent + 2) / 20
        for i in range(5):
            icon.setIcon(QIcon('icons/%d.png' % i))
            icon.setToolTip('cpu: %.2f' % cpu_percent)
            time.sleep(time_interval)
    app.exec_() 
開發者ID:CharlesPikachu,項目名稱:Tools,代碼行數:24,代碼來源:runcat.py

示例13: runcatMemory

# 需要導入模塊: from PyQt5 import QtWidgets [as 別名]
# 或者: from PyQt5.QtWidgets import QApplication [as 別名]
def runcatMemory():
    app = QApplication(sys.argv)
    # 最後一個可視的窗口退出時程序不退出
    app.setQuitOnLastWindowClosed(False)
    icon = QSystemTrayIcon()
    icon.setIcon(QIcon('icons/0.png'))
    icon.setVisible(True)
    memory_percent = psutil.virtual_memory().percent / 100
    memory_percent_update_fps = 20
    fps_count = 0
    while True:
        fps_count += 1
        if fps_count > memory_percent_update_fps:
            memory_percent = psutil.virtual_memory().percent / 100
            fps_count = 0
        # 開口向上的拋物線, 左邊遞減
        time_interval = (memory_percent * memory_percent - 2 * memory_percent + 2) / 20
        for i in range(5):
            icon.setIcon(QIcon('icons/%d.png' % i))
            icon.setToolTip('memory: %.2f' % memory_percent)
            time.sleep(time_interval)
    app.exec_() 
開發者ID:CharlesPikachu,項目名稱:Tools,代碼行數:24,代碼來源:runcat.py

示例14: init_print

# 需要導入模塊: from PyQt5 import QtWidgets [as 別名]
# 或者: from PyQt5.QtWidgets import QApplication [as 別名]
def init_print(self, linenos=True, style="default"):
        app = QApplication([])  # noqa
        doc = QTextDocument()
        doc.setHtml(
            self.highlight_file(linenos=linenos, style=style)
        )
        printer = QPrinter()
        printer.setOutputFileName(self.pdf_file)
        printer.setOutputFormat(QPrinter.PdfFormat)
        page_size_dict = {"a2": QPrinter.A2, "a3": QPrinter.A3, "a4": QPrinter.A4, "letter": QPrinter.Letter}
        printer.setPageSize(page_size_dict.get(self.size.lower(), QPrinter.A4))
        printer.setPageMargins(15, 15, 15, 15, QPrinter.Millimeter)
        doc.print_(printer)
        logging.info("PDF created at %s" % (self.pdf_file)) 
開發者ID:tushar-rishav,項目名稱:code2pdf,代碼行數:16,代碼來源:code2pdf.py

示例15: main_gui

# 需要導入模塊: from PyQt5 import QtWidgets [as 別名]
# 或者: from PyQt5.QtWidgets import QApplication [as 別名]
def main_gui():
    app = QtWidgets.QApplication(sys.argv)
    #    ui_about = Ui_About()
    #    ui = Ui_MainWindow()

    if platform.system() == 'Linux' and os.getuid() != 0:
        show_admin_info()
        sys.exit(2)

    else:
        window = AppGui()
        window.show()
        window.setWindowTitle("MultiBootUSB - " + mbusb_version())
        window.setWindowIcon(QtGui.QIcon(resource_path(os.path.join("data", "tools", "multibootusb.png"))))
    sys.exit(app.exec_()) 
開發者ID:mbusb,項目名稱:multibootusb,代碼行數:17,代碼來源:mbusb_gui.py


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