-
Notifications
You must be signed in to change notification settings - Fork 47
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Loop stops after dialog goes away #65
Comments
this looks like it's working as expected. The wizard closes, then the application quits because all windows attached to the application are closed, but the asyncio loop attached to the QApplication hasn't closed yet. You either need the extra QWidget or you need to reorganize your application. Example reordering: async def amain():
global app # not technically needed, but adds clarity
wiz1 = QWizard()
wiz1.addPage(QWizardPage())
wiz1.setWindowTitle("First Wizard")
result = await async_dialog_exec(wiz1)
if result != QDialog.Accepted:
app.quit()
return
wiz2 = QWizard()
wiz2.addPage(QWizardPage())
wiz2.setWindowTitle("Second Wizard")
result = await async_dialog_exec(wiz2)
if result != QDialog.Accepted:
app.quit()
return
app.quit()
app = QApplication(sys.argv)
loop = QEventLoop(app)
asyncio.set_event_loop(loop)
with loop:
asyncio.ensure_future(amain())
loop.run_forever() Just because this is expected doesn't mean it's the best way for quamash to be designed. (perhaps the loop should wrap a |
This is now a sort of feature request that's essentially a duplicate of #33. In all cases so far there's been a workaround, but nested execs are a thing people expect to be able to do since you can do them in vanilla Qt. |
I re-read this and I will need to investigate further. |
hrm. I'm not able to reproduce (I'm on Mac OS X using python 3.5.2 and PyQt5.6) I'll try on windows and linux when I get home. |
replicated on windows. In all cases the problem is that the loop exits when all windows are closed, so a dummy window that keeps the app open and the do to the magic of duck typing, this will work: app = QApplication(sys.argv)
wiz1 = QWizard()
wiz1.addPage(QWizardPage(wiz1))
wiz1.setWindowTitle("First Wizard")
loop = QEventLoop(wiz1)
asyncio.set_event_loop(loop)
with loop:
loop.run_forever()
wiz2 = QWizard()
wiz2.addPage(QWizardPage(wiz2))
wiz2.setWindowTitle("Second Wizard")
loop = QEventLoop(wiz2)
asyncio.set_event_loop(loop)
with loop:
loop.run_forever() |
adding |
Please disregard if I'm doing something bone-headed. It may be due to my lack, of either asyncio or Qt knowledge.
I'm trying to show two dialogs, one after the other.
In this small example I use
QWizard
'sAfter the first one goes away either by pressing cancel or finish, I get the error shown below.
However, if I have a button sitting there in the background it behaves just fine.
If instead of running
run_until_complete(amain())
I runasyncio.ensure_future(amain())
followed byloop.run_forever()
then I don't get any errors but the 2nd wizard never shows up. It just exists as soon as there is nothing left to display on the screen.The text was updated successfully, but these errors were encountered: