本文整理汇总了Python中AnyQt.QtWidgets.QDialog.setLayout方法的典型用法代码示例。如果您正苦于以下问题:Python QDialog.setLayout方法的具体用法?Python QDialog.setLayout怎么用?Python QDialog.setLayout使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AnyQt.QtWidgets.QDialog
的用法示例。
在下文中一共展示了QDialog.setLayout方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: ShowInfo
# 需要导入模块: from AnyQt.QtWidgets import QDialog [as 别名]
# 或者: from AnyQt.QtWidgets.QDialog import setLayout [as 别名]
def ShowInfo(self):
dialog = QDialog(self)
dialog.setModal(False)
dialog.setLayout(QVBoxLayout())
label = QLabel(dialog)
label.setText("Ontology:\n" + self.ontology.header
if self.ontology else "Ontology not loaded!")
dialog.layout().addWidget(label)
label = QLabel(dialog)
label.setText("Annotations:\n" + self.annotations.header.replace("!", "")
if self.annotations else "Annotations not loaded!")
dialog.layout().addWidget(label)
dialog.show()
示例2: __run_add_package_dialog
# 需要导入模块: from AnyQt.QtWidgets import QDialog [as 别名]
# 或者: from AnyQt.QtWidgets.QDialog import setLayout [as 别名]
def __run_add_package_dialog(self):
dlg = QDialog(self, windowTitle="Add add-on by name")
dlg.setAttribute(Qt.WA_DeleteOnClose)
vlayout = QVBoxLayout()
form = QFormLayout()
form.setContentsMargins(0, 0, 0, 0)
nameentry = QLineEdit(
placeholderText="Package name",
toolTip="Enter a package name as displayed on "
"PyPI (capitalization is not important)")
nameentry.setMinimumWidth(250)
form.addRow("Name:", nameentry)
vlayout.addLayout(form)
buttons = QDialogButtonBox(
standardButtons=QDialogButtonBox.Ok | QDialogButtonBox.Cancel
)
okb = buttons.button(QDialogButtonBox.Ok)
okb.setEnabled(False)
okb.setText("Add")
def changed(name):
okb.setEnabled(bool(name))
nameentry.textChanged.connect(changed)
vlayout.addWidget(buttons)
vlayout.setSizeConstraint(QVBoxLayout.SetFixedSize)
dlg.setLayout(vlayout)
f = None
def query():
nonlocal f
name = nameentry.text()
f = self._executor.submit(pypi_json_query_project_meta, [name])
okb.setDisabled(True)
def ondone(f):
error_text = ""
error_details = ""
try:
pkgs = f.result()
except Exception:
log.error("Query error:", exc_info=True)
error_text = "Failed to query package index"
error_details = traceback.format_exc()
pkg = None
else:
pkg = pkgs[0]
if pkg is None:
error_text = "'{}' not was not found".format(name)
if pkg:
method_queued(self.add_package, (object,))(pkg)
method_queued(dlg.accept, ())()
else:
method_queued(self.__show_error_for_query, (str, str)) \
(error_text, error_details)
method_queued(dlg.reject, ())()
f.add_done_callback(ondone)
buttons.accepted.connect(query)
buttons.rejected.connect(dlg.reject)
dlg.exec_()
示例3: formatValues
# 需要导入模块: from AnyQt.QtWidgets import QDialog [as 别名]
# 或者: from AnyQt.QtWidgets.QDialog import setLayout [as 别名]
painter.drawText(x2 - widthMax - 1, rect.y() + rect.height() - 2, strMax)
else:
painter.drawText(rect.x() + 1, x1 + height, strMin)
painter.drawText(rect.x() + rect.width() - widthMax - 1, x2 - 2, strMax)
def formatValues(self, valueMin, valueMax):
"""Format the int values into strings that are shown if showText is True."""
return str(valueMin), str(valueMax)
if __name__ == "__main__":
from AnyQt.QtWidgets import QApplication, QDialog, QGridLayout, QLabel
app = QApplication([])
win = QDialog()
grid = QGridLayout(win)
win.setLayout(grid)
kwargs = dict(
minimum=0,
maximum=100,
tickInterval=5,
minimumValue=20,
maximumValue=80,
slidersMoved=print
)
grid.addWidget(QLabel('RangeSlider:', win), 0, 0)
grid.addWidget(RangeSlider(win, orientation=Qt.Horizontal, **kwargs), 0, 1)
grid.addWidget(QLabel('RangeSlider:', win), 1, 0)
grid.addWidget(RangeSlider(win, orientation=Qt.Vertical, **kwargs), 1, 1)
grid.addWidget(QLabel('ViolinSlider:', win), 2, 0)