commit 10bc74524da7d1eb601cefc961c11748c8af79c5 Author: alban Date: Fri Aug 2 00:19:58 2019 +0200 first commit diff --git a/slider2json.py b/slider2json.py new file mode 100644 index 0000000..c61c1f9 --- /dev/null +++ b/slider2json.py @@ -0,0 +1,48 @@ + +from Tkinter import * + +import time +import json +from json import encoder +encoder.FLOAT_REPR = lambda o: format(o, '.2f') + +class PrettyFloat(float): + def __repr__(self): + return '%.15g' % self + +class App(): + def __init__(self): + self.root = Tk() + + self.label = Label(text="") + self.label.pack() + + self.w1 = Scale(self.root, from_=1000, to=1) + self.w1.pack() + self.w2 = Scale(self.root, from_=1000, to=1) + self.w2.pack() + self.w3 = Scale(self.root, from_=1000, to=1) + self.w3.pack() + self.w4 = Scale(self.root, from_=1000, to=1) + self.w4.pack() + self.update_clock() + self.root.mainloop() + +#{"velocity" : 0.0010,"expressivity" : 0.972,"sensibility" : 0.95,"beauty": 0.3} + + def update_clock(self): + + velocity = float(self.w1.get())/1000 + expressivity = float(self.w2.get())/1000 + sensibility = float(self.w3.get())/1000 + beauty = float(self.w4.get())/1000 + data = {'velocity':PrettyFloat(velocity), 'expressivity':PrettyFloat(expressivity),'sensibility':PrettyFloat(sensibility),'beauty':PrettyFloat(beauty)} + print( data ) + with open('/tmp/ws.json', 'w') as outfile: + json.dump(data, outfile) + now = time.strftime("%H:%M:%S") + self.label.configure(text=now) + self.root.after(1000, self.update_clock) + + +app=App()