summaryrefslogtreecommitdiff
path: root/tropical/qt/eventdrawer.py
diff options
context:
space:
mode:
Diffstat (limited to 'tropical/qt/eventdrawer.py')
-rw-r--r--tropical/qt/eventdrawer.py36
1 files changed, 27 insertions, 9 deletions
diff --git a/tropical/qt/eventdrawer.py b/tropical/qt/eventdrawer.py
index 331139f..c1b450f 100644
--- a/tropical/qt/eventdrawer.py
+++ b/tropical/qt/eventdrawer.py
@@ -18,20 +18,22 @@ class EvtQGraphicsView(QGraphicsView):
class EvtDrawerScene(QGraphicsScene):
- def __init__(self, calState, env):
+ def __init__(self, env):
self.gridWidth=2
super().__init__(None)
- self.calState=calState
self.env=env
self.eventsRect=list()
+ self.eventsList=list()
def drawForeground(self, painter, rect):
+ self.eventsList=self.env.listEventsOn(2024,10,1)
+ self.eventsRect.clear()
origXF, origYF, widthF, heightF = rect.getRect()
origXI, origYI, widthI, heightI = (int(origXF),int(origYF),int(widthF),int(heightF))
- self.drawEvents(painter,origXI, origYI, widthI, heightI)
+ self.drawEventsBG(painter,origXI, origYI, widthI, heightI)
+ self.drawEventsText(painter,origXI, origYI, widthI, heightI)
-
- def drawEvents(self,painter,x,y,width,height):
+ def drawEventsBG(self,painter,x,y,width,height):
# Init Pen
pen=QtGui.QPen()
pen.setWidth(self.gridWidth)
@@ -46,14 +48,28 @@ class EvtDrawerScene(QGraphicsScene):
eventHeight=80
colorWidth=20
- for e in self.env.listEventsOn(2024,10,1):
+ for e in self.eventsList:
r=QRect(x+po,y+po,width-po*2,eventHeight-po*2)
+ self.eventsRect.append(r)
painter.drawRect(r)
-
+
+ def drawEventsText(self,painter,x,y,width,height):
+ font=painter.font()
+ metric=QtGui.QFontMetrics(font);
+ labelH=metric.boundingRect("Hello event").height()
+ for i in range(0,len(self.eventsRect)):
+ e=self.eventsList[i]
+ r=self.eventsRect[i]
+ painter.drawText(r.x(),r.y()+labelH,"Hello event")
+
+ def setEvents(self, events):
+ print(events)
+ pass
+
class EvtDrawer():
- def __init__(self, layout, calState, env):
- self.gs=EvtDrawerScene(calState, env)
+ def __init__(self, layout, env):
+ self.gs=EvtDrawerScene(env)
self.gv=EvtQGraphicsView(self.gs)
# Setup propertion
spLeft=QSizePolicy(QSizePolicy.Policy.Preferred,QSizePolicy.Policy.Preferred);
@@ -70,3 +86,5 @@ class EvtDrawer():
# self.gv.setSizePolicy(spLeft);
layout.addWidget(self.gv)
+ def setEvents(self,events):
+ self.gs.setEvents(events)