from Tkinter import *
from visual import *
import time,sys,thread

class Program:
    def __init__(self,parent):
        self.parent = parent
        self.run = "run"
        
        parent.wm_geometry(newGeometry="200x300+80+80")   
        parent.wm_title("Controls")

        scene.x = 250
        scene.y = 200

        self.rr = 1
        self.angle = 0
        self.sphere1 = sphere(pos=(sin(self.angle),cos(self.angle),0), radius=0.03,color=(self.rr,0,0))

        self.scene.autoscale = 0

	thread.start_new_thread(self.box_anim,())

    def set_red(self,rstr):
        self.rr = string.atoi(rstr)/100.0
        self.sphere1.color = (self.rr,0,0)
        
    def box_anim(self):
        while (self.run == "run"):
            self.angle = self.angle+pi/32.0
            self.sphere1.pos = (sin(self.angle),cos(self.angle),0)
            rate(30)
        pp.run = "stopped"

tkr = Tk() 
pp = Program(tkr) 

scalerr = Scale(tkr,orient=VERTICAL,from_=100,to=0,label="R",command=lambda str: pp.set_red(str))
scalerr.pack(side=LEFT)

scalerr.set(pp.rr*100.0)

tkr.mainloop()

pp.run = "stop" 
while pp.run == "stop":
    time.sleep(0.1) 

scene.hide()






