License Custom License (see Source for Details)
Lines 22
Keywords
pyqt (1) transparent (1)
Permissions
Viewable by Everyone
Editable by All Siafoo Users

Transparent window for Windows 7 on Python with PyQt Atom Feed 0

# 's
 1from PyQt4.QtCore import *
2from PyQt4.QtGui import *
3import sys
4class Window(QWidget):
5 def __init__(self, *args):
6 QWidget.__init__(self, *args)
7 self.setLayout(QVBoxLayout())
8 self.layout().addWidget(QLabel("<font color='red'>This is the text</font"))
9 # let the whole window be a glass
10 self.setAttribute(Qt.WA_TranslucentBackground)
11 self.setWindowFlags(Qt.Tool | Qt.FramelessWindowHint)
12 self.setWindowFlags(self.windowFlags() | Qt.WindowStaysOnTopHint)
13 from ctypes import windll, c_int, byref
14 windll.dwmapi.DwmExtendFrameIntoClientArea(c_int(self.winId()), byref(c_int(-1)))
15 self.move(50, 50)
16 def mousePressEvent(self, event):
17 self.repaint()
18
19if __name__ == "__main__":
20 app = QApplication(sys.argv)
21 wnd = Window()
22 wnd.show()
23 sys.exit(app.exec_())