如何在 python 中实现 tkinter 进度条,用户可以在其中暂停并在停止的相同位置重新启动进度条?

How to implement a tkinter progress bar in python where the user can pause and restart the progress bar at the same position it was stopped?

这是我目前的代码,理想情况下,我希望它暂停,直到用户再次点击开始。任何帮助表示赞赏!非常感谢 :) <3

from tkinter import *
from tkinter import ttk
import time
from threading import *
import threading
import _thread

def start():
   w.start()

def stop():
   time.sleep(10)


def stopfunc():
    _thread.start_new_thread(stop,())

window = Tk()

w = ttk.Progressbar(window)
w.pack()
button1 = ttk.Button(window, text = 'start', command = start)
button1.pack()
button2 = ttk.Button(window, text = 'stop', command = stopfunc)
button2.pack()
window.mainloop()

variable 参数设置为控制变量,例如 IntVar

from tkinter import *
from tkinter import ttk


def start():
    
   w.start()

def stopfunc():
    w.stop()
    #var.set(var.get())

def reset():
    var.set(0)

window = Tk()

var = IntVar()

w = ttk.Progressbar(window, variable=var)
w.pack()
button1 = ttk.Button(window, text = 'start', command = start)
button1.pack()
button2 = ttk.Button(window, text = 'stop', command = stopfunc)
button2.pack()

button2 = ttk.Button(window, text = 'reset', command = reset)
button2.pack()


window.mainloop()