logilink
3rd October 2016, 09:27
Dear Friends. I wrote a program that have Form and Form2 called V1. V1 will show after cliked button in Form1.
In V1 I have a LineEdit and button. When i wrote something in LineEdit in V1 I want send this text to LineEdit in Form1.
from PyQt4 import QtCore, QtGui
from V1 import Ui_V1
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)
# V1 window
class Ui_V1(object):
def setupUi(self, V1):
V1.setObjectName(_fromUtf8("V1"))
V1.resize(400, 300)
self.label = QtGui.QLabel(V1)
...
self.pushButton.setText(_translate("V1", "Wyslij", None))
self.pushButton_2.setText(_translate("V1", "Wyslij", None))
self.pushButton.clicked.connect(lambda: self.wyslij())
def wyslij(self):
self.lineEdit.setText(self.Ui_Form.lineEdit_11.tex t())
# Main window!
class Ui_Form(object):
def setupUi(self, Form):
Form.setObjectName(_fromUtf8("Form"))
Form.resize(728, 601)
Form.setMinimumSize(QtCore.QSize(728, 601))
self.label_6 = QtGui.QLabel(Form)
self.label_6.setGeometry(QtCore.QRect(169, 3, 401, 41))
self.label_6.setObjectName(_fromUtf8("label_6"))...
def retranslateUi(self, Form):
Form.setWindowTitle(_translate("Form", "Form", None))
self.label_6.setText(_translate("Form", "<html><head/><body><p><span style=\" font-size:16pt; font-weight:600;\">TYGODNIOWA KONTROLA JAKOSCI</span></p></body></html>", None))
self.label_8.setText(_translate("Form", "(dd-mm-rrrr)", None))...
self.pushButton_2.clicked.connect(lambda: self.zapis_tyg()) # Do zapisu do tyg formularza
self.pushButton_5.clicked.connect(lambda: self.openV1()) # v1 window
#zapis do pliku formularza tyg
def zapis_tyg(self): # ZAPIS DO FORMULARZ TYGODNIOWEGO
s = ""
seq = (self.comboBox_6.currentText(), ".txt"); # This is sequence of strings. laczenie aby nazywał pliki wzaleznosci od aparatu
a= s.join( seq )
text_file = open( a , "a")
text_file.write(self.lineEdit.text()+ "\t" ) #data
text_file.write(self.lineEdit_2.text()+ "\t" ) #osoba
text_file.write(self.comboBox_6.currentText() + "\t" ) #aparat
text_file.write(self.comboBox.currentText() + "\t" ) #AKCESORIUM
text_file.write(self.comboBox_2.currentText() + "\t" ) #ZAB ANTYK
text_file.write(self.comboBox_3.currentText() + "\t" ) #iZO
text_file.write(self.comboBox_4.currentText() + "\t" )# CENTRQTOR
text_file.write(self.comboBox_5.currentText() + "\t" )# TELEMETR
text_file.write(self.textEdit.toPlainText()+ "\n" ) # KOM MECH
text_file.close()
#function to show a new form
def openV1(self):
self.V1Window=QtGui.QMainWindow()
self.ui= Ui_V1()
self.ui.setupUi(self.V1Window)
self.V1Window.show()
I had an error:
'Ui_V1' object has no attribute 'Ui_Form'
Where is the problem?
Thank you
In V1 I have a LineEdit and button. When i wrote something in LineEdit in V1 I want send this text to LineEdit in Form1.
from PyQt4 import QtCore, QtGui
from V1 import Ui_V1
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)
# V1 window
class Ui_V1(object):
def setupUi(self, V1):
V1.setObjectName(_fromUtf8("V1"))
V1.resize(400, 300)
self.label = QtGui.QLabel(V1)
...
self.pushButton.setText(_translate("V1", "Wyslij", None))
self.pushButton_2.setText(_translate("V1", "Wyslij", None))
self.pushButton.clicked.connect(lambda: self.wyslij())
def wyslij(self):
self.lineEdit.setText(self.Ui_Form.lineEdit_11.tex t())
# Main window!
class Ui_Form(object):
def setupUi(self, Form):
Form.setObjectName(_fromUtf8("Form"))
Form.resize(728, 601)
Form.setMinimumSize(QtCore.QSize(728, 601))
self.label_6 = QtGui.QLabel(Form)
self.label_6.setGeometry(QtCore.QRect(169, 3, 401, 41))
self.label_6.setObjectName(_fromUtf8("label_6"))...
def retranslateUi(self, Form):
Form.setWindowTitle(_translate("Form", "Form", None))
self.label_6.setText(_translate("Form", "<html><head/><body><p><span style=\" font-size:16pt; font-weight:600;\">TYGODNIOWA KONTROLA JAKOSCI</span></p></body></html>", None))
self.label_8.setText(_translate("Form", "(dd-mm-rrrr)", None))...
self.pushButton_2.clicked.connect(lambda: self.zapis_tyg()) # Do zapisu do tyg formularza
self.pushButton_5.clicked.connect(lambda: self.openV1()) # v1 window
#zapis do pliku formularza tyg
def zapis_tyg(self): # ZAPIS DO FORMULARZ TYGODNIOWEGO
s = ""
seq = (self.comboBox_6.currentText(), ".txt"); # This is sequence of strings. laczenie aby nazywał pliki wzaleznosci od aparatu
a= s.join( seq )
text_file = open( a , "a")
text_file.write(self.lineEdit.text()+ "\t" ) #data
text_file.write(self.lineEdit_2.text()+ "\t" ) #osoba
text_file.write(self.comboBox_6.currentText() + "\t" ) #aparat
text_file.write(self.comboBox.currentText() + "\t" ) #AKCESORIUM
text_file.write(self.comboBox_2.currentText() + "\t" ) #ZAB ANTYK
text_file.write(self.comboBox_3.currentText() + "\t" ) #iZO
text_file.write(self.comboBox_4.currentText() + "\t" )# CENTRQTOR
text_file.write(self.comboBox_5.currentText() + "\t" )# TELEMETR
text_file.write(self.textEdit.toPlainText()+ "\n" ) # KOM MECH
text_file.close()
#function to show a new form
def openV1(self):
self.V1Window=QtGui.QMainWindow()
self.ui= Ui_V1()
self.ui.setupUi(self.V1Window)
self.V1Window.show()
I had an error:
'Ui_V1' object has no attribute 'Ui_Form'
Where is the problem?
Thank you