import os from PyQt5 import QtWidgets, uic class MainWindow(QtWidgets.QMainWindow): """ A wrapper class for handling creating a window based on a Qt Designer *.ui file. """ # This file will always live in the root so we can yank # the root directory from it's location safely. __ROOT_DIR = os.path.dirname(os.path.abspath(__file__)) __UI_FILE_NAME = "clusterview.ui" def __init__(self): """ Initializes and launches the UI in one shot. """ # Assumption: The UI file will be in the project root. super(MainWindow, self).__init__() uic.loadUi("{}/{}".format(self.__ROOT_DIR,self. __UI_FILE_NAME)) self.show()