【发布时间】:2015-05-28 17:57:29
【问题描述】:
我正在使用 IPython (IPython.html.widgets) 的模块小部件,创建一些小部件。
我正在做的是创建一堆小部件,比如说 4 个整数滑块:
w1 = widgets.IntSliderWidget(description='w1')
w2 = widgets.IntSliderWidget(description='w2')
w3 = widgets.IntSliderWidget(description='w3')
w4 = widgets.IntSliderWidget(description='w4')
我想在函数a_function() 上使用函数interact() 来玩小部件。但是我希望有一个代码,我没有在函数的参数中明确列出所有小部件(通用的东西)。比如:
def a_function(**kwargs):
print kwargs
# do other things...
kwargs = {}
kwargs['w1'] = w1
kwargs['w2'] = w2
kwargs['w3'] = w3
kwargs['w4'] = w4
# calling the function interact() to interact with the function a_function()
interact(a_function, **kwargs)
我的问题是 Python 中的字典未排序,但我想管理小部件在笔记本中出现的顺序。我想确保小部件w1 将出现在w2 之前,w2 在w3 之前,等等...
有解决这个问题的建议吗?
非常感谢您的帮助!
【问题讨论】:
标签: python-2.7 widget ipython-notebook