Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

I don't think that there's an exact equivalent for the SageCell specific ButtonBar component.

Usually, you'd use ipywidgets to build something like this in a notebook. Here's a rough demo:

from ipywidgets import Button, GridBox, Layout, Text

value = Text()

buttons = []
for label in ["(", ")", ".", "+", "1", "2", "3", "-", "4", "5", "6", "*", "7", "8", "9", "/", "=", "0", "⟳", "←" ]:
    button = Button(description=label)
    def on_click(_, label=label):
        # Note the late binding workaround (label=label) without it all buttons are going to do the same)
        # TODO: Add your logic here.
        value.value += label
    button.on_click(on_click)
    buttons.append(button)

GridBox(buttons + [value], layout=Layout(grid_template_columns="repeat(4, 100px)"))