【问题标题】:wx 'easy gui' library; how do I keep this code from crashing IDLE & Other python IDEs?wx 'easy gui' 库;如何防止此代码崩溃 IDLE 和其他 python IDE?
【发布时间】:2010-01-31 02:53:00
【问题描述】:

当我在 IDLE 中运行此代码时,它会崩溃。但是,如果我在 IDLE 之外运行它,它就可以正常工作。

有几个用 python 编写的 Python IDE 遇到同样的问题,但如果我使用不是基于它的 IDE/编辑器,它们也可以正常运行。

有没有办法修改这段代码,以免弄乱 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()

哦,如果还不是很明显,我将把它导入另一个文件,然后像这样调用 MultiChoiceDialog:

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

【问题讨论】:

  • 你在哪个平台和python版本上运行?
  • 究竟是如何导入的以及文件是如何命名的?
  • 导入文件名为'wxEasyGUI.py',我使用的python版本是2.6.4

标签: python python-idle wxwidgets


【解决方案1】:

Ubuntu 上带有 wx 2.8.11.0 的最新 IDLE (2.7.2) 版本不会导致 IDLE 崩溃。

【讨论】:

    猜你喜欢
    • 2014-09-25
    • 2018-10-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-04-19
    • 2011-11-25
    相关资源
    最近更新 更多