当前位置: 首页>>代码示例>>Python>>正文


Python ipywidgets.Widget方法代码示例

本文整理汇总了Python中ipywidgets.Widget方法的典型用法代码示例。如果您正苦于以下问题:Python ipywidgets.Widget方法的具体用法?Python ipywidgets.Widget怎么用?Python ipywidgets.Widget使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ipywidgets的用法示例。


在下文中一共展示了ipywidgets.Widget方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: widget_dict_to_msg

# 需要导入模块: import ipywidgets [as 别名]
# 或者: from ipywidgets import Widget [as 别名]
def widget_dict_to_msg(msg_instance, d):
    for key in d:
        if isinstance(d[key], widgets.Widget):
            if key == 'img':
                img_msg = img_to_msg(d[key].value)
                for slot in img_msg.__slots__:
                    setattr(msg_instance, slot, getattr(img_msg, slot))
                return
            else:
                setattr(msg_instance, key, d[key].value)
        else:
            submsg = getattr(msg_instance, key)
            widget_dict_to_msg(submsg, d[key]) 
开发者ID:RoboStack,项目名称:jupyter-ros,代码行数:15,代码来源:ros_widgets.py

示例2: _assign

# 需要导入模块: import ipywidgets [as 别名]
# 或者: from ipywidgets import Widget [as 别名]
def _assign(object, value):
    if isinstance(object, widgets.Widget):
        object, trait = object, 'value'
    else:
        object, trait = object
    setattr(object, trait, value) 
开发者ID:QuantStack,项目名称:ipysheet,代码行数:8,代码来源:easy.py

示例3: cell

# 需要导入模块: import ipywidgets [as 别名]
# 或者: from ipywidgets import Widget [as 别名]
def cell(row, column, value=0., type=None, color=None, background_color=None,
         font_style=None, font_weight=None, style=None, label_left=None, choice=None,
         read_only=False, numeric_format='0.000', date_format='YYYY/MM/DD', renderer=None, **kwargs):
    """Adds a new ``Cell`` widget to the current ``Sheet``

    Args:
        row (int): Zero based row index where to put the cell in the sheet
        column (int): Zero based column index where to put the cell in the sheet
        value (int, float, string, bool, Widget): The value of the cell
        {args}

    Returns:
        The new ``Cell`` widget.

    Example:
        >>> from ipysheet import sheet, cell
        >>>
        >>> s1 = sheet()
        >>> cell(0, 0, 36.)            # The Cell type will be 'numeric'
        >>> cell(1, 0, True)           # The Cell type will be 'checkbox'
        >>> cell(0, 1, 'Hello World!') # The Cell type will be 'text'
        >>> c = cell(1, 1, True)
        >>> c.value = False            # Dynamically changing the cell value at row=1, column=1
    """
    global _cells
    if type is None:
        if isinstance(value, bool):
            type = 'checkbox'
        elif isinstance(value, numbers.Number):
            type = 'numeric'
        elif isinstance(value, widgets.Widget):
            type = 'widget'
        else:
            type = 'text'
        if choice is not None:
            type = 'dropdown'

    style = style or {}
    if color is not None:
        style['color'] = color
    if background_color is not None:
        style['backgroundColor'] = background_color
    if font_style is not None:
        style['fontStyle'] = font_style
    if font_weight is not None:
        style['fontWeight'] = font_weight
    c = Cell(value=value, row_start=row, column_start=column, row_end=row, column_end=column,
             squeeze_row=True, squeeze_column=True, type=type, style=style, choice=choice,
             read_only=read_only, numeric_format=numeric_format, date_format=date_format,
             renderer=renderer, **kwargs)
    if _hold_cells:
        _cells += (c,)
    else:
        _last_sheet.cells = _last_sheet.cells+(c,)
    if label_left:
        if column-1 < 0:
            raise IndexError("cannot put label to the left of column 0")
        cell(row, column-1, value=label_left, font_weight='bold')
    return c 
开发者ID:QuantStack,项目名称:ipysheet,代码行数:61,代码来源:easy.py


注:本文中的ipywidgets.Widget方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。