本文整理汇总了Python中AnyQt.QtWidgets.QDialog.setAttribute方法的典型用法代码示例。如果您正苦于以下问题:Python QDialog.setAttribute方法的具体用法?Python QDialog.setAttribute怎么用?Python QDialog.setAttribute使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AnyQt.QtWidgets.QDialog
的用法示例。
在下文中一共展示了QDialog.setAttribute方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __run_add_package_dialog
# 需要导入模块: from AnyQt.QtWidgets import QDialog [as 别名]
# 或者: from AnyQt.QtWidgets.QDialog import setAttribute [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_()