views:

42

answers:

0

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'])