I have a gui application
- I put text into text box1, text box2,and then click on the
pushButton
, - The function
return_text_username ()
in themoduel_b.py
be called. Now I can call one instance bylambda1
function and use it inclass_b
, but I can not call two instants when I click on thepushbutton
.
**A- I want add lineEdit_2
into lambda method in main.py
or add instance_lambda2_password
into connect
method.
**B- I want to edit return_printtext_password (self, txt)
in the moduel_b.py
to print and return password.
Can anyone help me? Here's the code for that :
main.py
# -*- coding: utf-8 -*-
from PyQt4 import QtCore, QtGui
import sys
from GUI import Ui_MainWindow
class MainWindow(QtGui.QMainWindow,Ui_MainWindow):
def __init__(self, parent=None):
QtGui.QWidget.__init__(self, parent)
self.ui = Ui_MainWindow()
self.ui.setupUi(self)
from module_b import calss_b
global instance_b
instance_b=calss_b(self)
instance_lambda1_username=lambda: instance_b.return_text_username(self.ui.lineEdit.text())##I want to add lineEdit_2
instance_lambda2_password=lambda: instance_b.printtext2(self.ui.lineEdit_2.text())
QtCore.QObject.connect(self.ui.pushButton, QtCore.SIGNAL("clicked()"), \
instance_lambda1_username)## Or add instance_lambda2_password here.
if __name__ == "__main__":
app = QtGui.QApplication(sys.argv)
global myapp
myapp = MainWindow()
myapp.show()
sys.exit(app.exec_())
module_b.py
import sys
from GUI import Ui_MainWindow
from PyQt4 import QtCore, QtGui
class calss_b (object):
def __init__(self, parent=None):
pass
def return_text_username (self, txt):
username=unicode(txt)
print username
return username
## I want print password and return it.
def return_printtext_password (self, txt):
password=unicode(txt)
print password
return password