from PyQt4 import QtCore, QtGui
import sys
ls = ["a", "b"]
try:
_fromUtf8
= QtCore.
QString.
fromUtf8except AttributeError:
def _fromUtf8(s):
return s
try:
def _translate(context, text, disambig):
return QtGui.
QApplication.
translate(context, text, disambig, _encoding
) except AttributeError:
def _translate(context, text, disambig):
return QtGui.
QApplication.
translate(context, text, disambig
)
def __init__(self):
self.setupUi(self)
def setupUi(self, Dialog):
Dialog.setObjectName(_fromUtf8("Dialog"))
Dialog.resize(400, 300)
self.
pushButton.
setGeometry(QtCore.
QRect(30,
40,
75,
23)) self.pushButton.setObjectName(_fromUtf8("pushButton"))
self.
lineEdit.
setGeometry(QtCore.
QRect(120,
40,
113,
20)) self.lineEdit.setObjectName(_fromUtf8("lineEdit"))
self.
lineEdit_2.
setGeometry(QtCore.
QRect(260,
40,
113,
20)) self.lineEdit_2.setObjectName(_fromUtf8("lineEdit_2"))
self.retranslateUi(Dialog)
def retranslateUi(self, Dialog):
Dialog.setWindowTitle(_translate("Dialog", "Dialog", None))
self.pushButton.setText(_translate("Dialog", "PushButton", None))
self.pushButton.clicked.connect(self.changedata)
def changedata(self):
print ls[0] #this line is just to print out what ls[0] is before it is changed
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
print ls[0] #this line is to print out the new value of ls[0] to see if it changed
if __name__ == '__main__':
ex = Ui_Dialog()
ex.show()
sys.exit(app.exec_())
from PyQt4 import QtCore, QtGui
import sys
ls = ["a", "b"]
try:
_fromUtf8 = QtCore.QString.fromUtf8
except AttributeError:
def _fromUtf8(s):
return s
try:
_encoding = QtGui.QApplication.UnicodeUTF8
def _translate(context, text, disambig):
return QtGui.QApplication.translate(context, text, disambig, _encoding)
except AttributeError:
def _translate(context, text, disambig):
return QtGui.QApplication.translate(context, text, disambig)
class Ui_Dialog(QtGui.QWidget):
def __init__(self):
QtGui.QWidget.__init__(self)
self.setupUi(self)
def setupUi(self, Dialog):
Dialog.setObjectName(_fromUtf8("Dialog"))
Dialog.resize(400, 300)
self.pushButton = QtGui.QPushButton(Dialog)
self.pushButton.setGeometry(QtCore.QRect(30, 40, 75, 23))
self.pushButton.setObjectName(_fromUtf8("pushButton"))
self.lineEdit = QtGui.QLineEdit(Dialog)
self.lineEdit.setGeometry(QtCore.QRect(120, 40, 113, 20))
self.lineEdit.setObjectName(_fromUtf8("lineEdit"))
self.lineEdit_2 = QtGui.QLineEdit(Dialog)
self.lineEdit_2.setGeometry(QtCore.QRect(260, 40, 113, 20))
self.lineEdit_2.setObjectName(_fromUtf8("lineEdit_2"))
self.retranslateUi(Dialog)
QtCore.QMetaObject.connectSlotsByName(Dialog)
def retranslateUi(self, Dialog):
Dialog.setWindowTitle(_translate("Dialog", "Dialog", None))
self.pushButton.setText(_translate("Dialog", "PushButton", None))
self.pushButton.clicked.connect(self.changedata)
def changedata(self):
print ls[0] #this line is just to print out what ls[0] is before it is changed
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
print ls[0] #this line is to print out the new value of ls[0] to see if it changed
if __name__ == '__main__':
app = QtGui.QApplication(sys.argv)
ex = Ui_Dialog()
ex.show()
sys.exit(app.exec_())
To copy to clipboard, switch view to plain text mode
Bookmarks