本文整理匯總了Python中PyQt5.QtWidgets.QLineEdit.displayText方法的典型用法代碼示例。如果您正苦於以下問題:Python QLineEdit.displayText方法的具體用法?Python QLineEdit.displayText怎麽用?Python QLineEdit.displayText使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類PyQt5.QtWidgets.QLineEdit
的用法示例。
在下文中一共展示了QLineEdit.displayText方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: LoginWindow
# 需要導入模塊: from PyQt5.QtWidgets import QLineEdit [as 別名]
# 或者: from PyQt5.QtWidgets.QLineEdit import displayText [as 別名]
class LoginWindow(QDialog):
def __init__(self):
super().__init__()
self.btn = QPushButton('LogIn', self)
self.btn.move(25, 82)
self.btn.clicked.connect(self.LogIn)
self.login = QLineEdit(self)
self.password = QLineEdit(self)
self.login.move(10, 22)
self.password.move(10, 52)
self.setGeometry(150, 150, 150, 120)
self.setWindowTitle('LogIn')
self.center()
self.show()
self.user = None
def LogIn(self):
self.user = Auth(self.login.displayText(), self.password.displayText())
if self.user.getError() is "UserNotFound":
text, ok = QInputDialog.getText(self, 'ERROR', 'Enter your name:')
if ok:
self.login.setText(str(text))
elif Auth(self.login.displayText(), self.password.displayText()).getError() is "IncorrectPassword":
pass
text, ok = QInputDialog.getText(self, 'ERROR', 'Enter your password:')
if ok:
self.password.setText(str(text))
else:
return self.user and self.close()
def getUser(self):
return self.user.getUser()
def getPriv(self):
return self.user.getPriv()
def center(self):
size = self.size()
desktopSize = QDesktopWidget().screenGeometry()
top = (desktopSize.height()/2)-(size.height()/2)
left = (desktopSize.width()/2)-(size.width()/2)
self.move(left, top)
示例2: MainWidget
# 需要導入模塊: from PyQt5.QtWidgets import QLineEdit [as 別名]
# 或者: from PyQt5.QtWidgets.QLineEdit import displayText [as 別名]
class MainWidget(QWidget):
def __init__(self, parent):
# this allow the use of the parent's methods when needed
super(MainWidget, self).__init__(parent=parent)
self.number_1 = QLineEdit()
self.number_2 = QLineEdit()
self.addition_button = QPushButton("push to add !")
self.addition_result = QLineEdit()
self.widget_init()
def widget_init(self):
grid = QGridLayout()
self.setLayout(grid)
self.addition_button.clicked.connect(self.collect_numbers)
grid.addWidget(self.number_1, 0, 0)
grid.addWidget(self.number_2, 0, 3)
grid.addWidget(self.addition_button, 1, 2)
grid.addWidget(self.addition_result, 2, 2)
@wrap_in_future # PyQT5 can't call a coroutine directly so we wrap it in a future
@asyncio.coroutine
# the function is called with a second positional argument that is False
# I haven't figured out why
def collect_numbers(self, dummy=False):
number_1 = self.number_1.displayText()
number_2 = self.number_2.displayText()
print("numbers to add: ", [number_1, number_2])
# make the wamp call using the call method instantiated in the MainWindows class
result = yield from self.parent().call('com.myapp.add', [number_1, number_2])
self.addition_result.setText(str(result))
示例3: EditIngredientsMenu
# 需要導入模塊: from PyQt5.QtWidgets import QLineEdit [as 別名]
# 或者: from PyQt5.QtWidgets.QLineEdit import displayText [as 別名]
class EditIngredientsMenu(QWidget):
def __init__(self):
super().__init__()
self.initUI()
def initUI(self):
self.addbtn = QPushButton('Add', self)
self.editbtn = QPushButton('Edit', self)
self.delbtn = QPushButton('Delete', self)
self.combo = QComboBox(self)
self.list = []
self.updateCombo()
name = QLabel("Name")
price = QLabel("Price")
replacement = QLabel("Replacement")
instock = QLabel("InStock")
self.nameEdit = QLineEdit()
self.priceEdit = QLineEdit()
self.instockEdit = QLineEdit()
self.replacementEdit = QLineEdit()
grid = QGridLayout()
grid.setSpacing(10)
grid.addWidget(self.combo, 1, 0)
grid.addWidget(self.addbtn, 1, 1)
grid.addWidget(self.editbtn, 1, 2)
grid.addWidget(self.delbtn, 1, 3)
grid.addWidget(name, 2, 0)
grid.addWidget(self.nameEdit, 2, 1, 1, 4)
grid.addWidget(price, 3, 0)
grid.addWidget(self.priceEdit, 3, 1, 1, 4)
grid.addWidget(replacement, 4, 0)
grid.addWidget(self.replacementEdit, 4, 1, 1, 4)
grid.addWidget(instock, 5, 0)
grid.addWidget(self.instockEdit, 5, 1, 1, 4)
self.setLayout(grid)
self.combo.activated[str].connect(self.onActivated)
self.addbtn.clicked.connect(self.addIngredient)
self.editbtn.clicked.connect(self.editIngredient)
self.delbtn.clicked.connect(self.deleteIngredient)
def updateCombo(self):
self.list.clear()
self.combo.clear()
for i in DB().getIngColl().find():
self.list.append(i["Name"])
self.combo.addItems(self.list)
def onActivated(self, text):
buffer = DB().getIngColl().find_one({"Name": text})
self.nameEdit.setText(buffer["Name"])
self.priceEdit.setText(str(buffer["Price"]))
self.instockEdit.setText(str(buffer["InStock"]))
if "Replacement" in buffer:
self.replacementEdit.setText(buffer["Replacement"])
else:
self.replacementEdit.setText("None")
def addIngredient(self):
DB.AddIngredient(DB(), self.nameEdit.displayText(), self.priceEdit.displayText(),
self.instockEdit.displayText(), self.replacementEdit.displayText())
self.updateCombo()
main.statusBar().showMessage("Done!")
def editIngredient(self):
DB.EditIngredient(DB(), self.nameEdit.displayText(), self.priceEdit.displayText(),
self.instockEdit.displayText(), self.replacementEdit.displayText())
self.updateCombo()
main.statusBar().showMessage("Done!")
def deleteIngredient(self):
DB.DeleteIngredient(DB(), self.nameEdit.displayText())
self.nameEdit.setText("")
self.priceEdit.setText("")
self.instockEdit.setText("")
self.replacementEdit.setText("")
self.updateCombo()
main.statusBar().showMessage("Done!")
示例4: EditCocktailsMenu
# 需要導入模塊: from PyQt5.QtWidgets import QLineEdit [as 別名]
# 或者: from PyQt5.QtWidgets.QLineEdit import displayText [as 別名]
class EditCocktailsMenu(QWidget):
def __init__(self):
super().__init__()
self.initUI()
def initUI(self):
self.addbtn = QPushButton("Add", self)
self.editbtn = QPushButton("Edit", self)
self.delbtn = QPushButton("Delete", self)
self.combo = QComboBox(self)
self.list = []
self.updateCombo()
name = QLabel("Name")
time = QLabel("time")
ingredients = QLabel("Ingredient")
self.nameEdit = QLineEdit()
self.ingredientsEdit = QLineEdit()
self.timeEdit = QLineEdit()
self.grid = QGridLayout()
self.grid.setSpacing(10)
self.grid.addWidget(self.combo, 1, 0)
self.grid.addWidget(self.addbtn, 1, 1)
self.grid.addWidget(self.editbtn, 1, 2)
self.grid.addWidget(self.delbtn, 1, 3)
self.grid.addWidget(name, 2, 0)
self.grid.addWidget(self.nameEdit, 2, 1, 1, 4)
self.grid.addWidget(time, 3, 0)
self.grid.addWidget(self.timeEdit, 3, 1, 1, 4)
self.grid.addWidget(ingredients, 4, 0)
self.grid.addWidget(self.ingredientsEdit, 4, 1, 1, 4)
self.setLayout(self.grid)
self.combo.activated[str].connect(self.onActivated)
self.addbtn.clicked.connect(self.addNewCocktail)
self.editbtn.clicked.connect(self.editCocktail)
self.delbtn.clicked.connect(self.deleteCocktail)
def updateCombo(self):
self.list.clear()
self.combo.clear()
for i in DB().getCockColl().find():
self.list.append(i["Name"])
self.combo.addItems(self.list)
def onActivated(self, text):
buffer = DB().getCockColl().find_one({"Name": text})
self.nameEdit.setText(buffer["Name"])
self.ingredientsEdit.setText(str(buffer["Ingredients"]))
self.timeEdit.setText(str(buffer["time"]))
def addNewCocktail(self):
DB.AddNewCoctail(DB(), self.nameEdit.displayText(), eval(self.ingredientsEdit.displayText()),
float(self.timeEdit.displayText()))
self.updateCombo()
main.statusBar().showMessage("Done!")
def editCocktail(self):
DB.EditCoctail(DB(), self.nameEdit.displayText(), eval(self.ingredientsEdit.displayText()),
float(self.timeEdit.displayText()))
self.updateCombo()
main.statusBar().showMessage("Done!")
def deleteCocktail(self):
DB.DeleteCoctail(DB(), self.nameEdit.displayText())
self.nameEdit.setText("")
self.ingredientsEdit.setText("")
self.timeEdit.setText("")
self.updateCombo()
main.statusBar().showMessage("Done!")
示例5: EditUserMenu
# 需要導入模塊: from PyQt5.QtWidgets import QLineEdit [as 別名]
# 或者: from PyQt5.QtWidgets.QLineEdit import displayText [as 別名]
class EditUserMenu(QWidget):
def __init__(self):
super().__init__()
self.initUI()
def initUI(self):
self.addbtn = QPushButton('Add', self)
self.editbtn = QPushButton('Edit', self)
self.delbtn = QPushButton('Delete', self)
self.combo = QComboBox(self)
self.list = []
self.updateCombo()
login = QLabel("Login")
password = QLabel("Password")
privilege = QLabel("Privilege")
self.loginEdit = QLineEdit()
self.passwordEdit = QLineEdit()
self.privilegeEdit = QLineEdit()
grid = QGridLayout()
grid.setSpacing(10)
grid.addWidget(self.combo, 1, 0)
grid.addWidget(self.addbtn, 1, 1)
grid.addWidget(self.editbtn, 1, 2)
grid.addWidget(self.delbtn, 1, 3)
grid.addWidget(login, 2, 0)
grid.addWidget(self.loginEdit, 2, 1, 1, 4)
grid.addWidget(password, 3, 0)
grid.addWidget(self.passwordEdit, 3, 1, 1, 4)
grid.addWidget(privilege, 4, 0)
grid.addWidget(self.privilegeEdit, 4, 1, 1, 4)
self.setLayout(grid)
self.combo.activated[str].connect(self.onActivated)
self.addbtn.clicked.connect(self.addNewUser)
self.editbtn.clicked.connect(self.editUser)
self.delbtn.clicked.connect(self.deleteUser)
def updateCombo(self):
self.list.clear()
self.combo.clear()
for i in DB().getUserColl().find():
self.list.append(i["Login"])
self.combo.addItems(self.list)
def onActivated(self, text):
buffer = DB().getUserColl().find_one({"Login": text})
self.loginEdit.setText(buffer["Login"])
self.passwordEdit.setText(buffer["Password"])
self.privilegeEdit.setText(buffer["Privilege"])
def addNewUser(self):
DB.AddNewUser(DB(), self.loginEdit.displayText(), self.passwordEdit.displayText(),
self.privilegeEdit.displayText())
self.updateCombo()
main.statusBar().showMessage("Done!")
def editUser(self):
DB.EditUser(DB(), self.loginEdit.displayText(), self.passwordEdit.displayText(),
self.privilegeEdit.displayText())
self.updateCombo()
main.statusBar().showMessage("Done!")
def deleteUser(self):
DB.DeleteUser(DB(), self.loginEdit.displayText())
self.loginEdit.setText("")
self.passwordEdit.setText("")
self.privilegeEdit.setText("")
self.updateCombo()
main.statusBar().showMessage("Done!")
示例6: contacts
# 需要導入模塊: from PyQt5.QtWidgets import QLineEdit [as 別名]
# 或者: from PyQt5.QtWidgets.QLineEdit import displayText [as 別名]
INSERT INTO contacts(name, lastName) VALUES(?,?)""",("pingui", "kinder",))
cursor.execute("""
SELECT name FROM contacts""")
person = cursor.fetchall()
db.commit()
print(person)
w = QWidget()
aj = QPushButton('ajout',w)
su = QPushButton('pop',w)
bro = QLineEdit(w)
liste = QListWidget(w)
su.move(50,50)
bro.move(450,50)
liste.move(100,100)
for row in person:
liste.addItem(row[0])
aj.clicked.connect( liste.addItem(bro.displayText()) )
w.resize(250, 150)
w.move(300, 300)
w.setWindowTitle('Simple')
w.showMaximized()
sys.exit(app.exec_())