本文整理汇总了Python中python_qt_binding.QtGui.QVBoxLayout.totalSizeHint方法的典型用法代码示例。如果您正苦于以下问题:Python QVBoxLayout.totalSizeHint方法的具体用法?Python QVBoxLayout.totalSizeHint怎么用?Python QVBoxLayout.totalSizeHint使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类python_qt_binding.QtGui.QVBoxLayout
的用法示例。
在下文中一共展示了QVBoxLayout.totalSizeHint方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: MessageBox
# 需要导入模块: from python_qt_binding.QtGui import QVBoxLayout [as 别名]
# 或者: from python_qt_binding.QtGui.QVBoxLayout import totalSizeHint [as 别名]
class MessageBox(QDialog):
NoIcon = 0
Information = 1
Warning = 2
Critical = 3
Question = 4
NoButton = 0
Ok = 1 # An "OK" button defined with the AcceptRole .
Open = 2 # A "Open" button defined with the AcceptRole .
Save = 4 # A "Save" button defined with the AcceptRole .
Cancel = 8 # A "Cancel" button defined with the RejectRole .
Close = 16 # A "Close" button defined with the RejectRole .
Discard = 32 # A "Discard" or "Don't Save" button, depending on the platform, defined with the DestructiveRole .
Apply = 64 # An "Apply" button defined with the ApplyRole .
Reset = 128 # A "Reset" button defined with the ResetRole .
RestoreDefaults = 256 # A "Restore Defaults" button defined with the ResetRole .
Help = 512 # A "Help" button defined with the HelpRole .
SaveAll = 1024 # A "Save All" button defined with the AcceptRole .
Yes = 2048 # A "Yes" button defined with the YesRole .
YesToAll = 4096 # A "Yes to All" button defined with the YesRole .
No = 8192 # A "No" button defined with the NoRole .
NoToAll = 16384 # A "No to All" button defined with the NoRole .
Abort = 32768 # An "Abort" button defined with the RejectRole .
Retry = 65536 # A "Retry" button defined with the AcceptRole .
Ignore = 131072 # An "Ignore" button defined with the AcceptRole .
Avoid = 262144 # An "'Don't show again'" button defined with the HelpRole, returns a default AcceptButton .
def __init__(self, icon, title, text, detailed_text="", buttons=Cancel | Ok, parent=None):
QDialog.__init__(self, parent=parent)
self.setWindowFlags(self.windowFlags() & ~Qt.WindowTitleHint)
self.setWindowFlags(self.windowFlags() & ~Qt.WindowContextHelpButtonHint & ~Qt.WindowMinimizeButtonHint)
self.setObjectName('MessageBox')
self._use_checkbox = True
self.text = text
self.verticalLayout = QVBoxLayout(self)
self.verticalLayout.setObjectName("verticalLayout")
self.verticalLayout.setContentsMargins(1, 1, 1, 1)
self.horizontalLayout = QHBoxLayout()
self.horizontalLayout.setObjectName("horizontalLayout")
self.horizontalLayout.setContentsMargins(1, 1, 1, 1)
# create icon
pixmap = None
if icon == self.NoIcon:
pass
elif icon == self.Question:
pixmap = QApplication.style().standardPixmap(QStyle.SP_MessageBoxQuestion)
elif icon == self.Information:
pixmap = QApplication.style().standardPixmap(QStyle.SP_MessageBoxInformation)
elif icon == self.Warning:
pixmap = QPixmap(":icons/crystal_clear_warning_56.png")
elif icon == self.Critical:
pixmap = QApplication.style().standardPixmap(QStyle.SP_MessageBoxCritical)
spacerItem = QSpacerItem(10, 60, QSizePolicy.Minimum, QSizePolicy.Minimum)
self.horizontalLayout.addItem(spacerItem)
self.icon_label = QLabel()
if pixmap is not None:
self.icon_label.setPixmap(pixmap)
self.icon_label.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed)
self.horizontalLayout.addWidget(self.icon_label)
spacerItem = QSpacerItem(10, 60, QSizePolicy.Minimum, QSizePolicy.Minimum)
self.horizontalLayout.addItem(spacerItem)
# add message
self.message_label = QLabel(text)
self.message_label.setWordWrap(True)
self.message_label.setScaledContents(True)
self.message_label.setOpenExternalLinks(True)
self.horizontalLayout.addWidget(self.message_label)
self.verticalLayout.addLayout(self.horizontalLayout)
# create buttons
self.buttonBox = QDialogButtonBox(self)
self.buttonBox.setObjectName("buttonBox")
self.buttonBox.setOrientation(Qt.Horizontal)
self._accept_button = None
self._reject_button = None
self._buttons = buttons
self._create_buttons(buttons)
self.buttonBox.accepted.connect(self.accept)
self.buttonBox.rejected.connect(self.reject)
self.verticalLayout.addWidget(self.buttonBox)
if detailed_text:
self.btn_show_details = QPushButton(self.tr('Details...'))
self.btn_show_details.setCheckable(True)
self.btn_show_details.setChecked(True)
self.btn_show_details.toggled.connect(self.on_toggled_details)
self.buttonBox.addButton(self.btn_show_details, QDialogButtonBox.ActionRole)
# create area for detailed text
self.textEdit = textEdit = QTextEdit(self)
textEdit.setObjectName("textEdit")
textEdit.setReadOnly(True)
textEdit.setText(detailed_text)
# textEdit.setVisible(False)
self.verticalLayout.addWidget(self.textEdit)
self.resize(480, self.verticalLayout.totalSizeHint().height())
buttons_in_box = self.buttonBox.buttons()
#.........这里部分代码省略.........