Code Monkey home page Code Monkey logo

Comments (6)

harvimt avatar harvimt commented on June 23, 2024 4

adding app.setQuitOnLastWindowClosed(False) makes everything work correctly.

from quamash.

harvimt avatar harvimt commented on June 23, 2024

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 QtCore.QEventLoop or QtCore.QThread instead of a QApplication in order to keep app from quitting until the future run with run_until_complete exits

from quamash.

harvimt avatar harvimt commented on June 23, 2024

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.

from quamash.

harvimt avatar harvimt commented on June 23, 2024

I re-read this and I will need to investigate further.

from quamash.

harvimt avatar harvimt commented on June 23, 2024

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.

from quamash.

harvimt avatar harvimt commented on June 23, 2024

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()

from quamash.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.