[PySide] Passing parameter from one class to an external function
Tibold Kandrai
kandraitibold at gmail.com
Thu Apr 5 07:36:51 CEST 2012
Hey!
You can use another method in the class to handle the event and call the
greetings with self:
http://pastebin.com/0m6csu6v
Or you can use functools.partial:
http://pastebin.com/NH3PNmKE
Best regards,
On 05/04/2012 00:28, craf wrote:
> 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
>
>
> _______________________________________________
> PySide mailing list
> PySide at qt-project.org
> http://lists.qt-project.org/mailman/listinfo/pyside
--
Tibold Kandrai,
CEO @ Dotz Team I/S,
Software developer, consultant
More information about the PySide
mailing list