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


Python QtWidgets.QWidget方法代碼示例

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


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

示例1: __makeWidgets

# 需要導入模塊: from Qt import QtWidgets [as 別名]
# 或者: from Qt.QtWidgets import QWidget [as 別名]
def __makeWidgets(self):
        self.setMinimumWidth(450)
        self.setMinimumHeight(300)
        self.__central_widget = QtWidgets.QWidget()
        self.__central_layout = QtWidgets.QVBoxLayout()
        self.setCentralWidget(self.__central_widget)
        self.__central_widget.setLayout(self.__central_layout)

        self.__top_widget = widgets.TopBarWidget()
        self.__main_widget = widgets.MainWidget(visitorClass=self.__visitor_class)

        self.__central_layout.addWidget(self.__top_widget)
        self.__central_layout.addWidget(self.__main_widget)
        self.__central_layout.setSpacing(0)
        self.__central_layout.setContentsMargins(0, 0, 0, 0)

        self.__top_widget.setBrowserButtonEnabled(False, False)
        self.__main_widget.ConditionChanged.connect(self.__top_widget.setBrowserButtonEnabled)
        self.__main_widget.KarteChanged.connect(self.__top_widget.setCurrentKarteName)
        self.__top_widget.BackClicked.connect(self.__back)
        self.__top_widget.NextClicked.connect(self.__next)
        self.__top_widget.SelectionOnlyChanged.connect(self.__main_widget.setSelectionOnly)
        self.__top_widget.reset_button.clicked.connect(self.__main_widget.reset)
        self.__top_widget.test_button.clicked.connect(self.__main_widget.test)
        self.__main_widget.StatusChanged.connect(self.__top_widget.status_label.setStatus) 
開發者ID:sol-ansano-kim,項目名稱:medic,代碼行數:27,代碼來源:window.py

示例2: __init__

# 需要導入模塊: from Qt import QtWidgets [as 別名]
# 或者: from Qt.QtWidgets import QWidget [as 別名]
def __init__(self, raw_tick, parent=None):
        """
        :param raw_tick: Input Core Tick
        :type raw_tick: :obj:`PyFlow.Core.structs.Tick`
        :param parent: Parent QWidget
        :type parent: QtWidgets.QWidget, optional
        """
        super(uiTick, self).__init__(parent)
        self.setAcceptHoverEvents(True)
        self._width = 6
        self._height = 6
        self.hovered = False
        self.setFlag(QtWidgets.QGraphicsWidget.ItemIsMovable)
        self.setFlag(QtWidgets.QGraphicsWidget.ItemIsFocusable)
        self.setFlag(QtWidgets.QGraphicsWidget.ItemIsSelectable, True)
        self.setFlag(QtWidgets.QGraphicsWidget.ItemSendsGeometryChanges)
        self._rawTick = raw_tick
        self._color = QtGui.QColor(0) 
開發者ID:wonderworks-software,項目名稱:PyFlow,代碼行數:20,代碼來源:QtSliders.py

示例3: setupUi

# 需要導入模塊: from Qt import QtWidgets [as 別名]
# 或者: from Qt.QtWidgets import QWidget [as 別名]
def setupUi(self, Form):
        Form.setObjectName("Form")
        Form.resize(228, 30)
        self.horizontalLayout = QtWidgets.QHBoxLayout(Form)
        self.horizontalLayout.setSpacing(1)
        self.horizontalLayout.setContentsMargins(1, 1, 1, 1)
        self.horizontalLayout.setObjectName("horizontalLayout")
        self.widget = QtWidgets.QWidget(Form)
        self.widget.setObjectName("widget")
        self.horizontalLayout.addWidget(self.widget)
        self.labelName = QtWidgets.QLabel(Form)
        self.labelName.setObjectName("labelName")
        self.horizontalLayout.addWidget(self.labelName)
        spacerItem = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum)
        self.horizontalLayout.addItem(spacerItem)
        self.pbKill = QtWidgets.QPushButton(Form)
        self.pbKill.setMaximumSize(QtCore.QSize(40, 16777215))
        self.pbKill.setText("")
        self.pbKill.setObjectName("pbKill")
        self.horizontalLayout.addWidget(self.pbKill)

        self.retranslateUi(Form)
        QtCore.QMetaObject.connectSlotsByName(Form) 
開發者ID:wonderworks-software,項目名稱:PyFlow,代碼行數:25,代碼來源:VariableForm_ui.py

示例4: __init__

# 需要導入模塊: from Qt import QtWidgets [as 別名]
# 或者: from Qt.QtWidgets import QWidget [as 別名]
def __init__(self, light):
        # Our init function takes the name of a light

        # We then call the init from QWidget to make sure that our object is initialized properly
        super(LightWidget, self).__init__()

        # If the light is a string, we want to convert it to a PyMel object to deal with it easier
        # The isInstance checks if it is of type basestring (which includes all the various string types)
        if isinstance(light, basestring):
            logger.debug('Converting node to a PyNode')
            light = pm.PyNode(light)

        # We might also get passed the transform instead of the light shape, either as a PyNode or a name.
        # So we'll check if it's a transform node and then get the shape
        if isinstance(light, pm.nodetypes.Transform):
            light = light.getShape()

        # Then we store the pyMel node on this class
        self.light = light

        # Finally we call the buildUI method
        self.buildUI() 
開發者ID:dgovil,項目名稱:PythonForMayaSamples,代碼行數:24,代碼來源:lightManager2016Below.py

示例5: getDock

# 需要導入模塊: from Qt import QtWidgets [as 別名]
# 或者: from Qt.QtWidgets import QWidget [as 別名]
def getDock(name='LightingManagerDock'):
    """
    This function creates a dock with the given name.
    It's an example of how we can mix Maya's UI elements with Qt elements
    Args:
        name: The name of the dock to create

    Returns:
        QtWidget.QWidget: The dock's widget
    """
    # First lets delete any conflicting docks
    deleteDock(name)
    # Then we create a dockControl dock using Maya's UI tools
    # This gives us back the name of the dock created
    
    # <=Maya2016: In Maya 2016 and below, we just give our Light Managers object name to the dockControl.
    # You can see this name when we do self.setObjectName in the LightManagers __init__ method
    ctrl = pm.dockControl(name, area='right', content='lightingManager', allowedArea='all', label="Lighting Manager")

    # And then we return the control name
    return ctrl 
開發者ID:dgovil,項目名稱:PythonForMayaSamples,代碼行數:23,代碼來源:lightManager2016Below.py

示例6: test_qtcompat_base_class

# 需要導入模塊: from Qt import QtWidgets [as 別名]
# 或者: from Qt.QtWidgets import QWidget [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

示例7: setup_ui

# 需要導入模塊: from Qt import QtWidgets [as 別名]
# 或者: from Qt.QtWidgets import QWidget [as 別名]
def setup_ui(uifile, base_instance=None):
    """Load a Qt Designer .ui file and returns an instance of the user interface

    Args:
        uifile (str): Absolute path to .ui file
        base_instance (QWidget): The widget into which UI widgets are loaded

    Returns:
        QWidget: the base instance

    """
    ui = QtCompat.loadUi(uifile)  # Qt.py mapped function
    if not base_instance:
        return ui
    else:
        for member in dir(ui):
            if not member.startswith('__') and \
               member is not 'staticMetaObject':
                setattr(base_instance, member, getattr(ui, member))
        return ui 
開發者ID:mottosso,項目名稱:Qt.py,代碼行數:22,代碼來源:baseinstance1.py

示例8: test

# 需要導入模塊: from Qt import QtWidgets [as 別名]
# 或者: from Qt.QtWidgets import QWidget [as 別名]
def test():
    """Example: QtCompat.loadUi with setup_ui wrapper"""
    working_directory = os.path.dirname(__file__)
    os.chdir(working_directory)

    app = QtWidgets.QApplication(sys.argv)
    window = MainWindow()

    # Tests
    assert isinstance(window, QtWidgets.QWidget)
    assert isinstance(window.parent(), type(None))
    assert isinstance(window.base_instance, QtWidgets.QWidget)
    assert isinstance(window.lineEdit, QtWidgets.QWidget)
    assert window.lineEdit.text() == ''
    window.lineEdit.setText('Hello')
    assert window.lineEdit.text() == 'Hello'

    app.exit() 
開發者ID:mottosso,項目名稱:Qt.py,代碼行數:20,代碼來源:baseinstance1.py

示例9: load_ui_wrapper

# 需要導入模塊: from Qt import QtWidgets [as 別名]
# 或者: from Qt.QtWidgets import QWidget [as 別名]
def load_ui_wrapper(uifile, base_instance=None):
    """Load a Qt Designer .ui file and returns an instance of the user interface

    Args:
        uifile (str): Absolute path to .ui file
        base_instance (QWidget): The widget into which UI widgets are loaded

    Returns:
        function: pyside_load_ui or uic.loadUi

    """
    if 'PySide' in __binding__:
        return pyside_load_ui(uifile, base_instance)
    elif 'PyQt' in __binding__:
        uic = __import__(__binding__ + ".uic").uic
        return uic.loadUi(uifile, base_instance) 
開發者ID:mottosso,項目名稱:Qt.py,代碼行數:18,代碼來源:baseinstance2.py

示例10: test

# 需要導入模塊: from Qt import QtWidgets [as 別名]
# 或者: from Qt.QtWidgets import QWidget [as 別名]
def test():
    """Example: load_ui with custom uic.loadUi-like wrapper"""
    working_directory = os.path.dirname(__file__)
    os.chdir(working_directory)

    app = QtWidgets.QApplication(sys.argv)
    window = MainWindow()

    # Tests
    assert isinstance(window, QtWidgets.QWidget)
    assert isinstance(window.parent(), type(None))
    assert isinstance(window.base_instance, QtWidgets.QWidget)
    assert isinstance(window.lineEdit, QtWidgets.QWidget)
    assert window.lineEdit.text() == ''
    window.lineEdit.setText('Hello')
    assert window.lineEdit.text() == 'Hello'

    app.exit() 
開發者ID:mottosso,項目名稱:Qt.py,代碼行數:20,代碼來源:baseinstance2.py

示例11: newWindow

# 需要導入模塊: from Qt import QtWidgets [as 別名]
# 或者: from Qt.QtWidgets import QWidget [as 別名]
def newWindow(self):
        """ Create a new window.
        
        :Returns:
            New main window widget
        :Rtype:
            `QtGui.QWidget`
        """
        return self.app.newWindow() 
開發者ID:dreamworksanimation,項目名稱:usdmanager,代碼行數:11,代碼來源:__init__.py

示例12: changeTab

# 需要導入模塊: from Qt import QtWidgets [as 別名]
# 或者: from Qt.QtWidgets import QWidget [as 別名]
def changeTab(self, tab):
        """ Set the current tab to the calling tab.
        
        :Parameters:
            tab : `QtWidgets.QWidget`
                Tab widget
        """
        self.tabWidget.setCurrentWidget(tab) 
開發者ID:dreamworksanimation,項目名稱:usdmanager,代碼行數:10,代碼來源:__init__.py

示例13: __init__

# 需要導入模塊: from Qt import QtWidgets [as 別名]
# 或者: from Qt.QtWidgets import QWidget [as 別名]
def __init__(self, name, parent=None):
        QtWidgets.QWidget.__init__(self, parent)
        self.name = name
        self.parent = parent

        self.graph_scene = Scene(parent=self.parent,
                                 nodegraph_widget=self)
        self.graph_view = View(self.graph_scene, parent=self.parent)
        self.horizontal_layout = QtWidgets.QHBoxLayout(self)
        self.horizontal_layout.addWidget(self.graph_view) 
開發者ID:dsideb,項目名稱:nodegraph-pyqt,代碼行數:12,代碼來源:main_perftest.py

示例14: __init__

# 需要導入模塊: from Qt import QtWidgets [as 別名]
# 或者: from Qt.QtWidgets import QWidget [as 別名]
def __init__(self):
        super(VariablesTool, self).__init__()
        self.setMinimumSize(QtCore.QSize(200, 50))
        self.varsWidget = None
        self.content = QWidget()
        self.content.setObjectName("VariablesToolContent")
        self.verticalLayout = QVBoxLayout(self.content)
        self.verticalLayout.setSpacing(0)
        self.verticalLayout.setContentsMargins(0, 0, 0, 0)
        self.verticalLayout.setObjectName("verticalLayout")
        self.setWidget(self.content) 
開發者ID:wonderworks-software,項目名稱:PyFlow,代碼行數:13,代碼來源:VariablesTool.py

示例15: setupUi

# 需要導入模塊: from Qt import QtWidgets [as 別名]
# 或者: from Qt.QtWidgets import QWidget [as 別名]
def setupUi(self):
        self.resize(400, 300)
        self.mainVLayout = QtWidgets.QVBoxLayout(self)
        self.mainVLayout.setSpacing(2)
        self.mainVLayout.setContentsMargins(2, 2, 2, 2)
        self.mainVLayout.setObjectName("mainVLayout")
        self.mainVLayout.setSizeConstraint(QtWidgets.QLayout.SetMinAndMaxSize)
        self.pbHead = HeadButton(self)
        self.mainVLayout.addWidget(self.pbHead)
        self.setMinimumHeight(30)
        self.ContentWidget = QtWidgets.QWidget(self)
        sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Preferred, QtWidgets.QSizePolicy.Preferred)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(self.ContentWidget.sizePolicy().hasHeightForWidth())
        self.ContentWidget.setSizePolicy(sizePolicy)
        self.setSizePolicy(QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Preferred, QtWidgets.QSizePolicy.Preferred))
        self.ContentWidget.setObjectName("ContentWidget")
        self.ContentWidget.setContentsMargins(10, 0, 0, 0)
        self.mainVLayout.addWidget(self.ContentWidget)
        self.spacerItem = QtWidgets.QSpacerItem(20, 40, QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Expanding)
        self.mainVLayout.addItem(self.spacerItem)
        self.setWindowTitle(self.objectName())
        self.pbHead.setStyleSheet(self.pbHead.styleSheet() + "\nText-align:left;")
        self.contentHiddenIcon = self.pbHead.style().standardIcon(QtWidgets.QStyle.SP_TitleBarUnshadeButton)
        self.contentVisibleIcon = self.pbHead.style().standardIcon(QtWidgets.QStyle.SP_TitleBarShadeButton)
        self.updateIcon() 
開發者ID:wonderworks-software,項目名稱:PyFlow,代碼行數:29,代碼來源:PropertiesFramework.py


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