Note that there are some explanatory texts on larger screens.

plurals
  1. POQt show windows sequentially
    primarykey
    data
    text
    <p>I'm working on a Python Qt application which starts with a login window. After the login, I want to show the normal application window. As a test, I tried to show the AuthWindow (the login window) twice. The desired effect is for the login window to open once, I close it, then the second opens, etc. What actually happens it that the first opens, I close it, and the program exits.</p> <pre><code>import sys from PyQt4 import QtGui from AuthWindow import AuthWindow def main(): app = QtGui.QApplication(sys.argv) w = AuthWindow() w.show() w = AuthWindow() w.show() sys.exit(app.exec()) if __name__ == '__main__': main() </code></pre> <p>Here's the code for AuthWindow:</p> <pre><code>from PyQt4 import QtGui class AuthWindow(QtGui.QDialog): User, Admin = range(2) def __init__(self, parent = None): super().__init__(parent) self.setWindowTitle('Login') hbox = QtGui.QHBoxLayout(self) vbox = QtGui.QVBoxLayout() self.username = QtGui.QLineEdit() self.password = QtGui.QLineEdit() vbox.addWidget(QtGui.QLabel('Username')) vbox.addWidget(self.username) vbox.addWidget(QtGui.QLabel('Password')) vbox.addWidget(self.password) btn = QtGui.QPushButton('Login') btn.clicked.connect(self.loginClicked) hbox.addLayout(vbox) hbox.addWidget(btn) self.password.setEchoMode(QtGui.QLineEdit.Password) def loginClicked(self, ev): auth = self.checkLogin() print(auth) def checkLogin(self): username = self.username.text() password = self.password.text() print(username) print(password) # login logic will go here... </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload