from tkinter import *
import time
from threading import *
window = Tk()
window.geometry('600x450')
window.resizable(width=False, height=False)
def dow():
while True:
window.title("Загрузка.")
window.title("Загрузка..")
window.title("Загрузка...")
window.title("Загрузка....")
def startk():
window.mainloop()
Thread(target = startk()).start()
Thread(target = dow()).start()
from tkinter import *
import time
from threading import *
DoLoading = False
def dow():
global DoLoading
while DoLoading:
window.title("Загрузка.")
time.sleep(1)
window.title("Загрузка..")
time.sleep(1)
window.title("Загрузка...")
time.sleep(1)
window.title("Загрузка....")
time.sleep(1)
window.title("Готов")
def loading():
global DoLoading
DoLoading = True
Thread(target = dow).start()
def loading_stop():
global DoLoading
DoLoading = False
window = Tk()
window.geometry('600x450')
window.resizable(width=False, height=False)
btn = Button(window, text="Готово", command=loading_stop)
btn.grid(column=1, row=0)
loading()
window.mainloop()
from tkinter import *
import time
from threading import *
class My_window(Tk):
def __init__(self):
super(My_window,self).__init__()
self._state = None
self._thread = Thread(target=self.loop_poop)
self._thread.setDaemon(True)
self._thread_active = False
def loop_poop(self):
while self._thread_active:
if self._state:
time.sleep(1)
self.title (time.ctime())
else:
pass
@property
def is_downloading(self):
return self._state
@is_downloading.setter
def is_downloading(self,tpm):
print('Start threding', tpm)
if tpm == True:
if self._thread_active == True:
self._state=True
else:
self._state=True
self._thread_active=True
self._thread.start()
elif tpm == False:
self._state = False
else:
return(False)
def on(window):
window.is_downloading = True
def off(window):
window.is_downloading = False
window = My_window()
on_btn = Button(window,text='on', height=1, width=20, command=lambda window = window:on(window)).pack()
off_btn = Button(window,text='off', height=1, width=20, command=lambda window = window:off(window)).pack()
window.geometry('400x50')
window.resizable(width=False, height=False)
window.mainloop()