iPython小部件:交互不';不能使用类方法-AttributeError
我在ipython笔记本上遇到了一个问题。我想在一些类meethods中实现ipython小部件,但在本期github中提到的ipython v2中似乎还不可能实现: 引自fperez 此代码:iPython小部件:交互不';不能使用类方法-AttributeError,python,widget,ipython,ipython-notebook,attributeerror,Python,Widget,Ipython,Ipython Notebook,Attributeerror,我在ipython笔记本上遇到了一个问题。我想在一些类meethods中实现ipython小部件,但在本期github中提到的ipython v2中似乎还不可能实现: 引自fperez 此代码: from IPython.html.widgets import interact class Foo(object): def show(self, x): print x f = Foo() interact(f.show, x=(1,10)) 生成此异常: -----
from IPython.html.widgets import interact
class Foo(object):
def show(self, x):
print x
f = Foo()
interact(f.show, x=(1,10))
生成此异常:
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
<ipython-input-58-b03b8685dfc0> in <module>()
7 f = Foo()
8
----> 9 interact(f.show, x=(1,10))
/home/fperez/usr/lib/python2.7/site-> packages/IPython/html/widgets/interaction.pyc in interact(__interact_f, > **kwargs)
235 f = __interact_f
236 w = interactive(f, **kwargs)
--> 237 f.widget = w
238 display(w)
239 return f
AttributeError: 'instancemethod' object has no attribute 'widget'
我收到了这个错误消息
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
TypeError: <lambda>() got an unexpected keyword argument 'WidgetNameFoo'
我需要传输一个描述字段,该字段根据情况而变化
谢谢你的帮助!=) 第二个错误(意外的关键字参数)是最近修复的错误:。现在,不要将description
参数传递给与interact()一起使用的小部件。
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
TypeError: <lambda>() got an unexpected keyword argument 'WidgetNameFoo'
def constructWidgets(self):
interact(lambda a:self.getWidgetValue(a),a=widgets.FloatSliderWidget(min=-10.0, max=10.0, step=0.1, value=5.0, description="a"))