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


Python Qt.QtCompat类代码示例

本文整理汇总了Python中Qt.QtCompat的典型用法代码示例。如果您正苦于以下问题:Python QtCompat类的具体用法?Python QtCompat怎么用?Python QtCompat使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: test_implicit_wrapInstance

    def test_implicit_wrapInstance():
        """.wrapInstance doesn't need the `base` argument"""
        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))
            assert isinstance(widget, QtWidgets.QWidget), widget
            assert widget.objectName() == button.objectName()

            if binding("PySide"):
                assert widget != button
            elif binding("PySide2") and _pyside2_commit_date() is None:
                assert widget != button
            elif binding("PySide2") and \
                    _pyside2_commit_date() <= datetime.datetime(
                        2017, 8, 25):
                assert widget == button
            else:
                assert widget == button

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

示例2: test_load_ui_baseinstance

def test_load_ui_baseinstance():
    """Tests to see if the baseinstance loading loads widgets on properly"""
    import sys
    from Qt import QtWidgets, QtCompat
    app = QtWidgets.QApplication(sys.argv)
    win = QtWidgets.QWidget()
    QtCompat.loadUi(self.ui_qwidget, win)
    assert hasattr(win, 'lineEdit'), "loadUi could not load instance to win"
    app.exit()
开发者ID:sonictk,项目名称:Qt.py,代码行数:9,代码来源:tests.py

示例3: LoadUI

 def LoadUI(self, obj):
     path = inspect.getsourcefile(obj.__class__).replace('\\','/')
     relpath = path.split(self['CoreDirectory'],1)[-1].rsplit('.',1)[0]+'.ui'
     uipath = self.GetOverriddenPath(relpath)
     print('path', path)
     print('self[CoreDirectory]', self['CoreDirectory'])
     print('relpath', relpath)
     print('uipath', uipath)
     
     if os.path.exists(uipath):
         QtCompat.loadUi(uipath, baseinstance=obj)
开发者ID:ThomasMcVay,项目名称:MediaApp,代码行数:11,代码来源:Core.py

示例4: test_meta_remap

def test_meta_remap():
    """Qt._remap() appends to __modified__"""
    from Qt import QtCompat

    module = imp.new_module("QtMock")

    QtCompat._remap(module, "MyAttr", None)

    assert "MyAttr" not in QtCompat.__added__, QtCompat.__added__
    assert "MyAttr" in QtCompat.__remapped__
    assert "MyAttr" not in QtCompat.__modified__
开发者ID:abstractfactory,项目名称:Qt.py,代码行数:11,代码来源:tests.py

示例5: test_load_ui_signals

def test_load_ui_signals():
    """Tests to see if the baseinstance loading loads widgets on properly"""
    import sys
    from Qt import QtWidgets, QtCompat
    app = QtWidgets.QApplication(sys.argv)
    win = QtWidgets.QWidget()
    QtCompat.loadUi(self.ui_qwidget, win)

    win.lineEdit.setText('Hello')
    assert str(win.label.text()) == 'Hello', "lineEdit signal did not fire"

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

示例6: setData

	def setData( self, data ) :

		# it could be argued that we should early out here if data is self.getData(),
		# but we can't right now as we're relying on setData() to update everything
		# when the data has been modified in place by some external process, or
		# by self.__removeSelection.

		if data is not None :
			if not isinstance( data, list ) :
				data = [ data ]
			self.__model = _Model( data, self.__tableView, self.getEditable(), self.__headerOverride, self.__columnToolTips, self.__columnEditability )
			self.__model.dataChanged.connect( Gaffer.WeakMethod( self.__modelDataChanged ) )
			self.__model.rowsInserted.connect( Gaffer.WeakMethod( self.__emitDataChangedSignal ) )
			self.__model.rowsRemoved.connect( Gaffer.WeakMethod( self.__emitDataChangedSignal ) )
		else :
			self.__model = None

		self.__tableView.setModel( self.__model )

		if self.__model :

			columnIndex = 0
			haveResizeableContents = False
			for accessor in self.__model.vectorDataAccessors() :
				for i in range( 0, accessor.numColumns() ) :
					delegate = _Delegate.create( accessor.data() )
					delegate.setParent( self.__model )
					self.__tableView.setItemDelegateForColumn( columnIndex, delegate )
					canStretch = delegate.canStretch()
					haveResizeableContents = haveResizeableContents or canStretch
					columnIndex += 1

			QtCompat.setSectionResizeMode(
				self.__tableView.horizontalHeader(),
				QtWidgets.QHeaderView.ResizeToContents if haveResizeableContents else QtWidgets.QHeaderView.Fixed
			)
			self.__tableView.horizontalHeader().setStretchLastSection( canStretch )
			self.__tableView.setSizePolicy(
				QtWidgets.QSizePolicy(
					QtWidgets.QSizePolicy.Expanding if canStretch else QtWidgets.QSizePolicy.Fixed,
					QtWidgets.QSizePolicy.Maximum
				)
			)

			selectionModel = self.__tableView.selectionModel()
			selectionModel.selectionChanged.connect( Gaffer.WeakMethod( self.__selectionChanged ) )

		self.__updateRemoveButtonEnabled()

		# Somehow the QTableView can leave its header in a state where updates are disabled.
		# If we didn't turn them back on, the header would disappear.
		self.__tableView.verticalHeader().setUpdatesEnabled( True )
		self.__tableView.updateGeometry()
开发者ID:boberfly,项目名称:gaffer,代码行数:53,代码来源:VectorDataWidget.py

示例7: test_meta_force_remap_existing

def test_meta_force_remap_existing():
    """Unsafe Qt._remap() of existing member adds to modified"""
    from Qt import QtCompat

    module = imp.new_module("QtMock")
    module.MyAttr = 123

    QtCompat._remap(module, "MyAttr", None, safe=False)

    assert "MyAttr" in QtCompat.__remapped__, QtCompat.__remapped__
    assert "MyAttr" not in QtCompat.__added__
    assert "MyAttr" in QtCompat.__modified__
    assert module.MyAttr is None, module.MyAttr
开发者ID:abstractfactory,项目名称:Qt.py,代码行数:13,代码来源:tests.py

示例8: test_load_ui_dockwidget

def test_load_ui_dockwidget():
    """Tests to see if the baseinstance loading loads a QDockWidget properly"""
    import sys
    from Qt import QtWidgets, QtCompat

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

    QtCompat.loadUi(self.ui_qdockwidget, win)

    assert hasattr(win, 'lineEdit'), \
        "loadUi could not load instance to main window"

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

示例9: test_load_ui_existingLayoutOnWidget

def test_load_ui_existingLayoutOnWidget():
    """Tests to see if loading a ui onto a layout in a Widget works"""
    import sys
    from Qt import QtWidgets, QtCompat

    msgs = 'QLayout: Attempting to add QLayout "" to QWidget ' \
        '"Form", which already has a layout'

    with ignoreQtMessageHandler([msgs]):
        app = QtWidgets.QApplication(sys.argv)
        win = QtWidgets.QWidget()
        QtWidgets.QComboBox(win)
        QtWidgets.QHBoxLayout(win)
        QtCompat.loadUi(self.ui_qwidget, win)
    app.exit()
开发者ID:mottosso,项目名称:Qt.py,代码行数:15,代码来源:tests.py

示例10: test_convert_backup

def test_convert_backup():
    """Converting produces a backup"""

    fname = os.path.join(self.tempdir, "idempotency.py")
    with open(fname, "w") as f:
        f.write("")

    from Qt import QtCompat

    os.chdir(self.tempdir)
    QtCompat.cli(args=["--convert", "idempotency.py"])

    assert os.path.exists(
        os.path.join(self.tempdir, "%s_backup%s" % os.path.splitext(fname))
    )
开发者ID:abstractfactory,项目名称:Qt.py,代码行数:15,代码来源:tests.py

示例11: test_convert_simple

def test_convert_simple():
    """python -m Qt --convert works in general"""
    before = """\
from PySide2 import QtCore, QtGui, QtWidgets

class Ui_uic(object):
    def setupUi(self, uic):
        self.retranslateUi(uic)

    def retranslateUi(self, uic):
        self.pushButton_2.setText(
            QtWidgets.QApplication.translate("uic", "NOT Ok", None, -1))
""".split("\n")

    after = """\
from Qt import QtCompat, QtCore, QtGui, QtWidgets

class Ui_uic(object):
    def setupUi(self, uic):
        self.retranslateUi(uic)

    def retranslateUi(self, uic):
        self.pushButton_2.setText(
            QtCompat.translate("uic", "NOT Ok", None, -1))
""".split("\n")

    from Qt import QtCompat
    assert QtCompat._convert(before) == after, after
开发者ID:sonictk,项目名称:Qt.py,代码行数:28,代码来源:tests.py

示例12: test_load_ui_returntype

def test_load_ui_returntype():
    """load_ui returns an instance of QObject"""

    import sys
    from Qt import QtWidgets, QtCore, QtCompat
    app = QtWidgets.QApplication(sys.argv)
    obj = QtCompat.loadUi(self.ui_qwidget)
    assert isinstance(obj, QtCore.QObject)
    app.exit()
开发者ID:sonictk,项目名称:Qt.py,代码行数:9,代码来源:tests.py

示例13: test_load_ui_customwidget

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,代码行数:18,代码来源:tests.py

示例14: ignoreQtMessageHandler

def ignoreQtMessageHandler(msgs):
    """A context that ignores specific qMessages for all bindings

    Args:
        msgs: list of message strings to ignore
    """
    from Qt import QtCompat

    def messageOutputHandler(msgType, logContext, msg):
        if msg in msgs:
            return
        sys.stderr.write("{0}\n".format(msg))

    QtCompat.qInstallMessageHandler(messageOutputHandler)
    try:
        yield
    finally:
        QtCompat.qInstallMessageHandler(None)
开发者ID:mottosso,项目名称:Qt.py,代码行数:18,代码来源:tests.py

示例15: __init__

    def __init__(self):
        super(Dialog, self).__init__()

        layout = QtWidgets.QVBoxLayout(self)
        layout.setContentsMargins(0, 10, 0, 0)
        fname = os.path.splitext(__file__)[0] + ".ui"
        self.ui = QtCompat.load_ui(fname=fname)
        layout.addWidget(self.ui)

        self.create_connections()
开发者ID:Bumpybox,项目名称:Tapp,代码行数:10,代码来源:dialog.py


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