Pyqt calling a custom dialog and returning the vars

David Boddie david at boddie.org.uk
Mon Apr 16 18:13:15 EDT 2007


On Monday 16 April 2007 22:06, Marcpp wrote:

> I call a dialog from a principal program but cannot return the value
> of the
> variables (text box's). Here is a example...

[...]

> class ag (Agenda):
> ...
> ...
>     def _slotAddClicked(self):
>         d=dialogo1()
>         d.exec_()
>         d.connect(d.buttonOk,SIGNAL("clicked()"),self._procesadialog1)
> 
>     def _procesadialog1():
>         d=dialogo1()
>         drempresa = d.dempresa.text()
>         print drempresa  #

Without seeing more of what you've done, it's difficult to tell, but
you are just creating a new dialog in _procesadialog1() and reading
the default text in its "dempresa" attribute which I presume is a
QLineEdit widget.

Assuming everything else is working correctly, I think you should
remove the second method and rewrite the first one in the following
way:

class ag (Agenda):
...
...
    def _slotAddClicked(self):
        d=dialogo1()
        if d.exec_() == QDialog.Accepted:
            drempresa = d.dempresa.text()
            print drempresa  #

David



More information about the Python-list mailing list