class CalendarApp(QMainWindow): '''This class contains the CalendarApp class(main window), it inherits the QMainWindow class in Pyside2''' def __init__(self): ''' This function calls parents class, initialize infoWindow, load main window UI, and call the clickOnDate function in eventHandler to get today's event list upon opening the GUI Args: none Returns: none ''' self.eventHandler = EventHandler(self) super(CalendarApp, self).__init__() self.infoDialog = InfoWindow() self.load_ui() self.eventHandler.clickOnDate() def showInfoDialog(self): '''Shows the pop-up infoWindow when the called (upon bookPushbutton is clicked) Args: none Returns: none ''' self.setEnabled( False) #set main window to disable when showing the popup window self.infoDialog.show() # show popup info window #Bindind the UI components to listener(eventhandler) def BindEventsHandler(self): '''Binds the UI components to its listener - functions in EventHandler class Args: none Returns: none ''' btn = self.window.findChild(QPushButton, 'bookPushButton') btn.clicked.connect(self.eventHandler.bookPushButton_cliked) self.calWidget = self.window.findChild(QCalendarWidget, 'calendarWidget') self.calWidget.selectionChanged.connect(self.eventHandler.clickOnDate) self.QListWidget = self.window.findChild(QListWidget, 'listWidget') btn = self.infoDialog.findChild(QPushButton, 'sendButton') btn.clicked.connect(self.eventHandler.sendPushButton_clicked) btn = self.infoDialog.findChild(QPushButton, 'cancelButton') btn.clicked.connect(self.eventHandler.cancelPushButton_clicked) def load_ui(self): '''Load the mainWindow.ui file and show it on screen. Args: none Returns: none ''' loader = QUiLoader() path = os.path.join(os.path.dirname(__file__), "mainWindow.ui") ui_file = QFile(path) ui_file.open(QFile.ReadOnly) self.window = loader.load(ui_file, self) ui_file.close() self.BindEventsHandler() self.window.show()