def initUI(self): # displays "status" in bar at bottom of window self.statusBar().showMessage("Welcome") # creates an action to close window exitAct = QAction(QIcon(IMAGES + "exit.png"), "&Exit", self) exitAct.setShortcut("Ctrl+Q") exitAct.setStatusTip("Exit Application") exitAct.triggered.connect(qApp.quit) # creates a menu bar with an option to close the window menubar = self.menuBar() # Mac OS deals with menus differently, so disable native handling if sys.platform == "darwin": menubar.setNativeMenuBar(False) fileMenu = menubar.addMenu("&File") fileMenu.addAction(exitAct) # create a toolbar on the right of the screen self.toolbar = QToolBar("System setup") self.addToolBar(Qt.RightToolBarArea, self.toolbar) # get the size of a section on the toolbar section = int(self.toolbar.height() / 7) # add a button to the toolbar to create a mirror btn = QPushButton("", self) btn.setIcon(QIcon(IMAGES + "mirror.png")) btn.setIconSize(QSize(section, section)) btn.clicked.connect(self.add_mirror) btn.setStatusTip("Add a mirror to the system") self.toolbar.addWidget(btn) # add a button to the toolbar to create a solid btn = QPushButton("", self) btn.setIcon(QIcon(IMAGES + "solid.png")) btn.setIconSize(QSize(section, section)) btn.clicked.connect(self.add_solid) btn.setStatusTip("Add a wedge to the system") self.toolbar.addWidget(btn) # get the bounds of the available screen space cp = QDesktopWidget().availableGeometry() # set frame to 70% of available window, centered self.setGeometry(int(cp.topLeft().x() + cp.width() * .15), int(cp.topLeft().y() + cp.height() * .15), int(cp.width() * .7), int(cp.height() * .7)) self.setWindowTitle("Ghost Hunters") self.setWindowIcon(QIcon(IMAGES + "logo.png"))
def initUI(self): QToolTip.setFont(QFont("SansSerif", 10)) self.setToolTip("This is a <b>GHOST HUNTERS</b>") # create a button that calls doSomething when it's clicked btn = QPushButton("Button", self) btn.clicked.connect(doSomething) btn.setToolTip("This is a button?") btn.resize(btn.sizeHint()) btn.move(50, 50) # get the bounds of the available screen space cp = QDesktopWidget().availableGeometry() # set frame to 70% of available window, centered self.setGeometry(cp.topLeft().x() + cp.width() * .15, cp.topLeft().y() + cp.height() * .15, cp.width() * .7, cp.height() * .7) self.setWindowTitle("Ghost Hunters") self.setWindowIcon(QIcon("logo.png"))