Python Forum
Tkinter GUI freeze
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Tkinter GUI freeze
#1
Hi,

I'm using python 3.6.7 on Windows

I'm making a Tkinter GUI that will let you upload files to a destination using ftplib.
My problem is that if the files are big, the GUI will freeze (not responding) because the mainloop can't process the event, until the file are uploaded and the GUI are responsive again

I'm will not perform other actions while uploading files, but i would like to avoid that the GUI freeze completely.

Here is the function i'm calling
def loadDropdownFiles(self, txutmp):
    ftp = FTP(ipdest)
    ftp.login(user='xxx', passwd='xxx')
    ftp.cwd(txutmp)
    localfile = open(promodest, 'rb')
    ftp.storbinary('STOR ' + "promo.zip", localfile)
    tp.quit()
Any tips on how i can avaid the GUI freeze?
Reply
#2
See the following thread
https://python-forum.io/Thread-Tkinter-H...ng-the-gui
Reply
#3
Call the function using after(), which will run the function in a separate process
some_widget.after(100, loadDropdownFiles, txutmp))  ## call after 1/10 of a second 
Reply
#4
(Jun-21-2019, 01:06 AM)woooee Wrote: Call the function using after(), which will run the function in a separate process
some_widget.after(100, loadDropdownFiles, txutmp))  ## call after 1/10 of a second 

Just calling the method using after will not run the function in a separate process, after makes thing happen in the GUI's thread after a period of time, its the waiting time period itself that is in a different thread, the above will just delay the freezing.
Refer to the linked thread in my previous post, where a separate thread is used on the blocking code and after is used to make thread safe calls back to the GUI.
Reply
#5
Thank you Yoriz. exactly what i neded
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
Question [Tkinter] Sections of the code causes the GUI to freeze. What should I do? Wilkk 13 3,449 Jan-11-2023, 07:16 PM
Last Post: Wilkk
  [Tkinter] mpv window freeze before video end rfeyer 7 3,374 Feb-20-2021, 09:34 PM
Last Post: rfeyer
  [Tkinter] tkinter freeze DeanAseraf1 0 2,090 Jul-20-2019, 07:46 AM
Last Post: DeanAseraf1
  [Tkinter] GUI Freeze/tkinter SamGer 2 4,060 Jun-24-2019, 07:25 PM
Last Post: noisefloor

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020