Nov-27-2020, 04:29 PM
Hello,I a Python beginner and am unable to code a scrpit coding for for a window with a start button and a stop button able to start an stop a progressbar in tkinter. My script start the proression but cannot stop it.
Thanks for your help!!
Thanks for your help!!
import tkinter as tk from tkinter import * def create_window(): from tkinter import ttk import time def start(): for x in range (5): myprogress['value']+=20 root.update_idletasks() time.sleep(1) print(myprogress['value']) def stop(): myprogress.stop() root= Tk() root.geometry("660x400") myprogress=ttk.Progressbar(root, orient=HORIZONTAL, length=300, mode='indeterminate') myprogress.pack(pady=20) mybutton=Button(root, text="start", command=start) mybutton.pack(pady=20) mybuttonstop=Button(root, text="stop", command=stop) mybuttonstop.pack(pady=20) root.mainloop() root = tk.Tk() b = tk.Button(root, text="Create new window", command=create_window) b.grid(row=4, column=3, sticky=W+E, padx=10, pady=20) root.mainloop()