Package: tkdial
TkDialThis is a library containing some circular rotatory dial-knob widgets for Tkinter. It can be used in place of normal sliders and scale.Installationpip install tkdialDial WidgetUsageSimple Example:importtkinterastkfromtkdialimportDialapp=tk.Tk()dial=Dial(app)dial.grid(padx=10,pady=10)app.mainloop()Example 2importtkinterastkfromtkdialimportDialapp=tk.Tk()# some color combinationscolor_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")]foriinrange(12):dial=Dial(master=app,color_gradient=color_combinations[i],unit_length=10,radius=40,needle_color=color_combinations[i][1])ifi<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()Example 3Implemented withCustomTkinterimportcustomtkinterfromtkdialimportDialcustomtkinter.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"),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"),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"),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=("green","green"),text_color="white",text="",unit_width=15,radius=50)dial4.grid(row=1,column=1,padx=20,pady=20)app.mainloop()Arguments:ParametersDescriptionmasterThe master parameter is the parent widgetbgThe default background color of the dial widgetwidthDefine width of the widget manually (optional)heightDefine height of the widget manually (optional)xDetermines the horizontal position of the dial in the canvasyDetermines the vertical position of the dial in the canvasstartThe start point of the range from where the needle will rotateendThe end point of the rangeradiusDetermines the distance of the unit lines between the center and the edge and also the length of the needle lineunit_lengthSpecify the length of the linesunit_widthSpecify the width of the linesunit_colorSpecify the color of the unit linesneedle_colorSpecify the color of the needle linecolor_gradientSpecify which color gradient will be used for the unitstextA string that will be displayed under the dial object with valuetext_colorSpecify the color of the text that will be displayed under the dial objecttext_fontSpecify the font of the text that will be displayed under the dial objectintegerA boolean (True/False), displays only the integer value in text if True (default=False)scrollA boolean (True/False), enables mouse scroll in dial (default=True)scroll_stepsNumber of steps per scrollstateSpecify the state of the needlecommandCall a function whenever the needle is rotatedMethods:MethodsDescription.get()get the current value of the dial.set()set the value of the dial.configure()configure parameters of the dialScroll KnobUsageSimple ExampleimporttkinterfromtkdialimportScrollKnobapp=tkinter.Tk()knob=ScrollKnob(app,start=0,end=100,steps=10)knob.grid()app.mainloop()Different Knob styles:importcustomtkinterfromtkdialimportScrollKnobapp=customtkinter.CTk()app.geometry("500x500")knob1=ScrollKnob(app,radius=250,progress_color="#87ceeb",steps=10,border_width=40,start_angle=90,inner_width=1,outer_width=1,text_font="calibri 20",text_color="#87ceeb",bar_color="black")knob1.grid(row=0,column=0)knob2=ScrollKnob(app,radius=200,progress_color="#7eff00",border_width=40,start_angle=90,inner_width=1,outer_width=0,text_font="calibri 20",text_color="#7eff00",integer=True,fg="#212325")knob2.grid(row=1,column=0)knob3=ScrollKnob(app,text=" ",radius=250,progress_color="white",bar_color="#2937a6",border_width=30,start_angle=0,inner_width=5,outer_width=0,text_font="calibri 20",steps=1,text_color="white",fg="#303ba1")knob3.grid(row=0,column=1)knob4=ScrollKnob(app,text=" ",steps=10,radius=200,bar_color="#242424",progress_color="yellow",outer_color="yellow",outer_length=10,border_width=30,start_angle=270,inner_width=0,outer_width=5,text_font="calibri 20",text_color="white",fg="#212325")knob4.grid(row=1,column=1)app.mainloop()Arguments:ParametersDescriptionmasterThe master parameter is the parent widgetbgThe default background color of the knob widgetwidthDefine width of the widget manually (optional)heightDefine height of the widget manually (optional)startThe start point of the range from where the bar will rotateendThe end point of the rangeradiusDefine the radius of the knobborder_widthDefine the width of progress bar with respect to the outer and inner ringstart_angleDetermines the angle from where to rotatetextA string that will be displayed on the knob with valuetext_colorSpecify the color of the text that will be displayed on the knobtext_fontSpecify the font of the text that will be displayed on the knobintegerA boolean (True/False), displays only the integer value in text if True (default=False)fgSpecify the color of the inner circleprogress_colorDefine the color of the progress barbar_colorDefine the color of the progress bar's backgroundinner_widthDefine the width of the inner ringinner_colorSpecify the color of the inner ringouter_widthDefine the width of the outer ringouter_lengthDefine the distance between progress bar and outer ringinner_colorSpecify the color of the outer ringstepsNumber of steps per scrollstateSpecify the state of the needlecommandCall a function whenever the bar is movedMethods:MethodsDescription.get()get the current value of the knob.set()set the value of the knob.configure()configure parameters of the knobMeterUsageSimple ExampleimporttkinterfromtkdialimportMeterroot=tkinter.Tk()dial=Meter(root)dial.pack(padx=10,pady=10)root.mainloop()Different Meter Styles:importcustomtkinterfromtkdialimportMeterapp=customtkinter.CTk()app.geometry("950x350")meter1=Meter(app,radius=300,start=0,end=160,border_width=0,fg="black",text_color="white",start_angle=270,end_angle=-270,text_font="DS-Digital 30",scale_color="white",needle_color="red")meter1.set_mark(140,160)# set red marking from 140 to 160meter1.grid(row=0,column=1,padx=20,pady=30)meter2=Meter(app,radius=260,start=0,end=200,border_width=5,fg="black",text_color="white",start_angle=270,end_angle=-360,text_font="DS-Digital 30",scale_color="black",axis_color="white",needle_color="white")meter2.set_mark(1,100,"#92d050")meter2.set_mark(105,150,"yellow")meter2.set_mark(155,196,"red")meter2.set(80)# set valuemeter2.grid(row=0,column=0,padx=20,pady=30)meter3=Meter(app,fg="#242424",radius=300,start=0,end=50,major_divisions=10,border_width=0,text_color="white",start_angle=0,end_angle=-360,scale_color="white",axis_color="cyan",needle_color="white",scroll_steps=0.2)meter3.set(15)meter3.grid(row=0,column=2,pady=30)app.mainloop()Arguments:ParametersDescriptionmasterThe master parameter is the parent widgetbgThe default background color of the meter widgetfgSpecify the color of the meter facewidthDefine width of the widget manually (optional)heightDefine height of the widget manually (optional)startThe start point of the range from where the needle will rotateendThe end point of the rangestart_angleDetermines the starting angle of the arcend_angleDetermines the final angle of the arcradiusDetermines the radius for the widgetmajor_divisionsDetermines the number of major lines in the scaleminor_divisionsDetermines the number of minor lines in the scalescale_colorSpecify the color of the meter scaleborder_widthDefine the width of the border case (default=1)border_colorSpecify the color of the border caseneedle_colorSpecify the color of the needle lineaxis_colorSpecify which color of the axis wheeltextA string that will be displayed under the meter with valuetext_colorSpecify the color of the text that will be displayed under the metertext_fontSpecify the font of the text that will be displayed under the meterintegerA boolean (True/False), displays only the integer value in text if True (default=False)scrollA boolean (True/False), enables mouse scroll in meter (default=True)scroll_stepsNumber of steps per scrollstateUnbind/Bind the mouse movement with the needlecommandCall a function whenever the needle is rotatedMethods:MethodsDescription.get()get the current value of the meter.set()set the value of the meter.configure()configure parameters of the meter.set_mark()set markings for the scale. Eg:meter.set_mark(from, to, color)JogWheelUsageimporttkinterfromtkdialimportJogwheelapp=tkinter.Tk()knob=Jogwheel(app)knob.grid()app.mainloop()Styles:importcustomtkinterfromtkdialimportJogwheelapp=customtkinter.CTk()wheel_1=Jogwheel(app,radius=200,fg="#045252",scale_color="white",text=None,button_radius=10)wheel_1.set_mark(0,100,"green")wheel_1.grid()wheel_2=Jogwheel(app,radius=200,fg="#045252",scale_color="white",start_angle=0,end_angle=360,start=0,end=200,text="Volume: ",button_radius=10)wheel_2.set_mark(0,50,"blue")wheel_2.set_mark(50,90,"green")wheel_2.set_mark(90,150,"orange")wheel_2.set_mark(150,200,"red")wheel_2.grid()app.mainloop()Arguments:ParametersDescriptionmasterThe master parameter is the parent widgetbgThe default background color of the widgetfgSpecify the color of the wheel facewidthDefine width of the widget manually (optional)heightDefine height of the widget manually (optional)startThe start point of the range from where the knob will rotateendThe end point of the rangestart_angleDetermines the starting angle of the arcend_angleDetermines the final angle of the arcradiusDetermines the radius for the widgetdivisionsDetermines the number of scale lines in the scaledivision_heightDetermines the height of scale linesscale_colorSpecify the color of the knob scaleborder_widthDefine the width of the border case (default=1)border_colorSpecify the color of the border casebutton_colorSpecify the color of the knobbutton_radiusSpecify the radius the knobtextA string that will be displayed with valuetext_colorSpecify the color of the text that will be displayedtext_fontSpecify the font of the text that will be displayedintegerA boolean (True/False), displays only the integer value in text if True (default=False)scrollA boolean (True/False), enables mouse scroll (default=True)scroll_stepsNumber of steps per scrollstateUnbind/Bind the mouse movement with the widgetcommandCall a function whenever the needle is rotatedMethods:MethodsDescription.get()get the current value of the knob.set()set the value of the knob.configure()configure parameters of the knob.set_mark()set markings for the scale. Eg:meter.set_mark(from, to, color)ImageKnobUsageimporttkinterfromtkdialimportImageKnobapp=tkinter.Tk()customknob=ImageKnob(app,image="knob.png")customknob.grid()app.mainloop()Styles:# Note: images are not provided, only for referenceimportcustomtkinterfromtkdialimportImageKnobapp=customtkinter.CTk()customknob=ImageKnob(app,image="knob.png",text_color="white",text="Volume ")customknob.grid(row=0,column=0)customknob2=ImageKnob(app,image="knob2.png",scale_image="scale1.png",text="",scale_width=120)customknob2.grid(row=0,column=1,padx=20)customknob3=ImageKnob(app,image="knob3.png",scale_image="scale2.png",text="",scale_width=50,start_angle=20,end_angle=-240,progress_color="cyan",progress=True)customknob3.grid(row=0,column=2)app.mainloop()Arguments:ParametersDescriptionmasterThe master parameter is the parent widgetbgThe default background color of the widgetwidthDefine width of the widget manually (optional)heightDefine height of the widget manually (optional)startThe start point of the range from where the knob will rotateendThe end point of the rangeimagepass the knob imagescale_imageadd a scale image (optional)scale_widthspecify relative distance between scale and knob imagestart_angleDetermines the starting angle of the knobend_angleDetermines the final angle of the knobradiusDetermines the radius for the widgettextA string that will be displayed with valuetext_colorSpecify the color of the text that will be displayedtext_fontSpecify the font of the text that will be displayedintegerA boolean (True/False), displays only the integer value in text if True (default=False)scrollA boolean (True/False), enables mouse scroll (default=True)scroll_stepsNumber of steps per scrollstateUnbind/Bind the mouse movement with the widgetcommandCall a function whenever the needle is rotatedMethods:MethodsDescription.get()get the current value of the widget.set()set the value of the widget.configure()configure parameters of the widgetNote: Images should be cropped in fixed ratio (1:1) and saved with transparency(png).ConclusionThis library is focused to create some circular widgets that can be used withTkinter/Customtkintereasily.
I hope it will be helpful in UI development with python.