Advertisement
furas

Python - PyQt - transparent background

Jun 27th, 2018
237
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.56 KB | None | 0 0
  1. from PyQt5 import QtWidgets, QtCore
  2.  
  3. app = QtWidgets.QApplication([]) # or sys.argv
  4.  
  5. win = QtWidgets.QWidget()
  6.  
  7. # transparent window but with frame/border
  8. win.setAttribute(QtCore.Qt.WA_TranslucentBackground)
  9.  
  10. # remove frame/border
  11. win.setWindowFlags(QtCore.Qt.FramelessWindowHint)
  12.  
  13. button = QtWidgets.QPushButton("HELLO", win)
  14. button.setGeometry(50, 50, 50, 50)
  15. button.clicked.connect(win.close)
  16.  
  17. # partially transparent button
  18. button.setStyleSheet("QWidget {background-color: rgba(50,50,50,128)}")
  19.  
  20. #win.setWindowOpacity(0.5)
  21.  
  22. win.show()
  23.  
  24. app.exec_()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement