SHARE
TWEET

Python - PyQt - transparent background

furas Jun 27th, 2018 (edited) 67 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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_()
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top