Вы решили поехать в поход и Вам необходимо положить в рюкзак необходимые
вещи: фонарик и компас, палатку, аптечку, зажигалку, воду и еду, предметы личной
гигиены. Напишите программу для реализации выбора данных вещей. При нажатии
на виджет Checkbutton, его фон должен окраситься в светло-зелёный цвет и стать
недоступным.
Python!!!!!!!
Ответы на вопрос
from PyQt5 import QtWidgets, QtCore, QtGui, QtWidgets
from sys import exit
class Ui_Form(object):
def setupUi(self, Form):
Form.setObjectName("Form")
Form.resize(400, 300)
Form.setStyleSheet("QCheckBox:checked{\n"
" background: #9cee90;\n"
"}")
self.gridLayoutWidget = QtWidgets.QWidget(Form)
self.gridLayoutWidget.setGeometry(QtCore.QRect(10, 10, 371, 271))
self.gridLayoutWidget.setObjectName("gridLayoutWidget")
self.gridLayout = QtWidgets.QGridLayout(self.gridLayoutWidget)
self.gridLayout.setContentsMargins(0, 0, 0, 0)
self.gridLayout.setObjectName("gridLayout")
self.checkBox = QtWidgets.QCheckBox(self.gridLayoutWidget)
self.checkBox.setObjectName("checkBox")
self.gridLayout.addWidget(self.checkBox, 1, 0, 1, 1)
self.checkBox_3 = QtWidgets.QCheckBox(self.gridLayoutWidget)
self.checkBox_3.setObjectName("checkBox_3")
self.gridLayout.addWidget(self.checkBox_3, 2, 0, 1, 1)
self.checkBox_4 = QtWidgets.QCheckBox(self.gridLayoutWidget)
self.checkBox_4.setObjectName("checkBox_4")
self.gridLayout.addWidget(self.checkBox_4, 3, 0, 1, 1)
self.checkBox_2 = QtWidgets.QCheckBox(self.gridLayoutWidget)
self.checkBox_2.setObjectName("checkBox_2")
self.gridLayout.addWidget(self.checkBox_2, 0, 0, 1, 1)
self.checkBox_5 = QtWidgets.QCheckBox(self.gridLayoutWidget)
self.checkBox_5.setObjectName("checkBox_5")
self.gridLayout.addWidget(self.checkBox_5, 0, 1, 1, 1)
self.checkBox_6 = QtWidgets.QCheckBox(self.gridLayoutWidget)
self.checkBox_6.setObjectName("checkBox_6")
self.gridLayout.addWidget(self.checkBox_6, 1, 1, 1, 1)
self.checkBox_7 = QtWidgets.QCheckBox(self.gridLayoutWidget)
self.checkBox_7.setObjectName("checkBox_7")
self.gridLayout.addWidget(self.checkBox_7, 2, 1, 1, 1)
self.checkBox_8 = QtWidgets.QCheckBox(self.gridLayoutWidget)
self.checkBox_8.setObjectName("checkBox_8")
self.gridLayout.addWidget(self.checkBox_8, 3, 1, 1, 1)
self.retranslateUi(Form)
QtCore.QMetaObject.connectSlotsByName(Form)
def retranslateUi(self, Form):
_translate = QtCore.QCoreApplication.translate
Form.setWindowTitle(_translate("Form", "Form"))
self.checkBox.setText(_translate("Form", "компас"))
self.checkBox_3.setText(_translate("Form", "палатка"))
self.checkBox_4.setText(_translate("Form", "аптечка"))
self.checkBox_2.setText(_translate("Form", "фонарик"))
self.checkBox_5.setText(_translate("Form", "зажигалка"))
self.checkBox_6.setText(_translate("Form", "вода"))
self.checkBox_7.setText(_translate("Form", "еда"))
self.checkBox_8.setText(_translate("Form", "предметы личной гигиены"))
class mywindow(QtWidgets.QMainWindow):
def __init__(self):
super(mywindow, self).__init__()
self.ui = Ui_Form()
self.ui.setupUi(self)
app = QtWidgets.QApplication([])
application = mywindow()
application.show()
exit(app.exec())