I'm writing a music related GUI in Python and a part of my script concerning tracks is not working properly.
I have some entry boxes for release dates and recording dates of tracks, and I want to check whether they are empty or not.
My code is as follows:
if self.active_tab == 'Tracks':
print(f'Release = {self.dateReleaseEntry.get()}, Recording = {self.dateRecordEntry.get()}')
if self.dateReleaseEntry.get() or self.dateRecordEntry.get() == '':
print('One of the dates is empty, setting missing date to true.')
self.missingDate = True
print(self.missingDate)
if self.missingDate:
self.alert_window = Toplevel()
self.alert_window.title('Alert')
self.alert_window.geometry('200x100+0+0')
The result of the first print statements is "Release = , Recording = 2007-05-22 14:00:00". This tells me that the value of 'self.dateReleaseEntry.get()' is '' or in other words, an empty string. However, the second print statement never gets called, telling me that the program doesn't agree with me.
I have tried other methods of detecting whether the entry is empty or not (such as len(entry) == 0 and entry == 'None'/None). Unfortunately I'm having no luck. Could someone advise me on whether it's tkinter or me that's being dumb (be honest, I don't mind).
Thanks, J