This is the code I have so far, Idealy, I want it to pause until the user clicks start again. Any help is appreciated:!! thanks so much :) <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()
set variable
argument to a control variable such as 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()
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.