import time teraz=time.localtime(time.time()) year, month, day, hour, minute, second, weekday, yearday, daylight = teraz datum="%02d.%02d.%04d" % (day, month, year) cas="%02d:%02d:%02d" % (hour, minute, second)Ale to mi zobrazi iba cas kedy som spustil program :(
Hladal som aj v googli ale o pythone a PyQt je tam toho malo popisane.
Dakujem za vsetky odpovede

import time from qt import * import sys def getTime(): cas = time.localtime((time.time())) h = cas[3] m = cas[4] s = cas[5] res = [] res.append(h) res.append(m) res.append(s) return res class MainWindow(QMainWindow): def __init__(self, *args): apply(QMainWindow.__init__, (self, ) + args) self.mainWidget=QWidget(self); self.vlayout = QVBoxLayout(self.mainWidget, 10, 5) self.lb = QLabel("Time", self.mainWidget) self.vlayout.addWidget(self.lb) self.setCentralWidget(self.mainWidget) self.timer = QTimer(self) QObject.connect(self.timer, SIGNAL("timeout()"), self.slotUpdate) self.timer.start(1000); def slotUpdate(self): t = getTime(); self.lb.setText(str(t[0])+":"+str(t[1])+":"+str(t[2])); def main(args): app=QApplication(args) win=MainWindow() win.show() app.exec_loop() if __name__=="__main__": main(sys.argv)http://vik.sh.cvut.cz/~tnt/python/tut/
nie je to dlhe
vytvoril si okno, label a timer na 1 sekundu kde updatuje label. v zivote som nepisal qt kod a vidim to tam. nic zlozite
self je klucove slovo odkazujuce sa na svoju triedu
self.lb je label z tej triedy
.setText je metoda na nastavenie textu v labeli
str(t[0])+":"+str(t[1])+":"+str(t[2]) je vytvorenie retazca pre ten label a je to v zatvorke, pretoze to predavas ako argument tej metode