Minor changes
This commit is contained in:
parent
3c44a536a7
commit
277ed8637d
2 changed files with 25 additions and 7 deletions
tropical/qt
|
@ -1,13 +1,15 @@
|
|||
|
||||
from PyQt6.QtWidgets import QGraphicsScene, QGraphicsView, QSizePolicy
|
||||
from PyQt6 import uic, QtGui, QtCore
|
||||
from PyQt6.QtCore import Qt, QRect
|
||||
from PyQt6.QtCore import Qt, QRect, QEvent, QCoreApplication
|
||||
import math
|
||||
#https://forum.qt.io/topic/93327/how-can-i-use-qpainter-to-paint-on-qgraphicsview/5
|
||||
#https://www.pythonguis.com/tutorials/pyqt6-bitmap-graphics/#qpainter
|
||||
|
||||
# to solve the fit problem: https://stackoverflow.com/questions/61886358/qgraphicsview-fitinview-not-working-as-expected
|
||||
|
||||
DaySelectedEvent = QEvent.registerEventType()
|
||||
|
||||
class CalQGraphicsView(QGraphicsView):
|
||||
def __init__(self, scene):
|
||||
super().__init__(None)
|
||||
|
@ -19,7 +21,8 @@ class CalQGraphicsView(QGraphicsView):
|
|||
|
||||
|
||||
class CalDrawerScene(QGraphicsScene):
|
||||
def __init__(self, calState):
|
||||
def __init__(self, parent, calState):
|
||||
self.parent=parent
|
||||
self.gridWidth=2
|
||||
self.daysLabelBG="#dddddd"
|
||||
self.eventsLabelBG="#36e364"
|
||||
|
@ -193,12 +196,21 @@ class CalDrawerScene(QGraphicsScene):
|
|||
if r.contains(x,y):
|
||||
self.mouseOver=i
|
||||
self.update()
|
||||
event.accept()
|
||||
break
|
||||
|
||||
|
||||
def mousePressEvent(self, event):
|
||||
b=event.button()
|
||||
if self.mouseOver>=0 and b==Qt.MouseButton.LeftButton:
|
||||
event.accept()
|
||||
event = QEvent(DaySelectedEvent)
|
||||
QCoreApplication.postEvent(self.parent, event)
|
||||
|
||||
|
||||
class CalDrawer():
|
||||
|
||||
def __init__(self, layout, calState):
|
||||
self.gs=CalDrawerScene(calState)
|
||||
def __init__(self, parent, layout, calState):
|
||||
self.gs=CalDrawerScene(parent, calState)
|
||||
self.gv=CalQGraphicsView(self.gs)
|
||||
# Setup propertion
|
||||
spLeft=QSizePolicy(QSizePolicy.Policy.Preferred,QSizePolicy.Policy.Preferred);
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
from PyQt6.QtWidgets import QApplication, QWidget, QMainWindow
|
||||
from PyQt6 import uic, QtGui
|
||||
from PyQt6.QtCore import Qt
|
||||
from .caldrawer import CalDrawer
|
||||
from .caldrawer import *
|
||||
from .eventdrawer import EvtDrawer
|
||||
|
||||
from .createcalendar import CreateCalendar
|
||||
|
@ -17,13 +17,19 @@ class MainWindow(QMainWindow):
|
|||
def __init__(self,uipath, calState):
|
||||
super(MainWindow,self).__init__()
|
||||
uic.loadUi(uipath+"/MainWindow.ui",self)
|
||||
self.calDrawer=CalDrawer(self.calContainer.layout(),calState)
|
||||
self.calDrawer=CalDrawer(self, self.calContainer.layout(),calState)
|
||||
self.evtDrawer=EvtDrawer(self.calContainer.layout(),calState)
|
||||
self.calState=calState
|
||||
self.show()
|
||||
|
||||
def setVersion(self,version):
|
||||
self.statusbar.showMessage("Calanus v"+version,0)
|
||||
|
||||
def event(self, event):
|
||||
if event.type() == DaySelectedEvent:
|
||||
print("Ho")
|
||||
return QWidget.event(self,event) #super().event(event)
|
||||
|
||||
|
||||
def StartApplication(version,calState):
|
||||
path = os.path.dirname(os.path.abspath(__file__))+"/designer"
|
||||
|
|
Loading…
Add table
Reference in a new issue