简体   繁体   中英

wx 'easy gui' library; how do I keep this code from crashing IDLE & Other python IDEs?

When I run this code in IDLE, it crashes. However, if I run it outside of IDLE it works just fine.

There are a couple of Python IDEs that are written in python that suffer the same problem, but if I use an IDE/editor that's not based on it, those run fine as well.

Is there any way of modifying this code so it doesn't muck up IDLE & Friends?

import wx

def MultiChoiceDialog(parent, title, message, choices):
    app = wx.PySimpleApp()
    app.MainLoop()
    dlg = wx.MultiChoiceDialog(parent, title, message, choices)

    try:
        if dlg.ShowModal() == wx.ID_OK:
            selections = dlg.GetSelections()
            strings = [choices[x] for x in selections]

            return strings
        else:
            return False
    finally:
        dlg.Destroy()
        app.Destroy()

Oh, and if it's not already obvious, I'm importing this in another file, and calling MultiChoiceDialog like so:

#Choice = MultiChoiceDialog(None, 'Title', 'Message', ['game1', 'game2', 'game3'])

在Ubuntu上具有wx 2.8.11.0的IDLE(2.7.2)的最新版本不会使IDLE崩溃。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM