Showing Progressbar status based on selection of radio buttons

Tkinter Progressbar

ttk Progressbar to radio buttons

Usually in online surveys user is shown one progress bar reflecting the number of tasks completed.

User has to select six pairs of radio buttons. Each pair of radio button has options Yes and No. User can select any one of the option and user has to complete selecting all six set of buttons.

The progress bar will show the progress based on the completed choices by the user.

There will be a reset button by clicking which the user can reset all the six radio buttons and the progress bar will reset to zero. Each completion of choice will increase the bar by 10 so the maximum value of the progress bar is 60.
Full code is here
import tkinter  as tk 
from tkinter import *
from tkinter import ttk
my_w = tk.Tk()
def my_upd(): 
    if(r1_v.get() != 'None'): 
        prg1['value'] += 10
        prg1['value'] += 10
        prg1['value'] += 10
        prg1['value'] += 10
        prg1['value'] += 10        
        prg1['value'] += 10
    l1.config(text=str(prg1['value'])) #update Label

prg1 = ttk.Progressbar(my_w,orient = HORIZONTAL,
        length = 320, mode = 'determinate',maximum=60),rely=.3)    

l1=tk.Label(my_w,text='value here',font=font1),rely=0.01)

r1_v = tk.StringVar()
r1_v.set(None) # (default value )
r11 = tk.Radiobutton(my_w,text='Yes', variable=r1_v, value='Yes',command=my_upd),rely=0.5) 
r12 = tk.Radiobutton(my_w,text='No', variable=r1_v, value='No',command=my_upd),rely=0.5) 

r2_v = tk.StringVar()
r2_v.set(None) # (default value )
r21 = tk.Radiobutton(my_w,text='Yes', variable=r2_v, value='Yes',command=my_upd),rely=0.5) 
r22 = tk.Radiobutton(my_w,text='No', variable=r2_v, value='No',command=my_upd),rely=0.5) 

r3_v = tk.StringVar()
r3_v.set(None) # (default value )
r31 = tk.Radiobutton(my_w,text='Yes', variable=r3_v, value='Yes',command=my_upd),rely=0.5) 
r32 = tk.Radiobutton(my_w,text='No', variable=r3_v, value='No',command=my_upd),rely=0.5) 

r4_v = tk.StringVar()
r4_v.set(None) # (default value )
r41 = tk.Radiobutton(my_w,text='Yes', variable=r4_v, value='Yes',command=my_upd),rely=0.7) 
r42 = tk.Radiobutton(my_w,text='No', variable=r4_v, value='No',command=my_upd),rely=0.7) 

r5_v = tk.StringVar()
r5_v.set(None) # (default value )
r51 = tk.Radiobutton(my_w,text='Yes', variable=r5_v, value='Yes',command=my_upd),rely=0.7) 
r52 = tk.Radiobutton(my_w,text='No', variable=r5_v, value='No',command=my_upd),rely=0.7) 

r6_v = tk.StringVar()
r6_v.set(None) # (default value )
r61 = tk.Radiobutton(my_w,text='Yes', variable=r6_v, value='Yes',command=my_upd),rely=0.7) 
r62 = tk.Radiobutton(my_w,text='No', variable=r6_v, value='No',command=my_upd),rely=0.7) 
def my_reset():
    l1.config(text='value here ')
my_w.mainloop()  # Keep the window open
Tkinter Progressbar to show status with options and methods to manage and display values


Options : value, mode ,orient ,variable etc.. start() step() and stop() Method example
Subscribe to our YouTube Channel here


* indicates required
Subscribe to plus2net

    Post your comments , suggestion , error , requirements etc here

    Python Video Tutorials
    Python SQLite Video Tutorials
    Python MySQL Video Tutorials
    Python Tkinter Video Tutorials
    We use cookies to improve your browsing experience. . Learn more
    HTML MySQL PHP JavaScript ASP Photoshop Articles FORUM . Contact us
    ©2000-2022 All rights reserved worldwide Privacy Policy Disclaimer