from
PyQt5.QtWidgets
import
*
from
PyQt5
import
QtCore, QtGui
from
PyQt5.QtGui
import
*
from
PyQt5.QtCore
import
*
import
sys
class
Window(QMainWindow):
def
__init__(
self
):
super
().__init__()
self
.setWindowTitle("Python ")
self
.setGeometry(
100
,
100
,
600
,
400
)
self
.UiComponents()
self
.show()
def
UiComponents(
self
):
label
=
QLabel("Label",
self
)
label.setGeometry(
200
,
100
,
150
,
60
)
label.setAlignment(Qt.AlignCenter)
label.setFont(QFont(
'Arial'
,
15
))
label.setStyleSheet("QLabel"
"{"
"border :
2px
solid green;"
"background : lightgreen;"
"}")
self
.opacity_effect
=
QGraphicsOpacityEffect()
self
.opacity_effect.setOpacity(
0.3
)
label.setGraphicsEffect(
self
.opacity_effect)
self
.button
=
QRadioButton("Disable opacity effect",
self
)
self
.button.setGeometry(
200
,
200
,
300
,
30
)
self
.button.clicked.connect(
self
.do_something)
def
do_something(
self
):
if
self
.button.isChecked()
=
=
True
:
self
.opacity_effect.setEnabled(
False
)
else
:
self
.opacity_effect.setEnabled(
True
)
App
=
QApplication(sys.argv)
window
=
Window()
sys.exit(App.
exec
())