[PyKDE] Newbie PyQt question
Andreas Pauley
andreasp+pykde at qbcon.com
Tue Mar 8 09:50:09 GMT 2005
Hi all,
I've started writing an app (point of sale) that needs to first show a
login dialog (and succesfully authenticate a user) before showing the main
window.
I've managed to do this, but my program fails to exit and return to the
command prompt whenever the authentication failed and the main window
never gets showed. The login window closes, but the command I use to
start the app (python main.py) just hangs until I manually kill the
proccess.
The problem doesn't occur when the program exits after the main window is
shown.
I'm using QT 3.3.3 with PyQt 3.13.
Regards,
Andreas
Here is a summary of my code.
(This can also be downloaded from
http://www.qbcon.com/downloads/python/qualitypos-minimal.tgz (12k))
In main.py I do:
qapp = QApplication(sys.argv)
QObject.connect(qapp,SIGNAL("lastWindowClosed()"),qapp,SLOT("quit()"))
poswindow = QualityPOS()
qapp.setMainWidget(poswindow)
poswindow.login()
qapp.exec_loop()
In the QualityPOS login() method:
class QualityPOS(QualityPOSBase):
def login(self):
loginwindow = Login(self)
loginwindow.show()
loginwindow.exec_loop()
The clicked signal of my login form connects to the authenticate() method
in my Login class:
class Login(LoginBase):
def __init__(self, poswindow):
LoginBase.__init__(self)
self.authenticated = False
self.poswindow = poswindow
def authenticate(self):
username=str(self.lnedUsername.text())
password=str(self.lnedPassword.text())
user=User.getUser(username, password)
if user:
self.poswindow.show()
self.authenticated = True
else:
self.authenticated = False
QMessageBox.warning(None,
self.trUtf8("Login Incorrect"),
self.trUtf8("""The user id and password you entered is
incorrect."""),
None,
None,
None,
0, -1)
return self.authenticated
More information about the PyQt
mailing list