update label text in for loop

I’m working on a shopping cart GUI. I have a list called my_order, which stores the information I get from the user. I want to update label text in a for loop so I can print all the elements of my_order list. Here’s my code: class PaymentScreen(QMainWindow): def __init__(self): super(PaymentScreen, self).__init__() loadUi("paymentscreen.ui",self) self.gobackbutton.clicked.connect(self.goback) self.basket.setText("{}".format(my_order)) #the… Read More update label text in for loop

When installing the validator, the number of characters entered is limited. [Python]

There was a problem, when installing the validator in PyQt5, the number of characters is limited to 1. Why might this be happening? I give an example code below:: import sys from PyQt5.QtWidgets import QMainWindow, QApplication, QWidget, QLabel, QGridLayout, QLineEdit from PyQt5 import QtWidgets, QtCore, QtGui class Example(QMainWindow): def __init__(self): super().__init__() self.initUI() def initUI(self): self.setGeometry(300,… Read More When installing the validator, the number of characters entered is limited. [Python]

How to auto hide a dialogue box in PyQt5

I have created a dialogue box using pyqt5, which I want to display for 5 seconds an wish to autohide it after the given time. Here’s the code:- from PyQt5.QtWidgets import QMainWindow, QApplication, QLCDNumber,QWidget, QDesktopWidget, QLabel from PyQt5 import uic import sys from PyQt5.QtCore import QTime, QTimer from PyQt5 import QtCore, QtGui from PyQt5.QtGui import… Read More How to auto hide a dialogue box in PyQt5

Why PYQT5 connecting multiple checkboxes does not work in a loop, but works by writing out everything manually

I am working on PyQT5 and I have the following list. self.config_cbs = [self.gui.cb_config_0, \ self.gui.cb_config_1, \ self.gui.cb_config_2, \ self.gui.cb_config_3, \ self.gui.cb_config_4, \ self.gui.cb_config_5, \ self.gui.cb_config_6, \ self.gui.cb_config_7, \ self.gui.cb_config_8, \ self.gui.cb_config_9, \ self.gui.cb_config_10, \ self.gui.cb_config_11] I want to connect all checkboxes to the same function. Does anyone know, why does this NOT work? for… Read More Why PYQT5 connecting multiple checkboxes does not work in a loop, but works by writing out everything manually

pyqt5 file_open method error, i got this error when i opened an image

def open_file(self): name=QFileDialog.getOpenFileName(self, ‘Open File’) file=open(name, ‘rb’, encoding= ‘utf8’) self.editor() with file: text=file.read() self.textEdit.setText(text) expected str, bytes or os.PathLike object, not tuple i got this error when i opened an image. >Solution : getOpenFileName return a tuple with the name and the extension def open_file(self): name = QFileDialog.getOpenFileName(self, ‘Open File’) file = open(name[0], ‘rb’, encoding=’utf8′)… Read More pyqt5 file_open method error, i got this error when i opened an image

Export Postgresql Table to excel with header in Python

My code works but it doesn’t bring the header with the names, it only brings the numbers 0 1 … 10 , what can I do ? Utils_db.py def consulta_sql(sql): try: connection = psycopg2.connect(user="postgres", password="postgres", host="localhost", port="5432", database="tb_cliente") cursor = connection.cursor() except (Exception, psycopg2.Error) as error: try: cursor.execute(sql) connection.commit() except (Exception, psycopg2.Error) as error: finally:… Read More Export Postgresql Table to excel with header in Python

Cutting Strings Pyhton

i have a simple ui created with pyqt5 it loads a file, let you choose a outputfolder and creats a new txt file with additonals information. the string of the loaded file is written to self.inputs.filename.text() it looks like "C:/User/Folder/File.txt" later in the application i write into a new file in a specific location. new_txt… Read More Cutting Strings Pyhton