I made a GUI in which after I click "Download" button the program will download files from FTP server. When doing that I want the label to update e.g: "Connecting..." -> "Downloading..." -> "Downloaded!" I tried doing it with threading module but it seems to not work:
def updater(self):
self.updateStatusText.setText("Status: Connecting...")
thread = threading.Thread(target=self.download)
thread.start()
while thread.isAlive():
self.updateStatusText.setText("Status: Still Downloading...")
def download(self):
ftp = FTP('testdomain.com')
ftp.login(user='username', passwd='password')
ftp.cwd('/main_directory/')
filename = 'testfile.bin'
with open(filename, 'wb') as localfile:
ftp.retrbinary('RETR ' + filename, localfile.write, 1024)
ftp.quit()
localfile.close()
It just downloads the file and doesn't change the text label at all. Do I have to use QThread here? I also tried using asyncio but awaiting self.updateStatusText.setText("Connecting...")
seems to return None and I get TypeError...