summaryrefslogtreecommitdiff
path: root/tropical/qt/mainwindow.py
blob: f9f9ac0ca19969abafaa01188757e36ae885fa46 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#!/usr/bin/env python3


from PyQt6.QtWidgets import QApplication, QWidget, QMainWindow
from PyQt6 import uic, QtGui
from PyQt6.QtCore import Qt
from .caldrawer import *
from .eventdrawer import EvtDrawer

from .createcalendar import CreateCalendar
# Only needed for access to command line arguments
import sys, os


class MainWindow(QMainWindow):

    def __init__(self,uipath, env):
        super(MainWindow,self).__init__()
        uic.loadUi(uipath+"/MainWindow.ui",self)
        self.calDrawer=CalDrawer(self, self.calContainer.layout(), env)
        self.evtDrawer=EvtDrawer(self.calContainer.layout(), env)
        self.show()
        print(self.calDrawer.getSelectionEvents())

    def setVersion(self,version):
        self.statusbar.showMessage("TropiCal v"+version,0)

    def event(self, event):
        if event.type() == DaySelectedEvent:
            self.evtDrawer.setEvents(self.calDrawer.getSelectionEvents())
        return QWidget.event(self,event) #super().event(event)

        
def StartApplication(env):
    path = os.path.dirname(os.path.abspath(__file__))+"/designer"
    # You need one (and only one) QApplication instance per application.
    # Pass in sys.argv to allow command line arguments for your app.
    # If you know you won't use command line arguments QApplication([]) works too.
    app = QApplication(sys.argv)

    # Create a Qt widget, which will be our window.
    window = MainWindow(path, env)
    window.setVersion(env.__VERSION__)
    window.show()  # IMPORTANT!!!!! Windows are hidden by default.

    
    # Start the event loop.
    app.exec()
    return window