[PyQt] Help with Login Dialog / QThread issues
eric.frederich at gmail.com
Fri Aug 5 17:46:11 BST 2011
On Thu, Jul 7, 2011 at 12:38 PM, Eric Frederich
<eric.frederich at gmail.com> wrote:
> I am trying to create a login dialog for my application.
> Logging in can take a couple of seconds so I wanted to show a progress
> bar during the login process.
> I think that for my QProgressBar to animate during this time, I need
> to log in on a different thread. Is this true?
> So, below I have what I think is a working example.
> Is there a better way to call QDialog's accept slot when the login
> thread is finished than how I am doing it via functools.partial?
> It seems a bit hacky.
> from functools import partial
> class LoginThread(QThread):
> def __init__(self, username, password, parent=None):
> super(LoginThread, self).__init__(parent)
> self.username = username
> self.password = password
> def run(self):
> class LoginDialog(QDialog, Ui_LoginDialog):
> def __init__(self, *args, **kwargs):
> super(LoginDialog, self).__init__(*args, **kwargs)
> def accept(self):
> self.lt = LoginThread(
> self.connect(self.lt, SIGNAL('finished()'),
> partial(QDialog.accept, self))
More information about the PyQt