PyQt を使用して、ウィンドウが存在しない場合にウィンドウの背後にあるもののスクリーンショットを撮って、疑似透明ウィンドウを作成したいと考えています。次のコードはスクリーンショットを取得します。
#!/usr/bin/python3
from PyQt4.QtGui import *
app = QApplication([])
widget = QWidget()
widget.setLayout(QVBoxLayout())
label = QLabel()
widget.layout().addWidget(label)
def shoot():
geometry = widget.geometry()
widget.hide()
label.setPixmap(QPixmap.grabWindow(QApplication.desktop().winId(), x = geometry.x(), y = geometry.y(), height = geometry.height(), width = geometry.width())
widget.show()
widget.layout().addWidget(QPushButton('Screenshot', clicked = shoot))
widget.show()
app.exec_()
しかし、widget.hide() がありますが、ウィンドウ自体はスクリーンショットに表示されます。どうすればこれを回避できますか?