class i3Void(QtGui.QMainWindow): """Create the QT window application. """ def __init__(self): """Set the parameters for the QT window. """ super(i3Void, self).__init__() self.setWindowTitle('i3Void') self.buttonWidget = ButtonWidget(self) self.setCentralWidget(self.buttonWidget) self.show() self.setWindowColor("#2e2e2e") self.installEventFilter(self) # Setup Ctrl+q to exit QtGui.QShortcut(QtGui.QKeySequence("Ctrl+Q"), self, self.close) def eventFilter(self, source, event): """Hide and show the buttons when the window is focused. """ if event.type() == QtCore.QEvent.WindowActivate: self.buttonWidget.show(); elif event.type()== QtCore.QEvent.WindowDeactivate: self.buttonWidget.hide(); return QtGui.QWidget.eventFilter(self, source,event) def setWindowColor(self, new_color): """Change the color of the window. """ self.setStyleSheet('QMainWindow{background-color: '+new_color+';}') def closeWindow(self): """Close the window. """ self.close() def closeEvent(self, event): """Accept a close event. """ event.accept()
def __init__(self): """Set the parameters for the QT window. """ super(i3Void, self).__init__() self.setWindowTitle('i3Void') self.buttonWidget = ButtonWidget(self) self.setCentralWidget(self.buttonWidget) self.show() self.setWindowColor("#2e2e2e") self.installEventFilter(self) # Setup Ctrl+q to exit QtGui.QShortcut(QtGui.QKeySequence("Ctrl+Q"), self, self.close)