本文整理汇总了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_())
示例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
示例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
示例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_())
示例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
示例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)
示例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_())
示例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)
示例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)
示例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用).
示例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_())
示例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_()
示例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_()
示例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))
示例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_())