“sunset_time = time(18,30,00)”行产生一个 'QTime' object is NOT callable 错误......我做错了什么?......我的应用程序应该获取并显示当前时间然后设置日落时间然后从日落时间中减去当前时间,以获得并显示“距离日落还有几分钟”
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