Mar-04-2017, 05:49 PM
in a small loop, I am trying to sum all of the lineEdits (in a PyQt5 GUI) whose objectName endswith a number in a particular frame. So far, I have the following code, but it has an AtributeError.
def sumcar(self): amts = [] for child in self.ui.frame_10.findChildren(QLineEdit): if child.objectName().endswith.isdigit(): amt = int(child.text()) if child.text() else 0 amts.append(amt) self.ui.cartotal.setText(str(sum(amts)))and this error
Traceback (most recent call last): File "C:/Users/Dennis/PycharmProjects/Savings\expenseswindow.py", line 125, in changecar1 self.sumcar() File "C:/Users/Dennis/PycharmProjects/Savings\expenseswindow.py", line 105, in sumcar if child.objectName().endswith.isdigit(): AttributeError: 'builtin_function_or_method' object has no attribute 'isdigit'I think the syntax is wrong on the "if" statement. By the way, I am a beginner.