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