Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Tk_qwikfix_sliders.py
- from Tkinter import *
- root = Tk()
- root.title("Tk Qwikfix Sliders")
- SlideTest = 1
- vars_init = '''
- AAA
- BBB
- CCC
- RGB, 0, 255
- DEG, 0, 360
- '''.strip().splitlines()
- if SlideTest:
- oldSliderValues = ''
- def refresh():
- try:
- canvas.update()
- except:
- pass
- def getSliderValues():
- global oldSliderValues
- sliderVector = []
- for z in range(len(vars)):
- sliderVector.append(str(vars[z].get()))
- if oldSliderValues != sliderVector:
- oldSliderValues = sliderVector
- print '\t\t'.join(sliderVector)
- iframe.after(500, getSliderValues)
- sliderframes = Frame(root)
- sliderframes.pack(side=TOP)
- slider = {}
- vars = {}
- iframe = Frame(root)
- iframe.pack(side=BOTTOM)
- for z in range(len(vars_init)):
- VAR = vars_init[z].replace(' ','')
- slider[z] = Frame(sliderframes)
- slider[z].pack(side=TOP)
- vars[z] = DoubleVar()
- FROM, TO, L = -250, 250, 500
- if ',' in VAR:
- t = VAR.split(',')[0]
- VAR = "'"+t+"'"+VAR[len(t):]
- VAR, FROM, TO = eval(VAR)
- w = Scale(slider[z], from_=FROM, to=TO, variable=vars[z], length=L, orient=HORIZONTAL)
- w.set(0)
- w.pack(side=TOP)
- L = Label(slider[z], text=VAR)
- L.pack(side=TOP)
- refresh = Button(text='UPDATE', command=refresh)
- refresh.pack(side=LEFT)
- getSliderValues()
- mainloop()
Add Comment
Please, Sign In to add comment