The "sunset_time = time(18,30,00)" line yields a 'QTime' object is NOT callable error.... what am I doing wrong?..My application is supposed to get and display current time then set sunset time and then subtract current time from sunset time in order to get and display "minutes left until sunset"
timer = QtCore.QTimer(self)
time= QtCore.QTime.currentTime()
timer.timeout.connect(self.showlcd)
timer.timeout.connect(self.showlcd_2)
timer.start(1000)
self.showlcd()
def showlcd(self):
time = QtCore.QTime.currentTime()
current = time.toString('hh:mm')
self.ui.lcdNumber.display(current)
def showlcd_2(self):
time = QtCore.QTime.currentTime()
sunset = time.toString('18:30')
current_time =(time.hour,time.minute,time.second)
sunset_time = time(18,30,00)
TillSunset = sunset_time-current_time
minutesTillSunset=divmod(TillSunset.seconds, 60)
self.ui.lblTillSunset.setText("minutesTillSunset.%s" %minutesTillSunset)
self.ui.lcdNumber_2.display(sunset)
def showTimeTillSunset(self):
self.ui.lblTillSunset.display(TillSunset)
pixmapTwo = QPixmap(os.getcwd() + '/sunset.jpg')
lblSunsetPic.setPixmap(pixmapTwo)
lblSunsetPic.show
I don't understand the logic of doing the following:
The correct thing is to create QTime from the sunset and "subtract" it, which is equivalent to knowing the time between those QTimes that can be obtained through the secsTo method: