Skip to content

Instantly share code, notes, and snippets.

@lambdalisue
Created February 20, 2014 08:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lambdalisue/9108918 to your computer and use it in GitHub Desktop.
Save lambdalisue/9108918 to your computer and use it in GitHub Desktop.
An example code to make clickable window on Qt
# coding=utf-8
"""
"""
__author__ = 'Alisue <lambdalisue@hashnote.net>'
try:
from PySide import QtCore
from PySide import QtGui
except ImportError:
from PyQt4 import QtCore
from PyQt4 import QtGui
class ClickableLabel(QtGui.QLabel):
clicked = QtCore.Signal()
def mousePressEvent(self, event):
self.clicked.emit()
class MainWindow(QtGui.QMainWindow):
def __init__(self):
super(MainWindow, self).__init__()
# make the window frameless
self.setWindowFlags(
QtCore.Qt.FramelessWindowHint |
QtCore.Qt.X11BypassWindowManagerHint)
# click to close
centralWidget = ClickableLabel(self)
centralWidget.clicked.connect(QtGui.qApp.quit)
self.setCentralWidget(centralWidget)
if __name__ == '__main__':
import sys
app = QtGui.QApplication(sys.argv)
main = MainWindow()
main.show()
sys.exit(app.exec_())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment