Like I said in the hedding, my programm crashes sometimes when I start the following thread. I don't get any Error, It just closes sometimes... If it crashes, then it crashes in the first round of the while-loop. I think its because of the time.sleep(0.5) because everything before this line works perfectly fine. My complete Programm runs perfectly fine, its just this part here which gives me a headache:
def TimeClock(self):
time.sleep(5)
TimeThreadRunning = True
Datum = datetime.now()
self.ui.label_3.setText(Datum.strftime("%H : %M"))
while TimeThreadRunning == True:
print("Uhrzeit wird überprüft")
time.sleep(0.5)
Datum = datetime.now()
self.ui.label.setText(_translate("GUI", Datum.strftime("%d.%m.%Y")))
self.ui.label_2.setText(_translate("GUI", Datum.strftime("%H : %M")))
TimeTread = threading.Thread(target=TimeClock, args=(self,))
TimeTread.daemon = True
TimeTread.start()
Hope somebody can help. Greetingsfrom Germany