Hi, i would love a little direction here please as i have been searching but not finding a solution to my issue.
What i would love is to take the data i enter into the line edit field of my gui and send that data to a string in my list. In the case below it is the value at ls[0] that i want to change to the value i enter in the gui line edit field. (not using line edit_2 at the moment) Am i going about it the wrong way?

Qt Code:
  1. from PyQt4 import QtCore, QtGui
  2. import sys
  3.  
  4. ls = ["a", "b"]
  5.  
  6. try:
  7. _fromUtf8 = QtCore.QString.fromUtf8
  8. except AttributeError:
  9. def _fromUtf8(s):
  10. return s
  11.  
  12. try:
  13. _encoding = QtGui.QApplication.UnicodeUTF8
  14. def _translate(context, text, disambig):
  15. return QtGui.QApplication.translate(context, text, disambig, _encoding)
  16. except AttributeError:
  17. def _translate(context, text, disambig):
  18. return QtGui.QApplication.translate(context, text, disambig)
  19.  
  20. class Ui_Dialog(QtGui.QWidget):
  21. def __init__(self):
  22. QtGui.QWidget.__init__(self)
  23. self.setupUi(self)
  24. def setupUi(self, Dialog):
  25. Dialog.setObjectName(_fromUtf8("Dialog"))
  26. Dialog.resize(400, 300)
  27. self.pushButton = QtGui.QPushButton(Dialog)
  28. self.pushButton.setGeometry(QtCore.QRect(30, 40, 75, 23))
  29. self.pushButton.setObjectName(_fromUtf8("pushButton"))
  30. self.lineEdit = QtGui.QLineEdit(Dialog)
  31. self.lineEdit.setGeometry(QtCore.QRect(120, 40, 113, 20))
  32. self.lineEdit.setObjectName(_fromUtf8("lineEdit"))
  33. self.lineEdit_2 = QtGui.QLineEdit(Dialog)
  34. self.lineEdit_2.setGeometry(QtCore.QRect(260, 40, 113, 20))
  35. self.lineEdit_2.setObjectName(_fromUtf8("lineEdit_2"))
  36.  
  37. self.retranslateUi(Dialog)
  38. QtCore.QMetaObject.connectSlotsByName(Dialog)
  39.  
  40. def retranslateUi(self, Dialog):
  41. Dialog.setWindowTitle(_translate("Dialog", "Dialog", None))
  42. self.pushButton.setText(_translate("Dialog", "PushButton", None))
  43. self.pushButton.clicked.connect(self.changedata)
  44.  
  45.  
  46. def changedata(self):
  47. print ls[0] #this line is just to print out what ls[0] is before it is changed
  48. ls[0] = self.lineEdit #this is where i am stuck as i do not know how to get the line edit data. i,m new to python and qt so forgive me if i'm a bit off
  49. print ls[0] #this line is to print out the new value of ls[0] to see if it changed
  50.  
  51.  
  52. if __name__ == '__main__':
  53. app = QtGui.QApplication(sys.argv)
  54. ex = Ui_Dialog()
  55. ex.show()
  56. sys.exit(app.exec_())
To copy to clipboard, switch view to plain text mode