first commit
This commit is contained in:
		
						commit
						10bc74524d
					
				
							
								
								
									
										48
									
								
								slider2json.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										48
									
								
								slider2json.py
									
									
									
									
									
										Normal file
									
								
							| @ -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() | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user