![]() Layer = QgsProject.instance().mapLayersByName('aux_revisao_p')įeature = core.QgsFeature(layer.fields()) Lambda: ().setMapTool(e_lineEditClicked))įrom re import QgsProject, QgsFeature, QgsGeometry, QgsPointXY Lambda: ().setMapTool(e_ComboBoxClicked)) Lambda: ().setMapTool(a_lineEditClicked)) Lambda: ().setMapTool(a_ComboBoxClicked)) # calls the tool when certain button is clicked # sets tool, it's the same tool for each different textĪ_ComboBoxClicked = HookCreator((), acquisitionTxt1)Ī_lineEditClicked = HookCreator((), acquisitionTxt2)Į_ComboBoxClicked = HookCreator((), editionTxt1)Į_lineEditClicked = HookCreator((), editionTxt2) # sets the text that must be passed to toolĪcquisitionTxt1 = _comboBox.currentText()ĮditionTxt1 = _comboBox.currentText()ĪcquisitionTxt2 = _lineEdit.text()ĮditionTxt2 = _lineEdit.text() (Qt.RightDockWidgetArea, self.dockwidget) When the comboBox button is clicked it works perfectly carring the comboBox.currentText() to the tool, but when the lineEdit button is clicked the tool is called but doesnt get the lineEdit.text(). Pyqt4 funcion lambda python connect qlineedits how to#I hope that this help you out to figure how to filter user input in a QLineEdit, or anywhere where you got an user input based on characters.I've write a plugin that calls a tool when a certain push button in my tabifyDockWidget is clicked. tWindowTitle("ReGEX Validator in Python with Qt Framework") Le_username_validator = QRegExpValidator(reg_ex, le_username) # For more details about ReGex search on google: regex rules or something similar to show how you can avoid that here is the code: from PyQt4.QtCore import * If this is the case then, I made a quick app. and so on, well from what I read in your question you use the input that is gathered from the user to send it in a database, which in this case if is a database you need to avoid sending again I say "strange" characters, well. ![]() and you want to stop users to enter "strange" characters like. I hope that I understand your question, so you got a QLineEdit somewhere in your app. Can someone tell me if there is a another concept I should be looking at besides using len? Semantically I know this makes sense but I can't figure out where I went wrong syntactically. Self.msg = (self, 'Message', 'User added successfully', ) Self.msg = (self, 'Message', 'Not enough characters!', ) nnect(erEdit, QtCore.SIGNAL("textchanged()"), self.validText) def newUser(self): #This method adds a new user into the login database and displays a pop up window confirming the entryĬ.execute("INSERT INTO logins(usernames, passwords)VALUES(?,?)", ((), ())) #sql query inserts entries from line edit and pass edit into database I understand that I only created one SIGNAL but this was just for testing. ![]() ![]() The SQL input works just fine but for some reason the input validation does not. I also created a signal for the QlineEdits that connects to a method that validates the text. I have a method in my register user class that adds a user into a sqlite database. I've been reading through the Class reference and it looks like the preferred way to do text validation would be through the QRegularExpression class but that seems excessive for some simple input validation. This is my first GUI application and first time working with the PyQt4 framework. I'm having a little trouble understanding input validation with PyQt4. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |