[PySide] Passing parameter from one class to an external function
craf
abarzuaf at gmail.com
Thu Apr 5 00:14:28 CEST 2012
Hi Everyone!.
Recently start with Pyside and I would like to know how I can call the
function greetings from within the Form class, passing the self
argument.
My Code:---------------------------------------------------
import sys
from PySide.QtCore import *
from PySide.QtGui import *
class Form(QDialog):
def __init__(self, parent=None):
QDialog.__init__(self, parent=None)
self.edit = QLineEdit("Write my name here")
self.button = QPushButton("Show Greetings")
self.layout = QVBoxLayout()
self.layout.addWidget(self.edit)
self.layout.addWidget(self.button)
self.setLayout(self.layout)
self.button.clicked.connect(greetings)
def greetings(self):
print ("Hello %s" % self.edit.text())
if __name__ == '__main__':
app = QApplication(sys.argv)
form = Form()
form.show()
sys.exit(app.exec_())
----------------------------------------------------
I try with:
self.button.clicked.connect(greetings)
self.button.clicked.connect(lambda e: greetings(self))
self.button.clicked.connect(lambda e, self=self:greetings(self))
but, nothing.
I appreciate any information
Best Regards
Cris
More information about the PySide
mailing list