[PyQt] Problems with getting text from QLineEdit

Gerry Brown gbrown at gerbreown.com
Mon Jan 16 10:50:13 GMT 2017


Greetings:

I have created a form using QT Designer that has a number of QLineEdit 
widgets in it.  It shows great on the screen.  I have the problem when I 
try to get the .text property from it.

Below is several samples of my code with the error messages:

print(pat_add_gui.ui.txtlname.text())
NameError: name 'pat_add_gui' is not defined

print(self.pat_add_gui.ui.txtlname.text())
AttributeError: 'bool' object has no attribute 'pat_add_gui'

  print(self.ui.txtlname.text())
AttributeError: 'bool' object has no attribute 'ui'

This code & errors are in the same file where I import the GUI file.  I 
have tried:

from gui.pat_add_gui import Ui_frame

AND

qtDesignerFile = '/home/gerald/virtualenvs/medrec/gui/pat_add_gui.ui'

Ui_MainWindow, QtBaseClass = uic.loadUiType(qtDesignerFile)

Any ideas how I can get the text from these lineedits???

Thanks


More information about the PyQt mailing list