How to use the ipysheet.cell function in ipysheet

To help you get started, we’ve selected a few ipysheet examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github QuantStack / ipysheet / ipysheet / test_all.py View on Github external
def test_cell_add():
    sheet1 = ipysheet.sheet()
    sheet2 = ipysheet.sheet()
    ipysheet.cell(0, 0, value='1')
    assert len(sheet1.cells) == 0
    assert len(sheet2.cells) == 1
    ipysheet.sheet(sheet1)
    ipysheet.cell(0, 0, value='2')
    ipysheet.cell(0, 1, value='2')
    assert len(sheet1.cells) == 2
    assert len(sheet2.cells) == 1

    with ipysheet.hold_cells():
        ipysheet.cell(1, 0, value='3')
        ipysheet.cell(1, 1, value='4')
        assert len(sheet1.cells) == 2
        assert len(sheet2.cells) == 1
    assert len(sheet1.cells) == 4
    assert len(sheet2.cells) == 1

    # nested hold cells
    sheet1 = ipysheet.sheet()
    with ipysheet.hold_cells():
        with ipysheet.hold_cells():
github QuantStack / ipysheet / ipysheet / test_all.py View on Github external
def test_cell_style():
    cell = ipysheet.cell(0, 0, color='red')
    assert cell.style['color'] == 'red'
    cell = ipysheet.cell(0, 0, background_color='blue')
    assert cell.style['backgroundColor'] == 'blue'
    cell = ipysheet.cell(0, 0, font_style='nice')
    assert cell.style['fontStyle'] == 'nice'
    cell = ipysheet.cell(0, 0, font_weight='bold')
    assert cell.style['fontWeight'] == 'bold'
github QuantStack / ipysheet / ipysheet / test_all.py View on Github external
a.value = 1
    b.value = 2
    assert c.row_start == 0

    @ipysheet.calculation(inputs=[a, b], output=(c, 'type'))
    def add2(a, b):  # pylint: disable=unused-variable
        return 'abcdefg'[a + b]

    assert c.type == 'd'
    b.value = 1
    assert c.type == 'c'

    ipysheet.sheet()
    a = ipysheet.cell(0, 0, value=1)
    b = ipysheet.cell(0, 0, value=widgets.IntSlider(value=2))
    c = widgets.IntSlider(max=0)
    d = ipysheet.cell(0, 0, value=1)

    @ipysheet.calculation(inputs=[a, (b, 'value'), (c, 'max')], output=d)
    def add3(a, b, c):  # pylint: disable=unused-variable
        return a + b + c

    assert d.value == 3
    a.value = 10
    assert d.value == 10+2
    b.value.value = 20
    assert d.value == 10+20
    c.max = 30
    assert d.value == 10+20+30

    b.value = widgets.IntSlider(value=2)
github QuantStack / ipysheet / ipysheet / test_all.py View on Github external
def test_cell_style():
    cell = ipysheet.cell(0, 0, color='red')
    assert cell.style['color'] == 'red'
    cell = ipysheet.cell(0, 0, background_color='blue')
    assert cell.style['backgroundColor'] == 'blue'
    cell = ipysheet.cell(0, 0, font_style='nice')
    assert cell.style['fontStyle'] == 'nice'
    cell = ipysheet.cell(0, 0, font_weight='bold')
    assert cell.style['fontWeight'] == 'bold'
github QuantStack / ipysheet / ipysheet / test_all.py View on Github external
b.value = 2
    assert c.row_start == 0

    @ipysheet.calculation(inputs=[a, b], output=(c, 'type'))
    def add2(a, b):  # pylint: disable=unused-variable
        return 'abcdefg'[a + b]

    assert c.type == 'd'
    b.value = 1
    assert c.type == 'c'

    ipysheet.sheet()
    a = ipysheet.cell(0, 0, value=1)
    b = ipysheet.cell(0, 0, value=widgets.IntSlider(value=2))
    c = widgets.IntSlider(max=0)
    d = ipysheet.cell(0, 0, value=1)

    @ipysheet.calculation(inputs=[a, (b, 'value'), (c, 'max')], output=d)
    def add3(a, b, c):  # pylint: disable=unused-variable
        return a + b + c

    assert d.value == 3
    a.value = 10
    assert d.value == 10+2
    b.value.value = 20
    assert d.value == 10+20
    c.max = 30
    assert d.value == 10+20+30

    b.value = widgets.IntSlider(value=2)
    assert d.value == 10+2+30
    b.value = 20
github QuantStack / ipysheet / ipysheet / test_all.py View on Github external
def test_cell_style():
    cell = ipysheet.cell(0, 0, color='red')
    assert cell.style['color'] == 'red'
    cell = ipysheet.cell(0, 0, background_color='blue')
    assert cell.style['backgroundColor'] == 'blue'
    cell = ipysheet.cell(0, 0, font_style='nice')
    assert cell.style['fontStyle'] == 'nice'
    cell = ipysheet.cell(0, 0, font_weight='bold')
    assert cell.style['fontWeight'] == 'bold'
github QuantStack / ipysheet / ipysheet / test_all.py View on Github external
assert len(sheet1.cells) == 2
    assert len(sheet2.cells) == 1

    with ipysheet.hold_cells():
        ipysheet.cell(1, 0, value='3')
        ipysheet.cell(1, 1, value='4')
        assert len(sheet1.cells) == 2
        assert len(sheet2.cells) == 1
    assert len(sheet1.cells) == 4
    assert len(sheet2.cells) == 1

    # nested hold cells
    sheet1 = ipysheet.sheet()
    with ipysheet.hold_cells():
        with ipysheet.hold_cells():
            ipysheet.cell(1, 0, value='3')
            ipysheet.cell(1, 1, value='4')
            assert len(sheet1.cells) == 0
        assert len(sheet1.cells) == 0
    assert len(sheet1.cells) == 2
github QuantStack / ipysheet / ipysheet / test_all.py View on Github external
def test_cell_add():
    sheet1 = ipysheet.sheet()
    sheet2 = ipysheet.sheet()
    ipysheet.cell(0, 0, value='1')
    assert len(sheet1.cells) == 0
    assert len(sheet2.cells) == 1
    ipysheet.sheet(sheet1)
    ipysheet.cell(0, 0, value='2')
    ipysheet.cell(0, 1, value='2')
    assert len(sheet1.cells) == 2
    assert len(sheet2.cells) == 1

    with ipysheet.hold_cells():
        ipysheet.cell(1, 0, value='3')
        ipysheet.cell(1, 1, value='4')
        assert len(sheet1.cells) == 2
        assert len(sheet2.cells) == 1
    assert len(sheet1.cells) == 4
    assert len(sheet2.cells) == 1

    # nested hold cells
    sheet1 = ipysheet.sheet()
    with ipysheet.hold_cells():
        with ipysheet.hold_cells():
            ipysheet.cell(1, 0, value='3')
github QuantStack / ipysheet / ipysheet / test_all.py View on Github external
def test_calculation():
    ipysheet.sheet()
    a = ipysheet.cell(0, 0, value=1)
    b = ipysheet.cell(0, 0, value=2)
    c = ipysheet.cell(0, 0, value=0)

    @ipysheet.calculation(inputs=[a, (b, 'value')], output=c)
    def add(a, b):  # pylint: disable=unused-variable
        return a + b

    assert c.value == 3
    a.value = 10
    assert c.value == 10 + 2
    b.value = 20
    assert c.value == 10 + 20

    a.value = 1
    b.value = 2
    assert c.row_start == 0

    @ipysheet.calculation(inputs=[a, b], output=(c, 'type'))
github QuantStack / ipysheet / ipysheet / test_all.py View on Github external
def test_cell_values():
    cell = ipysheet.cell(0, 0, value=True)
    assert cell.value is True
    assert cell.type == 'checkbox'

    cell = ipysheet.cell(0, 0, value=1.2)
    assert cell.value == 1.2
    assert cell.type == 'numeric'
    cell = ipysheet.cell(0, 0, value=1)
    assert cell.value == 1
    assert cell.type == 'numeric'

    cell = ipysheet.Cell(value='1.2')
    assert cell.value == '1.2'
    assert cell.type is None

    cell = ipysheet.row(0, [True, False])
    assert cell.value == [True, False]
    assert cell.type == 'checkbox'

    cell = ipysheet.row(0, [0, 1.2])
    assert cell.value == [0, 1.2]
    assert cell.type == 'numeric'

    cell = ipysheet.row(0, [0, 1])