I'm trying to control setAttribute
using this example, located here. I want to make the background transparent except the button when I click the button. but it's not working. I'm noob, so I do not know what's wrong with this.
import sys
from PyQt5 import QtWidgets
from PyQt5.QtCore import Qt
class MainFrame(QtWidgets.QWidget):
def __init__(self, parent=None):
super(MainFrame, self).__init__(parent)
self.setWindowFlags(Qt.FramelessWindowHint)
self.setFixedSize(860, 560)
layout = QtWidgets.QHBoxLayout(self)
self.btn = QtWidgets.QPushButton("TEST")
layout.addWidget(self.btn)
self.btn.clicked.connect(self.Btn_clicked)
def Btn_clicked(self) :
self.setAttribute(Qt.WA_TranslucentBackground)
print("clicked")
if __name__ == '__main__':
app = QtWidgets.QApplication(sys.argv)
Frame = MainFrame(None)
Frame.show()
app.exec_()