我的问题是相同的to this unanswered question,但我想添加我的上下文(包版本),并且由于缺乏声誉点而无法提出上一个问题。 (请根据SE规则让我知道我应该怎么做。)
以下几行:
import wx
from traitsui.api import View, Item, Group, HSplit, Handler, EnumEditor, FileEditor
导致以下错误:
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
<ipython-input-2-ad1e3b62165b> in <module>()
----> 1 from traitsui.api import View, Item, Group, HSplit, Handler, EnumEditor, FileEditor
/usr/local/lib/python2.7/dist-packages/traitsui/api.py in <module>()
34
35 try:
---> 36 from .editors.api import ArrayEditor
37 except ImportError:
38 # ArrayEditor depends on numpy, so ignore if numpy is not present.
/usr/local/lib/python2.7/dist-packages/traitsui/editors/__init__.py in <module>()
21
22 try:
---> 23 from .api import ArrayEditor
24 except ImportError:
25 pass
/usr/local/lib/python2.7/dist-packages/traitsui/editors/api.py in <module>()
22 from .button_editor import ButtonEditor
23 from .check_list_editor import CheckListEditor
---> 24 from .code_editor import CodeEditor
25 from .color_editor import ColorEditor
26 from .compound_editor import CompoundEditor
/usr/local/lib/python2.7/dist-packages/traitsui/editors/code_editor.py in <module>()
34 #-------------------------------------------------------------------------------
35
---> 36 class ToolkitEditorFactory ( EditorFactory ):
37 """ Editor factory for code editors.
38 """
/usr/local/lib/python2.7/dist-packages/traitsui/editors/code_editor.py in ToolkitEditorFactory()
46
47 # Background color for marking lines
---> 48 mark_color = Color( 0xECE9D8 )
49
50 # Object trait containing the currently selected line (optional)
/usr/local/lib/python2.7/dist-packages/traits/traits.pyc in __call__(self, *args, **metadata)
520
521 def __call__ ( self, *args, **metadata ):
--> 522 return self.maker_function( *args, **metadata )
523
524 class TraitImportError ( TraitFactory ):
/usr/local/lib/python2.7/dist-packages/traits/traits.pyc in Color(*args, **metadata)
1234 from traitsui.toolkit_traits import ColorTrait
1235
-> 1236 return ColorTrait( *args, **metadata )
1237
1238 Color = TraitFactory( Color )
/usr/local/lib/python2.7/dist-packages/traitsui/toolkit_traits.pyc in ColorTrait(*args, **traits)
5
6 def ColorTrait ( *args, **traits ):
----> 7 return toolkit().color_trait( *args, **traits )
8
9 def RGBColorTrait ( *args, **traits ):
/usr/local/lib/python2.7/dist-packages/traitsui/toolkit.pyc in toolkit(*toolkits)
150 if ETSConfig.toolkit:
151 # If a toolkit has already been set for ETSConfig, then use it:
--> 152 _toolkit = _import_toolkit(ETSConfig.toolkit)
153 return _toolkit
154 else:
/usr/local/lib/python2.7/dist-packages/traitsui/toolkit.pyc in _import_toolkit(name)
81
82 def _import_toolkit ( name ):
---> 83 return __import__( name, globals=globals(), level=1 ).toolkit
84
85
/usr/local/lib/python2.7/dist-packages/traitsui/wx/__init__.py in <module>()
24 #-------------------------------------------------------------------------------
25
---> 26 import toolkit
27
28 # Reference to the GUIToolkit object for wxPython
/usr/local/lib/python2.7/dist-packages/traitsui/wx/toolkit.py in <module>()
56 import PythonDropTarget
57
---> 58 from constants \
59 import WindowColor, screen_dx, screen_dy
60
/usr/local/lib/python2.7/dist-packages/traitsui/wx/constants.py in <module>()
59 BorderedGroupColor = wx.Colour( 224, 224, 224 )
60 else:
---> 61 WindowColor = wx.SystemSettings_GetColour( wx.SYS_COLOUR_MENUBAR )
62
63 # Standard width of an image bitmap
AttributeError: 'module' object has no attribute 'SystemSettings_GetColour'
我怀疑更新的软件包之间不兼容,因此以下是版本:
Python 2.7.12 on Ubuntu 16.04
traits==4.6.0
traitsui==5.1.0
wxPython==4.0.0b2
wxPython-common==3.0.2.0
我设置(在终端中,在进入python之前):
export ETS_TOOLKIT=wx
答案 0 :(得分:0)
问题是删除&#34; _&#34;静态方法的版本,而traitsui还没有完全迁移。见https://docs.wxpython.org/MigrationGuide.html#static-methods。