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.
and this error
I think the syntax is wrong on the "if" statement. By the way, I am a beginner.
1 2 3 4 5 6 7 |
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))) |
1 2 3 4 5 6 |
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' |