2010-11-11 50 views
1

我想使用EasyDialogs python模塊爲OSX上的我的python腳本生成一些簡單的對話框。每當我試圖導入EasyDialogs模塊我得到以下錯誤:無法導入EasyDialogs - 導入錯誤:沒有模塊命名爲_Dlg

>>> import EasyDialogs 
Traceback (most recent call last): 
    File "<stdin>", line 1, in <module> 
    File "/Library/Frameworks/EPD64.framework/Versions/6.2/lib/python2.6/plat-mac/EasyDialogs.py", line 24, in <module> 
    from Carbon.Dlg import GetNewDialog, SetDialogItemText, GetDialogItemText, ModalDialog 
    File "/Library/Frameworks/EPD64.framework/Versions/6.2/lib/python2.6/plat-mac/Carbon/Dlg.py", line 1, in <module> 
    from _Dlg import * 
ImportError: No module named _Dlg 

我試着做easy_install Carbon,因爲我以爲這可能是由於一些問題與碳包蟒蛇,但是這並沒有幫助。有任何想法嗎?

回答

2

從回溯中的路徑看來,您似乎正在使用64位Enthought Python Distribution。 EasyDialogs模塊使用各種OS X Carbon界面,其中許多OS X僅提供32位版本並且已被Apple棄用。出於這個原因,Python 2中的Python Carbon包裝和EasyDialogs模塊已被棄用,並且已在Python 3中被刪除。雖然它們可能以32位模式工作,但您應該避免在新代碼中使用它們。還有其他選擇:標準庫中的Tkinter,各種跨平臺GUI框架(請參閱here)。對於更簡單的對話框,您還可以使用osax包中的appscript來使用AppleScript的Standard AdditionsUser Interaction套件。

相關問題