[prev in list] [next in list] [prev in thread] [next in thread] 

List:       pykde
Subject:    Re: [PyQt] returning a value from a sub-dialog
From:       "Johoski, Timothy R" <timothy.r.johoski () intel ! com>
Date:       2013-07-25 21:02:09
Message-ID: 6A6C81C6EE0AD649BEC0D14FB78818CD6B81C1BB () ORSMSX107 ! amr ! corp ! intel ! com
[Download RAW message or body]

I'm a newbie, so take this with a grain of salt...  The quick example below shows a \
dialog with a label and line edit, then after the user presses OK or Cancel (or hits \
                return or escape), it prints what they typed in the line edit.  Hope \
                this helps.
- Tim

#/usr/bin/env python
import sys

from PyQt4.QtCore import *
from PyQt4.QtGui import *

app = QApplication(sys.argv)
dlg = QDialog()

l  = QLabel("Enter name:")
le = QLineEdit()
hl = QHBoxLayout()
hl.addWidget(l)
hl.addWidget(le)

bb = QDialogButtonBox(dlg)
bb.setStandardButtons(QDialogButtonBox.Cancel|QDialogButtonBox.Ok)
bb.accepted.connect(dlg.accept)
bb.rejected.connect(dlg.reject)

vl = QVBoxLayout(dlg)
vl.addLayout(hl)
vl.addWidget(bb)

retval = dlg.exec_()
name = le.text()

print "Dialog retval=%s, name entered=\"%s\"" % (retval, name)


> From: pyqt-bounces@riverbankcomputing.com \
>                 [mailto:pyqt-bounces@riverbankcomputing.com] On Behalf Of Hajas, \
>                 Wayne
> Sent: Thursday, July 25, 2013 11:36 AM
> To: pyqt@riverbankcomputing.com
> Subject: [PyQt] returning a value from a sub-dialog
> 
> I am hoping somebody can point me to a simple example to do the following:
> After a Dialog is created and filled-in by the user, get the values returned to the \
> rest of the application. 
> I have built applications around a single dialog.  Everything gets done under the \
> single dialog-class.  I can get it to work. 
> In the current application I am building, I need multiple dialogs.   I can generate \
> the extra dialogs but I can't figure out how to retrieve the data so I can use it \
> elsewhere in the application. 
> I think the solution is going to be trivial once I see it.  But I can't figure it \
> out right now and I can't come up with the right google-search. 
> Thanks in advance,
> Wayne Hajas
_______________________________________________
PyQt mailing list    PyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic