I'm having a problem where I'm unable to access PyQT QTextEdits and QLineEdits from a separate class method. I'm getting different variations of this error:
AttributeError: type object 'MyApp' has no attribute 'Ui_MainWindow'
I've tried everything that I can think of, including:
- Using a child-class
- Explicitly adding the GUI class as an argument in the non-child class
- Calling on the items by using 'self..text()'
- Calling on the items by using 'MyApp..text()' (GUI inhereted class name)
- Calling on the items by using 'MyApp.Ui_MainWindow..text()' (GUI inhereted class name)
- Calling on the items by using 'MyApp.Ui_MainWindow.setupUi..text()' (GUI inhereted class name)
- Calling on items by using 'UiMainWindow..text()' (imported GUI .py file class)
- Calling on items by using 'UiMainWindow.setupUi..text()' (imported GUI .py file class + method)
- Calling on items by using 'UiMainWindow.setupUi..text()' (imported GUI .py file class + method)
Please see my code below:
from app import Ui_MainWindow #import UI
class MyApp(QtWidgets.QMainWindow, Ui_MainWindow): #GUI class
def __init__(self):
QtWidgets.QMainWindow.__init__(self)
Ui_MainWindow.__init__(self)
self.button_search_item.clicked.connect(new_class.get_information)
class new_class(MyApp): #new class that i want to call on qtext and qline edits.
def get_information(self):
print(str(MyApp.Ui_MainWindow.setupUi.qlineedit_item.text()))
#OUTPUT:
#AttributeError: type object 'MyApp' has no attribute 'Ui_MainWindow'