本文整理汇总了Python中AnyQt.QtWidgets.QVBoxLayout.itemAt方法的典型用法代码示例。如果您正苦于以下问题:Python QVBoxLayout.itemAt方法的具体用法?Python QVBoxLayout.itemAt怎么用?Python QVBoxLayout.itemAt使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AnyQt.QtWidgets.QVBoxLayout
的用法示例。
在下文中一共展示了QVBoxLayout.itemAt方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: WelcomeDialog
# 需要导入模块: from AnyQt.QtWidgets import QVBoxLayout [as 别名]
# 或者: from AnyQt.QtWidgets.QVBoxLayout import itemAt [as 别名]
#.........这里部分代码省略.........
if self.__showAtStartupCheck.isChecked() != show:
self.__showAtStartupCheck.setChecked(show)
def showAtStartup(self):
"""
Return the 'Show at startup' check box state.
"""
return self.__showAtStartupCheck.isChecked()
def setFeedbackUrl(self, url):
# type: (str) -> None
"""
Set an 'feedback' url. When set a link is displayed in the bottom row.
"""
self.__feedbackUrl = url
if url:
text = self.tr("Help us improve!")
self.__feedbackLabel.setText(
'<a href="{url}">{text}</a>'.format(url=url, text=escape(text))
)
else:
self.__feedbackLabel.setText("")
self.__feedbackLabel.setVisible(bool(url))
def addRow(self, actions, background="light-orange"):
"""Add a row with `actions`.
"""
count = self.__mainLayout.count()
self.insertRow(count, actions, background)
def insertRow(self, index, actions, background="light-orange"):
"""Insert a row with `actions` at `index`.
"""
widget = QWidget(objectName="icon-row")
layout = QHBoxLayout()
layout.setContentsMargins(40, 0, 40, 0)
layout.setSpacing(65)
widget.setLayout(layout)
self.__mainLayout.insertWidget(index, widget, stretch=10,
alignment=Qt.AlignCenter)
for i, action in enumerate(actions):
self.insertAction(index, i, action, background)
def insertAction(self, row, index, action,
background="light-orange"):
"""Insert `action` in `row` in position `index`.
"""
button = self.createButton(action, background)
self.insertButton(row, index, button)
def insertButton(self, row, index, button):
"""Insert `button` in `row` in position `index`.
"""
item = self.__mainLayout.itemAt(row)
layout = item.widget().layout()
layout.insertWidget(index, button)
button.triggered.connect(self.__on_actionTriggered)
def createButton(self, action, background="light-orange"):
"""Create a tool button for action.
"""
button = WelcomeActionButton(self)
button.setDefaultAction(action)
button.setText(action.iconText())
button.setIcon(decorate_welcome_icon(action.icon(), background))
button.setToolTip(action.toolTip())
button.setFixedSize(100, 100)
button.setToolButtonStyle(Qt.ToolButtonTextUnderIcon)
button.setVisible(action.isVisible())
font = QFont(button.font())
font.setPointSize(13)
button.setFont(font)
return button
def buttonAt(self, i, j):
"""Return the button at i-t row and j-th column.
"""
item = self.__mainLayout.itemAt(i)
row = item.widget()
item = row.layout().itemAt(j)
return item.widget()
def triggeredAction(self):
"""Return the action that was triggered by the user.
"""
return self.__triggeredAction
def showEvent(self, event):
# Clear the triggered action before show.
self.__triggeredAction = None
super().showEvent(event)
def __on_actionTriggered(self, action):
"""Called when the button action is triggered.
"""
self.triggered.emit(action)
self.__triggeredAction = action
示例2: WelcomeDialog
# 需要导入模块: from AnyQt.QtWidgets import QVBoxLayout [as 别名]
# 或者: from AnyQt.QtWidgets.QVBoxLayout import itemAt [as 别名]
class WelcomeDialog(QDialog):
"""A welcome widget shown at startup presenting a series
of buttons (actions) for a beginner to choose from.
"""
triggered = Signal(QAction)
def __init__(self, *args, **kwargs):
QDialog.__init__(self, *args, **kwargs)
self.__triggeredAction = None
self.setupUi()
def setupUi(self):
self.setLayout(QVBoxLayout())
self.layout().setContentsMargins(0, 0, 0, 0)
self.layout().setSpacing(0)
self.__mainLayout = QVBoxLayout()
self.__mainLayout.setContentsMargins(0, 40, 0, 40)
self.__mainLayout.setSpacing(65)
self.layout().addLayout(self.__mainLayout)
self.setStyleSheet(WELCOME_WIDGET_BUTTON_STYLE)
bottom_bar = QWidget(objectName="bottom-bar")
bottom_bar_layout = QHBoxLayout()
bottom_bar_layout.setContentsMargins(20, 10, 20, 10)
bottom_bar.setLayout(bottom_bar_layout)
bottom_bar.setSizePolicy(QSizePolicy.MinimumExpanding,
QSizePolicy.Maximum)
check = QCheckBox(self.tr("Show at startup"), bottom_bar)
check.setChecked(False)
self.__showAtStartupCheck = check
feedback = QLabel(
'<a href="http://orange.biolab.si/survey/long.html">Help us improve!</a>')
feedback.setTextInteractionFlags(Qt.TextBrowserInteraction)
feedback.setOpenExternalLinks(True)
bottom_bar_layout.addWidget(check, alignment=Qt.AlignVCenter | \
Qt.AlignLeft)
bottom_bar_layout.addWidget(feedback, alignment=Qt.AlignVCenter | \
Qt.AlignRight)
self.layout().addWidget(bottom_bar, alignment=Qt.AlignBottom,
stretch=1)
self.setSizeGripEnabled(False)
self.setFixedSize(620, 390)
def setShowAtStartup(self, show):
"""
Set the 'Show at startup' check box state.
"""
if self.__showAtStartupCheck.isChecked() != show:
self.__showAtStartupCheck.setChecked(show)
def showAtStartup(self):
"""
Return the 'Show at startup' check box state.
"""
return self.__showAtStartupCheck.isChecked()
def addRow(self, actions, background="light-orange"):
"""Add a row with `actions`.
"""
count = self.__mainLayout.count()
self.insertRow(count, actions, background)
def insertRow(self, index, actions, background="light-orange"):
"""Insert a row with `actions` at `index`.
"""
widget = QWidget(objectName="icon-row")
layout = QHBoxLayout()
layout.setContentsMargins(40, 0, 40, 0)
layout.setSpacing(65)
widget.setLayout(layout)
self.__mainLayout.insertWidget(index, widget, stretch=10,
alignment=Qt.AlignCenter)
for i, action in enumerate(actions):
self.insertAction(index, i, action, background)
def insertAction(self, row, index, action,
background="light-orange"):
"""Insert `action` in `row` in position `index`.
"""
button = self.createButton(action, background)
self.insertButton(row, index, button)
def insertButton(self, row, index, button):
"""Insert `button` in `row` in position `index`.
"""
item = self.__mainLayout.itemAt(row)
#.........这里部分代码省略.........