Search code examples
pythonjupyter-notebookipywidgets

Rename checkboxes of ipywidgets.interact


How to rename displayed checkboxes of ipywidgets.interact to be different from names of variables?

import ipywidgets
def print_var(_print_or_not):
    if _print_or_not:
        print("printed")
    else:
        print("don't print")

ipywidgets.interact_manual(print_var, _print_or_not=True)

I want to have a custom text as the label of the checkbox. enter image description here

Edit: I don't want to change the label of the interact button, but the label of the checkbox ("_print_or_not" in this case).


Solution

  • This should be closed as duplicate of How do I change a button label created with 'interact_manual' from 'ipywidgets'? and how do I change the size and color of that button?

    Applying the solution from that question renames the checkbox as below:

    Output using linked solution