Skip to main content

A rotatory dial tkinter widget.

Project description

TkDial

This is a circular rotatory dial-knob widget for tkinter. It can be used in place of normal slider.

Usage

Simple Example:

import tkinter as tk
from tkdial import Dial

app = tk.Tk()

dial = Dial(app, color_gradient=("white", "black"))
dial.grid(padx=10, pady=10)

app.mainloop()

Screenshot1

Example 2

import tkinter as tk
from tkdial import Dial

app = tk.Tk()

#Some color combinations
color_combinations = [("yellow", "red"), ("white", "cyan"), ("red", "pink"), ("black", "green"),
                    ("white", "black"), ("blue", "blue"), ("green", "green"), ("white", "pink"),
                    ("red", "black"), ("green", "cyan"), ("cyan","black"), ("pink", "blue")]

for i in range (12):
    dial = Dial(master=app, color_gradient=color_combinations[i],
                unit_length=10, radius=40, needle_color=color_combinations[i][1])
    if i<6:
        dial.grid(row=1, padx=10, pady=10, column=i)
    else:
        dial.grid(row=2, padx=10, pady=10, column=11-i)

app.mainloop()

Screenshot2

Example 3

Implemented with CustomTkinter

import customtkinter
from tkdial import Dial

customtkinter.set_appearance_mode("Dark") 
              
app = customtkinter.CTk()
app.geometry("350x400")
                
app.grid_columnconfigure((0,1), weight=1)
app.grid_rowconfigure((0,1), weight=1)

frame_1 = customtkinter.CTkFrame(master=app)
frame_1.grid(padx=20, pady=20, sticky="nswe")

dial1 = Dial(master=frame_1, color_gradient=("green", "cyan"), bg="#2a2d2e",
             text_color="white", text="Current: ", unit_length=10, radius=50)
dial1.grid(padx=20, pady=20)

dial2 = Dial(master=frame_1, color_gradient=("yellow", "white"), bg="#2a2d2e",
             text_color="white", text="Position: ", unit_length=10, radius=50)
dial2.grid(padx=20, pady=20)

dial3 = Dial(master=frame_1, color_gradient=("white", "pink"), bg="#2a2d2e",
             text_color="white", text=" ", unit_length=10, radius=50)
dial3.grid(row=0, column=1, padx=20, pady=20)

dial4 = Dial(master=frame_1, color_gradient=("red", "red"), bg="#2a2d2e",
             text_color="white", text="", unit_width=15, radius=50)
dial4.grid(row=1, column=1, padx=20, pady=20)

app.mainloop()                  

Screenshot 3

Documentation

Options:

Parameters Description
master The master parameter is the parent widget
bg The default background color of the dial widget
width Define width of the widget manually (optional)
height Define height of the widget manually (optional)
x Determines the horizontal position of the dial in the canvas
y Determines the vertical position of the dial in the canvas
start The start point of the range where the needle will rotate
end The end point of the range where the needle will rotate
radius Determines the distance of the unit lines between the center and the edge and also the length of the needle line
unit_length Specify the length of the lines
unit_width Specify the width of the lines
unit_color Specify the color of the unit lines
needle_color Specify the color of the needle line
color_gradient Specify which color gradient will be used for the units
text A string that will be displayed under the dial object
text_color Specify the color of the text that will be displayed under the dial object
text_font Specify the font of the text that will be displayed under the dial object
integer A boolean (True/False), displays only the integer value in text if True
command Call a function whenever the needle is rotated

Methods:

Methods Description
.get() get the current value of the dial
.set() set the value of the dial
.set_text() configure text of the dial

Conclusion

This widget is based on this VolumeControl widget with lots of modifications.

I hope it will be helpful for UI development in tkinter.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

tkdial-0.0.1.tar.gz (10.9 kB view hashes)

Uploaded Source

Built Distribution

tkdial-0.0.1-py3-none-any.whl (9.5 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page