here2share

# Tk_qwikfix_sliders.py

Jun 23rd, 2020
365
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.30 KB | None | 0 0
  1. # Tk_qwikfix_sliders.py
  2.  
  3. from Tkinter import *
  4.  
  5. root = Tk()
  6. root.title("Tk Qwikfix Sliders")
  7.  
  8. SlideTest = 1
  9.  
  10. vars_init = '''
  11. AAA
  12. BBB
  13. CCC
  14. RGB, 0, 255
  15. DEG, 0, 360
  16. '''.strip().splitlines()
  17.  
  18. if SlideTest:
  19.     oldSliderValues = ''
  20.     def refresh():
  21.         try:
  22.             canvas.update()
  23.         except:
  24.             pass
  25.  
  26.     def getSliderValues():
  27.         global oldSliderValues
  28.         sliderVector = []
  29.         for z in range(len(vars)):
  30.             sliderVector.append(str(vars[z].get()))
  31.         if oldSliderValues != sliderVector:
  32.             oldSliderValues = sliderVector
  33.             print '\t\t'.join(sliderVector)
  34.         iframe.after(500, getSliderValues)
  35.  
  36.     sliderframes = Frame(root)
  37.     sliderframes.pack(side=TOP)
  38.  
  39.     slider = {}
  40.     vars = {}
  41.  
  42.     iframe = Frame(root)
  43.     iframe.pack(side=BOTTOM)
  44.  
  45.     for z in range(len(vars_init)):
  46.         VAR = vars_init[z].replace(' ','')
  47.         slider[z] = Frame(sliderframes)
  48.         slider[z].pack(side=TOP)
  49.         vars[z] = DoubleVar()
  50.         FROM, TO, L = -250, 250, 500
  51.         if ',' in VAR:
  52.             t = VAR.split(',')[0]
  53.             VAR = "'"+t+"'"+VAR[len(t):]
  54.             VAR, FROM, TO = eval(VAR)
  55.         w = Scale(slider[z], from_=FROM, to=TO, variable=vars[z], length=L, orient=HORIZONTAL)
  56.         w.set(0)
  57.         w.pack(side=TOP)
  58.         L = Label(slider[z], text=VAR)
  59.         L.pack(side=TOP)
  60.  
  61.     refresh = Button(text='UPDATE', command=refresh)
  62.     refresh.pack(side=LEFT)
  63.  
  64.     getSliderValues()
  65. mainloop()
Add Comment
Please, Sign In to add comment