Ask Your Question

Interact selector containing card suits

asked 2020-04-07 11:33:07 +0100

castor gravatar image

updated 2020-04-15 15:29:34 +0100

I have the following code that used to work in the Python 2 era:

def _(S=selector([r"$\diamondsuit$",r"$\heartsuit$",r"$\spadesuit$",r"$\clubsuit$"],default=r"$\diamondsuit$",nrows=1,buttons=True,label="suits")):

Now it providesimage description. Is there a way to have the expected symbols in the selector? Thank you for your suggestions in advance.

OK, it seems to work online using SageMath Cell, in case of Jupyter Notebook I still do not know an answer. image description

edit retag flag offensive close merge delete


FrédéricC gravatar imageFrédéricC ( 2020-04-07 13:28:17 +0100 )edit

That is what I looked for. It seems that the code works online using SageMath Cell, but not in Jupyter Notebook.

castor gravatar imagecastor ( 2020-04-15 15:27:34 +0100 )edit

1 Answer

Sort by » oldest newest most voted

answered 2020-04-15 17:45:42 +0100

Juanjo gravatar image

In a Jupyter notebook, try this code:

def _(S=selector([u"\u2664",u"\u2661",u"\u2662",u"\u2667"],default=u"\u2664",
                 nrows=1, buttons=True, label="suits")):

The next code gives hints on formatting the layout and shows a different set of symbols:

def suits(S=selector(["\u2660","\u2665","\u2666","\u2663"],
                     default="\u2660", nrows=1, label="Suits")):
    show(html(f"You selected {S}"))
W = suits.widget
W.box_style = "info" # try success, info, danger, warning
W.layout = {"border": "2px solid #aaf"}
buttons, output = W.children
buttons.button_style = "warning"  # try success, info, danger, warning = {"description_width": "3em", "font_weight": "bold", "button_width": "5em"}

See here a screen capture: image description

edit flag offensive delete link more


Thank you, it is great. Also thanks for the second part.

castor gravatar imagecastor ( 2020-04-15 18:06:37 +0100 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower


Asked: 2020-04-07 11:33:07 +0100

Seen: 268 times

Last updated: Apr 15 '20