本文整理汇总了Python中openmolar.qt4gui.customwidgets.upper_case_line_edit.UpperCaseLineEdit.setFocus方法的典型用法代码示例。如果您正苦于以下问题:Python UpperCaseLineEdit.setFocus方法的具体用法?Python UpperCaseLineEdit.setFocus怎么用?Python UpperCaseLineEdit.setFocus使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类openmolar.qt4gui.customwidgets.upper_case_line_edit.UpperCaseLineEdit
的用法示例。
在下文中一共展示了UpperCaseLineEdit.setFocus方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: AddUserDialog
# 需要导入模块: from openmolar.qt4gui.customwidgets.upper_case_line_edit import UpperCaseLineEdit [as 别名]
# 或者: from openmolar.qt4gui.customwidgets.upper_case_line_edit.UpperCaseLineEdit import setFocus [as 别名]
class AddUserDialog(ExtendableDialog):
def __init__(self, parent=None):
ExtendableDialog.__init__(self, parent)
self.setWindowTitle(_("Add User Dialog"))
self.top_label = WarningLabel("%s<br />%s<hr />%s" % (
_('Add a new user to the system?'),
_("This is done using initials or a short nickname."),
_("Must be unique and Maximum allowed in 5 characters")))
self.line_edit = UpperCaseLineEdit()
frame = QtWidgets.QFrame(self)
layout = QtWidgets.QFormLayout(frame)
layout.addRow(_("User Initials or nickname"), self.line_edit)
self.insertWidget(self.top_label)
self.insertWidget(frame)
self.line_edit.textChanged.connect(self._check_enable)
self.line_edit.setFocus()
settings_fetcher = db_settings.SettingsFetcher()
self.existing_logins = settings_fetcher.existing_logins()
list_widget = QtWidgets.QListWidget()
list_widget.addItems(sorted(self.existing_logins))
self.add_advanced_widget(list_widget)
self.set_advanced_but_text(_("view existing users"))
def _check_enable(self, *args):
input_ = self.username
if input_ in self.existing_logins:
QtWidgets.QMessageBox.warning(
self,
_("error"),
_("Initials/nickname must be unique"))
self.enableApply(False)
else:
self.enableApply(input_ != "")
@property
def username(self):
return str(self.line_edit.text())
def apply(self):
if db_settings.insert_login(self.username):
localsettings.initiateUsers()
return True
def exec_(self):
if ExtendableDialog.exec_(self):
return self.apply()
return False