Replies: 2 comments
-
@emcek self.after(5000, lambda: self.progressbar.stop()) # time is in milliseconds |
Beta Was this translation helpful? Give feedback.
0 replies
-
@Akascape from pathlib import Path
from tempfile import gettempdir
import customtkinter
from requests import get
class App(customtkinter.CTk):
def __init__(self):
super().__init__()
self.progressbar = customtkinter.CTkProgressBar(self, mode='indeterminate')
self.btn_start = customtkinter.CTkButton(self, text='Start', command=self._start)
self.btn_start.grid(row=0, column=0)
self.btn_stop = customtkinter.CTkButton(self, text='Stop', command=self._stop)
self.btn_stop.grid(row=1, column=0)
self.long = customtkinter.CTkButton(self, text='Long', command=self._long)
self.long.grid(row=2, column=0)
def _start(self):
self.progressbar.grid(row=3, column=0)
self.progressbar.start()
def _stop(self):
self.progressbar.stop()
self.progressbar.grid_forget()
def _long(self):
self.progressbar.grid(row=3, column=0)
self.progressbar.start()
local = Path(gettempdir()) / 'dcspy_2.2.0.exe'
url = 'https://github.com/emcek/dcspy/releases/download/v2.2.0/dcspy_2.2.0.exe'
download_file(url, local)
self.progressbar.stop()
self.progressbar.grid_forget()
def download_file(url, save_path):
response = get(url=url, stream=True, timeout=5)
if response.ok:
print(f'Download file from: {url}')
with open(save_path, 'wb+') as dl_file:
for chunk in response.iter_content(chunk_size=128):
dl_file.write(chunk)
print(f'Saved as: {save_path}')
return True
else:
print(f'Can not download from: {url}')
return False
app = App()
app.mainloop() |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I need show and start CTkProgressBar in indeterminate mode (since this would be a long task), when task finish I would like to hide progress bar.
Start and Stop is fine, but when I click Long it just wait 5 sec or do anything (execute method I see logs it really doing it), but progress bar do not show up.
I guess it is king of 'repaint' issue, because instead of sleep I start message box to get user input progress bar appear for shot time.
I try even setup callback (but no luck) with:
I'm missing something???
Beta Was this translation helpful? Give feedback.
All reactions