widget.py 文件源码

python
阅读 26 收藏 0 点赞 0 评论 0

项目:altair_widgets 作者: altair-viz 项目源码 文件源码
def _controllers_for(opt):
    """
    Give a string representing the parameter represented, find the appropriate
    command.

    """
    colors = [None, 'blue', 'red', 'green', 'black']
    controllers = {'type': widgets.Dropdown(options=['auto detect'] +\
                           _get_types(), description='type'),
                   'bin': widgets.Checkbox(description='bin'),
                   'aggregate': widgets.Dropdown(options=[None] +\
                                _get_functions(), description='aggregate'),
                   'zero': widgets.Checkbox(description='zero'),
                   'text': widgets.Text(description='text value'),
                   'scale': widgets.Dropdown(options=['linear', 'log'],
                                             description='scale'),
                    'color': widgets.Dropdown(options=colors,
                                             description='main color'),
                    'applyColorToBackground': widgets.Checkbox(description='applyColorToBackground'),
                    'shortTimeLabels': widgets.Checkbox(description='shortTimeLabels')
                  }

    for title, controller in controllers.items():
        controller.title = title
        if 'Checkbox' in str(controller):
            # traits = dir(controller.layout)
            # traits = [t for t in traits if t[0] != '_']
            controller.layout.max_width = '200ex'
            # controller.layout.min_width = '100ex'
            # controller.layout.width = '150ex'

    return controllers[opt]
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号