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