I'm doing software that controls my computer with a wireless navigator that includes Windows CE. I'm doing this with Python.

Okay, so lets begin. One of those control options is audio volume controlling. I have a code, that can change Windows XP WaveOut volume on a scale of 0-255. I want to make a horizontal bar so user can change computers volume over network. I have a function SetVolume(new_volume) that takes a argument called new volume. How can I make a horizontal bar what controls the volume? That bar should be like this:

0 |---------------------*----------| 255

The volume control is fixed in point *. For example like in Windows Media Player, or that tray icon, but it must be horizontal and on a scale of 0-255.

That image can help to understand. The red line should be movable with mouse. When the red line moves so it will need to pass a value between 0-255, depending on the point where it is.

Best regards


PS. Sorry for my bad english. I'm not from a country where people speak english. I hope you understand.

Here is an example of a Tkinter scale/slider bar ...

# exploring Tkinter's Scale (slider) widget

    # Python2
    import Tkinter as tk
except ImportError:
    # Python3
    import tkinter as tk

class ScaleDemo(tk.Frame):
    def __init__(self, parent=tk.Tk()):
        tk.Frame.__init__(self, parent)
        self.parent = parent
        tk.Label(self, text="Scale/Slider").pack()
        #self.var = tk.IntVar()
        self.scale1 = tk.Scale(self, label='volume',
            from_=0, to=255,
            length=300, tickinterval=30,
    def onMove(self, value):
        """ you can use value or self.scale1.get() """
        s = "moving = %s" % value
        # show result in the title

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.