Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Tk_slider_shuttle.py
- from tkinter import *
- root = Tk()
- root.title("Tk_slider_shuttle")
- root.geometry("160x600+10+10")
- speed = [-1000,-100,-10,-5,-1]
- speed += [0]+list(map(abs, speed[::-1]))
- speed = speed[::-1]
- label = Label(root, text="Slider Shuttle")
- label.pack(anchor="w", padx=10, pady=10)
- shuttle_slide = Scale(root, from_=0, to=10, length=500, tickinterval=1, variable=5, orient=VERTICAL)
- shuttle_slide.pack(anchor='w', padx=0, pady=20)
- shuttle_slide.val = 0
- shuttle_slide.active = 0
- shuttle_slide.set(5)
- frame = Frame(root, width=36, height=500)
- frame.place(x=1, y=62)
- incr = 46.9
- for i in range(0,11):
- t = Label(root, text=speed[i])
- t.place(x=56, y=i*incr+68)
- val = Label(root, font=("Arial", 18), text=0, fg='blue')
- val.place(x=80, y=30)
- def on_press(e):
- shuttle_slide.active = 1
- def on_release(e):
- shuttle_slide.active = 0
- shuttle_slide.set(5)
- root.bind("<ButtonRelease-1>", on_release)
- root.bind("<Button-1>", on_press)
- def main():
- if shuttle_slide.active:
- t = shuttle_slide.get()
- if speed[t]:
- shuttle_slide.val += speed[t]
- shuttle_slide.val = max(-9999, min(9999, shuttle_slide.val))
- val.config(text=shuttle_slide.val)
- root.after(400, main)
- main()
- root.mainloop()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement