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


Python QtWidgets.QApplication方法代码示例

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


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

示例1: convert

# 需要导入模块: from PySide2 import QtWidgets [as 别名]
# 或者: from PySide2.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

示例2: main

# 需要导入模块: from PySide2 import QtWidgets [as 别名]
# 或者: from PySide2.QtWidgets import QApplication [as 别名]
def main():
    app = QtWidgets.QApplication(sys.argv)
    viewer = quarter.QuarterWidget()
    # build a scene (sphere, cube)
    plane = coin.SbPlane(coin.SbVec3f(0, 0, 1), coin.SbVec3f(0, 0, 0))
    root = coin.SoSeparator()
    myCallback = coin.SoCallback()
    cap = CapPlane(plane, root)
    myCallback.setCallback(myCallbackRoutine, cap)
    root += myCallback, coin.SoSphere()

    viewer.setSceneGraph(root)
    viewer.setBackgroundColor(coin.SbColor(.5, .5, .5))
    viewer.setWindowTitle("GL stencil buffer")

    viewer.show()

    sys.exit(app.exec_()) 
开发者ID:coin3d,项目名称:pivy,代码行数:20,代码来源:GlClipPlane.py

示例3: __init__

# 需要导入模块: from PySide2 import QtWidgets [as 别名]
# 或者: from PySide2.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

示例4: mouseMoveEvent

# 需要导入模块: from PySide2 import QtWidgets [as 别名]
# 或者: from PySide2.QtWidgets import QApplication [as 别名]
def mouseMoveEvent(self, event):
		if (event.pos() - self.dragStartPosition).manhattanLength() < QApplication.startDragDistance():
			return

		event.accept()
		print('starting drag event')
		self.latentDragged.emit(self.latentCluster)

		self.setActive()

		width = self.mainWidget.getCurrentLatentSize()

		dragPix = self.image.scaled(width, width)
		drag = QDrag(self)
		drag.setMimeData(QMimeData(self))
		drag.setPixmap(dragPix)
		drag.setHotSpot(QPoint(drag.pixmap().width() // 2, drag.pixmap().height() // 2))
		self.mainWidget.viewer.setDrag(drag)
		dropAction = drag.start(QtCore.Qt.MoveAction)

		print('created drag with pixmap of size {}x{}'.format(width, width)) 
开发者ID:afruehstueck,项目名称:tileGAN,代码行数:23,代码来源:tileGAN_client.py

示例5: quickModKeyAsk

# 需要导入模块: from PySide2 import QtWidgets [as 别名]
# 或者: from PySide2.QtWidgets import QApplication [as 别名]
def quickModKeyAsk(self):
        modifiers = QtWidgets.QApplication.queryKeyboardModifiers()
        clickMode = 0 # basic mode
        if modifiers == QtCore.Qt.ControlModifier:
            clickMode = 1 # ctrl
        elif modifiers == QtCore.Qt.ShiftModifier:
            clickMode = 2 # shift
        elif modifiers == QtCore.Qt.AltModifier:
            clickMode = 3 # alt
        elif modifiers == QtCore.Qt.ControlModifier | QtCore.Qt.ShiftModifier | QtCore.Qt.AltModifier:
            clickMode = 4 # ctrl+shift+alt
        elif modifiers == QtCore.Qt.ControlModifier | QtCore.Qt.AltModifier:
            clickMode = 5 # ctrl+alt
        elif modifiers == QtCore.Qt.ControlModifier | QtCore.Qt.ShiftModifier:
            clickMode = 6 # ctrl+shift
        elif modifiers == QtCore.Qt.AltModifier | QtCore.Qt.ShiftModifier:
            clickMode = 7 # alt+shift
        return clickMode 
开发者ID:shiningdesign,项目名称:universal_tool_template.py,代码行数:20,代码来源:universal_tool_template_1116.py

示例6: test_load_ui_customwidget

# 需要导入模块: from PySide2 import QtWidgets [as 别名]
# 或者: from PySide2.QtWidgets import QApplication [as 别名]
def test_load_ui_customwidget():
    """Tests to see if loadUi loads a custom widget properly"""
    import sys
    from Qt import QtWidgets, QtCompat

    app = QtWidgets.QApplication(sys.argv)
    win = QtWidgets.QMainWindow()

    QtCompat.loadUi(self.ui_qcustomwidget, win)

    # Ensure that the derived class was properly created
    # and not the base class (in case of failure)
    custom_class_name = getattr(win, "customwidget", None).__class__.__name__
    excepted_class_name = CustomWidget(win).__class__.__name__
    assert custom_class_name == excepted_class_name, \
        "loadUi could not load custom widget to main window"

    app.exit() 
开发者ID:mottosso,项目名称:Qt.py,代码行数:20,代码来源:tests.py

示例7: test_load_ui_invalidxml

# 需要导入模块: from PySide2 import QtWidgets [as 别名]
# 或者: from PySide2.QtWidgets import QApplication [as 别名]
def test_load_ui_invalidxml():
    """Tests to see if loadUi successfully fails on invalid ui files"""
    import sys
    invalid_xml = os.path.join(self.tempdir, "invalid.ui")
    with io.open(invalid_xml, "w", encoding="utf-8") as f:
        f.write(u"""
        <?xml version="1.0" encoding="UTF-8"?>
        <ui version="4.0" garbage
        </ui>
        """)

    from xml.etree import ElementTree
    from Qt import QtWidgets, QtCompat
    app = QtWidgets.QApplication(sys.argv)
    assert_raises(ElementTree.ParseError, QtCompat.loadUi, invalid_xml)
    app.exit() 
开发者ID:mottosso,项目名称:Qt.py,代码行数:18,代码来源:tests.py

示例8: test_qtcompat_base_class

# 需要导入模块: from PySide2 import QtWidgets [as 别名]
# 或者: from PySide2.QtWidgets import QApplication [as 别名]
def test_qtcompat_base_class():
    """Tests to ensure the QtCompat namespace object works as expected"""
    import sys
    import Qt
    from Qt import QtWidgets
    from Qt import QtCompat
    app = QtWidgets.QApplication(sys.argv)
    # suppress `local variable 'app' is assigned to but never used`
    app
    header = QtWidgets.QHeaderView(Qt.QtCore.Qt.Horizontal)

    # Spot check compatibility functions
    QtCompat.QHeaderView.setSectionsMovable(header, False)
    assert QtCompat.QHeaderView.sectionsMovable(header) is False
    QtCompat.QHeaderView.setSectionsMovable(header, True)
    assert QtCompat.QHeaderView.sectionsMovable(header) is True

    # Verify that the grab function actually generates a non-null image
    button = QtWidgets.QPushButton('TestImage')
    pixmap = QtCompat.QWidget.grab(button)
    assert not pixmap.isNull() 
开发者ID:mottosso,项目名称:Qt.py,代码行数:23,代码来源:tests.py

示例9: test_wrapInstance

# 需要导入模块: from PySide2 import QtWidgets [as 别名]
# 或者: from PySide2.QtWidgets import QApplication [as 别名]
def test_wrapInstance():
        """.wrapInstance and .getCppPointer is identical across all bindings"""
        from Qt import QtCompat, QtWidgets

        app = QtWidgets.QApplication(sys.argv)

        try:
            button = QtWidgets.QPushButton("Hello world")
            button.setObjectName("MySpecialButton")
            pointer = QtCompat.getCppPointer(button)
            widget = QtCompat.wrapInstance(long(pointer),
                                           QtWidgets.QWidget)
            assert isinstance(widget, QtWidgets.QWidget), widget
            assert widget.objectName() == button.objectName()

            # IMPORTANT: this differs across sip and shiboken.
            if binding("PySide") or binding("PySide2"):
                assert widget != button
            else:
                assert widget == button

        finally:
            app.exit() 
开发者ID:mottosso,项目名称:Qt.py,代码行数:25,代码来源:tests.py

示例10: main

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

    app.setWindowIcon(QIcon(':/icons/app.svg'))

    fontDB = QFontDatabase()
    fontDB.addApplicationFont(':/fonts/Roboto-Regular.ttf')
    app.setFont(QFont('Roboto'))

    f = QFile(':/style.qss')
    f.open(QFile.ReadOnly | QFile.Text)
    app.setStyleSheet(QTextStream(f).readAll())
    f.close()

    translator = QTranslator()
    translator.load(':/translations/' + QLocale.system().name() + '.qm')
    app.installTranslator(translator)

    mw = MainWindow()
    mw.show()

    sys.exit(app.exec_()) 
开发者ID:gmarull,项目名称:pyside2-boilerplate,代码行数:24,代码来源:__main__.py

示例11: retranslateUi

# 需要导入模块: from PySide2 import QtWidgets [as 别名]
# 或者: from PySide2.QtWidgets import QApplication [as 别名]
def retranslateUi(self, Dialog):
        Dialog.setWindowTitle(QtWidgets.QApplication.translate("Dialog", "Dialog", None, -1))
        self.open_button.setToolTip(QtWidgets.QApplication.translate("Dialog", "Import file", None, -1))
        self.label_5.setText(QtWidgets.QApplication.translate("Dialog", "Units", None, -1))
        self.autolink_button.setToolTip(QtWidgets.QApplication.translate("Dialog", "Automatic link profiles to objects based on their name", None, -1))
        self.autolink_slider.setToolTip(QtWidgets.QApplication.translate("Dialog", "Auto-link string simmilarity", None, -1))
        self.rnd_link_pushButton.setToolTip(QtWidgets.QApplication.translate("Dialog", "Random-link profiles and objects", None, -1))
        self.assign_to_all_pushButton.setToolTip(QtWidgets.QApplication.translate("Dialog", "Assign profile to all objects", None, -1))
        self.assign_to_selection_pushButton.setToolTip(QtWidgets.QApplication.translate("Dialog", "Assign profile to object selection", None, -1))
        self.clear_selection_button.setToolTip(QtWidgets.QApplication.translate("Dialog", "Clear selection", None, -1))
        self.set_multiplier_button.setToolTip(QtWidgets.QApplication.translate("Dialog", "Set multiplier", None, -1))
        self.doit_button.setToolTip(QtWidgets.QApplication.translate("Dialog", "Do it!", None, -1))
        self.doit_button.setText(QtWidgets.QApplication.translate("Dialog", "Accept", None, -1))
        self.normalized_checkBox.setToolTip(QtWidgets.QApplication.translate("Dialog", "Check if you want the profiles to be normalized on the base object property", None, -1))
        self.normalized_checkBox.setText(QtWidgets.QApplication.translate("Dialog", "normalized", None, -1))
        self.tabWidget.setTabText(self.tabWidget.indexOf(self.tab), QtWidgets.QApplication.translate("Dialog", "Assignation", None, -1))
        self.tabWidget.setTabText(self.tabWidget.indexOf(self.tab_2), QtWidgets.QApplication.translate("Dialog", "Plot", None, -1)) 
开发者ID:SanPen,项目名称:GridCal,代码行数:19,代码来源:gui.py

示例12: retranslateUi

# 需要导入模块: from PySide2 import QtWidgets [as 别名]
# 或者: from PySide2.QtWidgets import QApplication [as 别名]
def retranslateUi(self, Dialog):
        Dialog.setWindowTitle(QtWidgets.QApplication.translate("Dialog", "Tower creation", None, -1))
        self.label_9.setText(QtWidgets.QApplication.translate("Dialog", "Name", None, -1))
        self.label_8.setText(QtWidgets.QApplication.translate("Dialog", "Frequency (Hz)", None, -1))
        self.label_11.setText(QtWidgets.QApplication.translate("Dialog", "Earth resistivity (Ohm/m^3)", None, -1))
        self.label_12.setText(QtWidgets.QApplication.translate("Dialog", "Wire catalogue", None, -1))
        self.label_10.setText(QtWidgets.QApplication.translate("Dialog", "Wire compisition", None, -1))
        self.add_to_tower_pushButton.setToolTip(QtWidgets.QApplication.translate("Dialog", "Add wire", None, -1))
        self.delete_from_tower_pushButton.setToolTip(QtWidgets.QApplication.translate("Dialog", "Delete wire", None, -1))
        self.compute_pushButton.setToolTip(QtWidgets.QApplication.translate("Dialog", "Compute matrices", None, -1))
        self.label_4.setText(QtWidgets.QApplication.translate("Dialog", "Tower", None, -1))
        self.tabWidget.setTabText(self.tabWidget.indexOf(self.tab_2), QtWidgets.QApplication.translate("Dialog", "Tower", None, -1))
        self.label.setText(QtWidgets.QApplication.translate("Dialog", "   Z series (Ohm / km) for ABCN", None, -1))
        self.label_6.setText(QtWidgets.QApplication.translate("Dialog", "   Z series (Ohm / km) for ABC", None, -1))
        self.label_7.setText(QtWidgets.QApplication.translate("Dialog", "   Z series (Ohm / km) in sequence components", None, -1))
        self.tabWidget.setTabText(self.tabWidget.indexOf(self.tab), QtWidgets.QApplication.translate("Dialog", "Z series", None, -1))
        self.label_2.setText(QtWidgets.QApplication.translate("Dialog", "   Y shunt (uS / km) for ABCN", None, -1))
        self.label_3.setText(QtWidgets.QApplication.translate("Dialog", "   Y shunt (uS / km) for ABC", None, -1))
        self.label_5.setText(QtWidgets.QApplication.translate("Dialog", "   Y shunt (uS / km) for the sequence components", None, -1))
        self.tabWidget.setTabText(self.tabWidget.indexOf(self.tab_3), QtWidgets.QApplication.translate("Dialog", "Y shunt", None, -1)) 
开发者ID:SanPen,项目名称:GridCal,代码行数:22,代码来源:gui.py

示例13: main

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

    root = coin.SoSeparator()
    

    vert = coin.SoVertexShader()
    vert.sourceProgram = "vertex.glsl"
    
    frag = coin.SoFragmentShader()
    frag.sourceProgram = "frag.glsl"
    
    shaders = [vert,frag]
    pro = coin.SoShaderProgram()
    pro.shaderObject.setValues(0,len(shaders),shaders)
    
    
    mat = coin.SoMaterial()
    mat.diffuseColor.setValue(coin.SbColor(0.8, 0.8, 0.8))
    mat.specularColor.setValue(coin.SbColor(1, 1, 1))
    mat.shininess.setValue(1.0)
    mat.transparency.setValue(0.5)
    
    
    
    
    sphere = coin.SoSphere()
    sphere.radius = 1.2
    
    
    root.addChild(pro)
    root.addChild(sphere)
    root.addChild(mat)
    root.addChild(coin.SoCube())

    viewer = quarter.QuarterWidget()
    viewer.setSceneGraph(root)

    viewer.setWindowTitle("minimal")
    viewer.show()
    sys.exit(app.exec_()) 
开发者ID:tomate44,项目名称:CurvesWB,代码行数:43,代码来源:shaders.py

示例14: main

# 需要导入模块: from PySide2 import QtWidgets [as 别名]
# 或者: from PySide2.QtWidgets import QApplication [as 别名]
def main():
	app = QtWidgets.QApplication(sys.argv)
	pt = PTable()
	pt.selectAtomtype("N")
	pt.show()
	sys.exit(app.exec_()) 
开发者ID:EBjerrum,项目名称:rdeditor,代码行数:8,代码来源:ptable_widget.py

示例15: main

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

    root = coin.SoSeparator()
    root += coin.SoCone()
    root += test()

    viewer.setSceneGraph(root)
    viewer.setBackgroundColor(QColor(255, 255, 255))
    viewer.setWindowTitle("minimal")
    viewer.show()
    sys.exit(app.exec_()) 
开发者ID:coin3d,项目名称:pivy,代码行数:15,代码来源:event_callback.py


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