from
PyQt5.QtCore
import
*
from
PyQt5.QtGui
import
*
from
PyQt5.QtWidgets
import
*
import
sys
class
Window(QMainWindow):
def
__init__(
self
):
super
().__init__()
self
.setWindowTitle("Python")
self
.setGeometry(
100
,
100
,
600
,
400
)
self
.button
=
QPushButton("Toggle",
self
)
self
.button.setGeometry(
200
,
150
,
100
,
40
)
self
.button.setCheckable(
True
)
self
.button.clicked.connect(
self
.changeColor)
self
.button.setStyleSheet("background
-
color : lightgrey")
self
.update()
self
.show()
def
changeColor(
self
):
if
self
.button.isChecked():
self
.button.setStyleSheet("background
-
color : lightblue")
else
:
self
.button.setStyleSheet("background
-
color : lightgrey")
App
=
QApplication(sys.argv)
window
=
Window()
sys.exit(App.
exec
())