feat: added timestamp to information widget log items

This commit is contained in:
Ignacio Muñoz Fernandez 2020-11-26 22:55:53 +01:00 committed by Dan Albert
parent 28cf42aeb8
commit 3ad57d995b
2 changed files with 9 additions and 3 deletions

View File

@ -1,3 +1,4 @@
import datetime
class Information():
@ -5,7 +6,12 @@ class Information():
self.title = title
self.text = text
self.turn = turn
self.timestamp = datetime.datetime.now()
def __str__(self):
s = "[" + str(self.turn) + "] " + self.title + "\n" + self.text
return s
return '[{}][{}] {} {}'.format(
self.timestamp.strftime("%Y-%m-%d %H:%M:%S") if self.timestamp is not None else '',
self.turn,
self.title,
self.text
)

View File

@ -8,5 +8,5 @@ class QInfoItem(QStandardItem):
def __init__(self, info: Information):
super(QInfoItem, self).__init__()
self.info = info
self.setText("[%02d]" % self.info.turn + " " + self.info.title + ' : {:<16}'.format(info.text))
self.setText(str(info))
self.setEditable(False)