本文整理汇总了Python中qtpy.QtWidgets.QDialog.setLayout方法的典型用法代码示例。如果您正苦于以下问题:Python QDialog.setLayout方法的具体用法?Python QDialog.setLayout怎么用?Python QDialog.setLayout使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类qtpy.QtWidgets.QDialog
的用法示例。
在下文中一共展示了QDialog.setLayout方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _ask_overwrite
# 需要导入模块: from qtpy.QtWidgets import QDialog [as 别名]
# 或者: from qtpy.QtWidgets.QDialog import setLayout [as 别名]
def _ask_overwrite(self):
msg = QDialog()
msg.setWindowTitle('Load overwrite')
layout = QGridLayout()
layout.addWidget(QLabel('Instrument %s already exists in memory. Overwrite this?'), 0, 0, 1, -1)
buttons = [QPushButton(label) for label in ['Load and overwrite', 'Cancel Load', 'Load and rename to']]
locations = [[1, 0], [1, 1], [2, 0]]
self.overwrite_flag = 1
def overwriteCB(idx):
self.overwrite_flag = idx
msg.accept()
for idx, button in enumerate(buttons):
button.clicked.connect(lambda _, idx=idx: overwriteCB(idx))
layout.addWidget(button, locations[idx][0], locations[idx][1])
newname = QLineEdit()
newname.editingFinished.connect(lambda: overwriteCB(2))
layout.addWidget(newname, 2, 1)
msg.setLayout(layout)
msg.exec_()
newname = str(newname.text())
if not newname or newname in self.instruments:
self.errormessage('Invalid instrument name. Cancelling load.')
self.overwrite_flag = 1
return self.overwrite_flag, newname
示例2: final_dialog
# 需要导入模块: from qtpy.QtWidgets import QDialog [as 别名]
# 或者: from qtpy.QtWidgets.QDialog import setLayout [as 别名]
def final_dialog(self, label):
"""
Final dialog that to show where the calculated collapsed cube was put.
:param label:
:return:
"""
final_dialog = QDialog()
# Create data component label and input box
widget_desc = QLabel('The collapsed cube was added as an overlay with label "{}". {}'.format(
label, self._extra_message))
widget_desc.setWordWrap(True)
widget_desc.setFixedWidth(350)
widget_desc.setAlignment((Qt.AlignLeft | Qt.AlignTop))
hb_desc = QHBoxLayout()
hb_desc.addWidget(widget_desc)
# Create Ok button
okButton = QPushButton("Ok")
okButton.clicked.connect(lambda: final_dialog.close())
okButton.setDefault(True)
hb_buttons = QHBoxLayout()
hb_buttons.addStretch(1)
hb_buttons.addWidget(okButton)
# Add description and buttons to popup box
vbl = QVBoxLayout()
vbl.addLayout(hb_desc)
vbl.addLayout(hb_buttons)
final_dialog.setLayout(vbl)
final_dialog.setMaximumWidth(400)
final_dialog.show()