Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Selector buttons are wrapped #302

Open
jasongrout opened this issue May 9, 2012 · 0 comments
Open

Selector buttons are wrapped #302

jasongrout opened this issue May 9, 2012 · 0 comments

Comments

@jasongrout
Copy link
Member

Notice that in sage notebook, these buttons are wrapped:

import random

def init():
    global B,Br,n,round,tm,t,v
    B = 40
    Br = 15
    n = 1
    round = 0
    tm = 0
    t = walltime()


init()    

html("<h1 align=center>Zeros</h1>")
html("<h2 align=center><font color='blue'>How many zeros?</font></h2>")

@interact
def zeros(a=selector(buttons=True, nrows=1, values=['Reset'] + [1..B], default=1)):
    if a == 'Reset': 
        init()
    html("<center>")
    global B,Br,n,round,tm,t,v
    if a == n:
        if round > 0:
           html("<font size=+3 color='red'>RIGHT</font>")
        r = walltime() - t
        tm += r
        round += 1
        t = walltime()
        while True:
           n2 = random.randrange(1,Br)
           if n2 != n:
               n = n2
               break
        if Br < B:
            Br += 2
    elif round > 0:
        html("<font size=+2 color='blue'>Wrong. Try again...</font>")
    html("</center>")
    html("<font size=+%s color='#333'>"%random.randrange(-2,5))
    print  ' '*random.randrange(20) + '0'*n
    html("</font>")
    if round > 0:
        html("<br><br><center>Score: %s rounds, Average time: %.1f seconds</center>"%(
                 round, float(tm)/round))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant