I have a barcode reader that reads the code of the citizenship card and verifies, on a server with OctoberCMS, if the user is registered. If you are registered, it returns the information of the user that is hosted in the database. If it is not, it will create a record in the database with the information provided by the citizenship card and will return the ID of the new record. So far everything is going well.
The problem is that I am new to GUI programming and I need to create an interface for this code. I have advanced work using PyQt.
For now, I have created a simple interface that captures additional information that must be added to the user when it is created or verified in OctoberCMS. My question is: What is the best way to send the additional information using the API that I made in OctoberCMS ?. I would be grateful if you could provide me with a sample code, something general, since I don't understand PyQt's classes and modules very well.
This is the code I have made in python.
class MyApp(QtWidgets.QMainWindow, Ui_MainWindow):
def __init__(self):
#Iniciar el objeto QMainWindow
QtWidgets.QMainWindow.__init__(self)
Ui_MainWindow.__init__(self)
self.setupUi(self)
self.showMaximized()
self.email.textChanged.connect(self.validar_email)
self.telefono.textChanged.connect(self.validar_telefono)
self.pushButton.clicked.connect(self.validar_formulario)
def validar_email(self):
email = self.email.text()
validar = re.match('^[a-zA-Z0-9\._-]+@[a-zA-Z0-9-]{2,}[.][a-zA-Z]{2,4}$', email, re.I)
if email == "":
self.email.setStyleSheet("border: 1px solid yellow;")
return False
elif not validar:
self.email.setStyleSheet("border: 1px solid red;")
return False
else:
self.email.setStyleSheet("border: 1px solid green;")
return True
def validar_telefono(self):
telefono = self.telefono.text()
validar = re.match('^(\d{10})$', telefono, re.I)
if telefono == "":
self.telefono.setStyleSheet("border: 1px solid yellow;")
return False
elif not validar:
self.telefono.setStyleSheet("border: 1px solid red;")
return False
else:
self.telefono.setStyleSheet("border: 1px solid green;")
return True
def mostrar(self):
self.label_7.setText(str(pregunta1) + "_" + str(pregunta2) + "_" + str(pregunta3) + "_" + str(dias))
def validar_formulario(self):
if self.validar_telefono() and self.validar_email():
self.mostrar()
QMessageBox.information(self, "Formulario correcto", "Validación correcta", QMessageBox.Discard)
else:
QMessageBox.warning(self, "Formulario incorrecto", "Validación incorrecta", QMessageBox.Discard)
I need to send this information through the Api like this: http://localhost/api/myoctobermodule, using from-data.