Reputation: 21
I was wondering if it was possible to make a Tkinter scale correspond with the volume of the computer. In other words, by dragging the scale up, could the volume of the computer increase? Here is just some random code I drew up. I am running a a 64-Bit Windows 7 operating system.
1 from Tkinter import *
2
3 def sel():
4 selection = "Value = " + str(var.get())
5 label.config(text = selection)
6
7 root = Tk()
8 var = DoubleVar()
9 scale = Scale( root, variable = var )
10 scale.pack(anchor=CENTER)
11
12 button = Button(root, text="Get Scale Value", command=sel)
13 button.pack(anchor=CENTER)
14
15 label = Label(root)
16 label.pack()
17
18 root.mainloop()
Honestly I do not care if it can't be done. I was just wondering if it was possible. Thanks for all the help!
Upvotes: 2
Views: 4419
Reputation: 153
I know that this is an old question, but the top answer is out of the scope of most people's abilities. I write in python to avoid C, not to embrace it.
The realistic best answer is to install something for the command line (e.g. Nircmd) and then to use subprocess
(preinstalled) to call it e.g.subprocess.getoutput("nircmd setsysvolume 0")
Hope this helps anyone else who finds it.
Upvotes: 1
Reputation: 45542
See Changing master volume level for how to do this in C and then mix with How to use win32 API's with python. Then bind your resulting callbacks to Tkinter gui events.
Upvotes: 1