Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/333.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
iPython小部件:交互不';不能使用类方法-AttributeError_Python_Widget_Ipython_Ipython Notebook_Attributeerror - Fatal编程技术网

iPython小部件:交互不';不能使用类方法-AttributeError

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)) 生成此异常: -----

我在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))
生成此异常:

---------------------------------------------------------------------------
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"))