1 | initial version |
It doesn't appear to be possible as of early 2017 to use HTML in SageMathCell interacts. I think this is because the software used to display code (CodeMirror) is automatically escaping the characters <
, >
and &
that are needed to tell the browser to render content as HTML.
You can however get this to work by using Unicode characters, making sure to preface the strings with u
. The number of rows of buttons for L2
is controlled by the nrows
option. The width
option appears to be ignored by SageMathCell. I've also formatted the labels to all selectors using LaTeX, since that forces them to stay on one line.
Here's some modified code:
L1=[u"♕",u"♖",u"♗",u"♘",u"♙",u"♛",u"♜",u"♝",u"♞",u"♟"]
L2=["a1","a3","a5","a7","b2","b4","b6","b8","c1","c3","c5","c7","d2","d4","d6","d8","e1","e3","e5","e7", "f2","f4","f6","f8","g1","g3","g5","g7","h2","h4","h6","h8"]
L3=[u"Yes (Sí)","No (No)"]
@interact
def ChessCoords(Q1=selector(L1,buttons=True,label="$\\text{Question 1:} \\; \\text{g4}$"),
Q2=selector(L2,buttons=True,label=u"$\\text{Question 2:} \\; ♗ \\,$",nrows=4),
Q3=selector(L3,buttons=True,label="$\\text{Question 3:} \\;\\;\\;\\;$")):
if L1.index(Q1)==0 and L2.index(Q2)==0 and L3.index(Q3)==0:
pretty_print(html(""))
pretty_print(html("To compute final coordinates, select your answers."))
else:
pass
and here's how it looks in action.