原文链接http://www.cnblogs.com/alanalan/archive/2012/09/29/2708976.html
1 遮挡用户键盘鼠标输入
#coding=utf-8
import sys
from PyQt4 import QtGui
if __name__ == '__main__':
app = QtGui.QApplication(sys.argv)
trans = QtGui.QWidget()
# 就这句就搞定了。。设置成0的话就是全透明,
# 同时这个窗口也不会跟你交互了,要看不见又要交互,0.01吧。。
# 我反正是这么干的。。简单粗暴。。。。
trans.setWindowOpacity(0.5)
trans.show()
sys.exit(app.exec_())
2 隐藏窗体突出悬浮控件
#coding=utf-8
import sys
from PyQt4 import QtGui, QtCore
class Trans(QtGui.QWidget):
def __init__(self):
super(Trans, self).__init__()
self.initUI()
button = QtGui.QPushButton('Close', self)
self.connect(button, QtCore.SIGNAL('clicked()'), QtGui.qApp,
QtCore.SLOT('quit()'))
def initUI(self):
#self.setAttribute(QtCore.Qt.WA_NoSystemBackground, False)
self.setAttribute(QtCore.Qt.WA_TranslucentBackground, True)
self.setWindowFlags(QtCore.Qt.FramelessWindowHint)
if __name__ == '__main__':
app = QtGui.QApplication(sys.argv)
trans = Trans()
trans.show()
sys.exit(app.exec_())