-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvolume_slider.py
More file actions
21 lines (17 loc) · 844 Bytes
/
volume_slider.py
File metadata and controls
21 lines (17 loc) · 844 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
import tkinter as tk
class VolumeSlider(tk.Scale):
""" A Scale object - that is, a slide-control - for
reporting and changing the current volume. """
def __init__(self, master, **kw):
""" Initialize the slider and bind the events for
clicking, dragging, and releasing an item in it."""
tk.Scale.__init__(self, master, kw)
self.bind('<B1-Motion>', self.shift_selection)
self.bind('<ButtonRelease-1>', self.button_release)
self.master = master
def shift_selection(self, event):
""" Define what to do while the user drags the slider. """
self.master.change_volume(self.get())
def button_release(self, event):
""" Define what to do when the user releases the mouse button. """
self.master.change_volume(self.get())