From 58d03fbea5fdc89fea17ebfee4392c8ed843333d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Gu=C3=A9gan?= Date: Thu, 19 Sep 2024 16:50:00 +0200 Subject: [PATCH] Minor changes --- tropical/qt/caldrawer.py | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/tropical/qt/caldrawer.py b/tropical/qt/caldrawer.py index 12645f9..f2e7558 100644 --- a/tropical/qt/caldrawer.py +++ b/tropical/qt/caldrawer.py @@ -34,6 +34,7 @@ class CalDrawerScene(QGraphicsScene): self.env=env self.calState=env.calState self.daysNames=["Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"] + self.monthNames=["January", "February", "March", "April", "May", "June","July","August", "September","October", "November", "December"] self.pullState() self.selection=self.today @@ -43,11 +44,32 @@ class CalDrawerScene(QGraphicsScene): self.defaultBrush=painter.brush() self.daysRect.clear() self.eventsRect.clear() - daysNamesH=self.drawDaysName(painter, origXI, origYI, widthI, heightI) - self.drawGrid(painter, origXI, origYI+daysNamesH, widthI, heightI-daysNamesH) + offsetX=0 + offsetX+=self.drawHeader(painter, origXI, origYI, widthI, heightI) + offsetX+=self.drawDaysName(painter, origXI, origYI+offsetX, widthI, heightI-offsetX) + self.drawGrid(painter, origXI, origYI+offsetX, widthI, heightI-offsetX) self.drawDaysLabel(painter) self.drawEvents(painter) + def drawHeader(self,painter, x, y, width, height): + # Init Pen + pen=QtGui.QPen() + pen.setWidth(self.gridWidth) + pen.setJoinStyle(Qt.PenJoinStyle.MiterJoin) + po=int(self.gridWidth/2) # Pen offset + painter.setPen(pen) + # Init Brush + painter.setBrush(Qt.BrushStyle.NoBrush) + # Init dimensions + font=painter.font() + metric=QtGui.QFontMetrics(font); + labelH=metric.boundingRect("".join(self.monthNames)).height() + # Draw + rect=QRect(x+po,y+po,width-po*2,height-po*2) # Draw grid + painter.drawRect(rect) + painter.drawText(x,y,width,height,Qt.AlignmentFlag.AlignHCenter,self.monthNames[self.calState.month]) + return labelH + def drawDaysName(self, painter, x, y, width, height): # Init Pen pen=QtGui.QPen()