def __init__(self): super(control, self).__init__() self.ui = Ui_control() self.ui.setupUi(self) self.ui.home.clicked.connect(self.home) self.ui.hour.setMinimum(0) self.ui.hour.setMaximum(23) self.ui.min.setMinimum(0) self.ui.min.setMaximum(59) self.ui.hour_2.setMinimum(0) self.ui.hour_2.setMaximum(23) self.ui.min_2.setMinimum(0) self.ui.min_2.setMaximum(59) self.ui.min.valueChanged.connect(self.min) self.ui.hour.valueChanged.connect(self.hour) self.ui.min_2.valueChanged.connect(self.min_2) self.ui.hour_2.valueChanged.connect(self.hour_2) self.ui.hour.setToolTip( "Заданные настройки заработают при следующем включении!") self.ui.min.setToolTip( "Заданные настройки заработают при следующем включении!") self.ui.hour_2.setToolTip( "Заданные настройки заработают при следующем включении!") self.ui.min_2.setToolTip( "Заданные настройки заработают при следующем включении!") with open("text_control.txt", "r", encoding="utf-8") as file: self.ui.textEdit.setText(file.read()) self.resTime() self.hours = Resurse("hour").read() self.hours_2 = Resurse("hour_2").read() self.minutes = Resurse("min").read() self.minutes_2 = Resurse("min_2").read()
def resurse_init(self): bal = Resurse("баллы") bal.write(self.bal) maxnum = Resurse("слайдер") maxnum.write(self.maxnum) zn = Resurse("умножение") zn.write(self.zn)
def __init__(self): """ Родители класса - QMainWindow. self.ui.svaip.clicked.connect(self.primer)--------------------|Кнопка пропуска привязаннна к методу primer() self.ui.ask.clicked.connect(self.proverka)--------------------|Кнопка ОТВЕТИТЬ! привязаннна к методу proverka() self.ui.horizontalSlider.setValue(self.maxnum)----------------|Начальное положение Slider = muxnum(по умол. 10) self.ui.horizontalSlider.valueChanged[int].connect(self.val)--|Значения слайдера привязанны к методу val() self.ui.otvet.returnPressed.connect(self.proverka)------------|Кнопка на клавиатуре Enter привязанна к методу proverka() self.ui.checkBox.stateChanged.connect(self.cb)----------------|Значения с CheckBox привязанны к методу cb() self.ui.otvet.setFocus()--------------------------------------|По умолчанию каретка стотит на поле ответа """ super(mywindow, self).__init__() self.bal = int(Resurse("баллы").read()) self.maxnum = int(Resurse("слайдер").read()) if int( Resurse("слайдер").read()) > 1 else 2 self.zn = int(Resurse("умножение").read()) self.ui = Ui_calc() self.ui.setupUi(self) self.ui.home.clicked.connect(self.home) self.ui.svaip.clicked.connect(self.svaip) self.ui.pushButton.clicked.connect(self.option) self.ui.lol.clicked.connect(self.lol) self.ui.ask.clicked.connect(self.proverka) self.ui.otvet.returnPressed.connect(self.proverka) self.ui.otvet.setFocus() self.lolch = False self.save = 0 self.hert() self.primer() # первый запуск primer()
def home(self): Resurse("min").write(self.minutes) Resurse("hour").write(self.hours) Resurse("min_2").write(self.minutes_2) Resurse("hour_2").write(self.hours_2) with open("text_control.txt", "w", encoding="utf-8") as file: file.write(self.ui.textEdit.toPlainText()) sub.Popen(["python.exe", "logic_options.py"]) sys.exit()
def reb(self): self.ui.otvet.clear() num = Resurse("ребус").read() if num == "23": num = "0" self.num = str(num) path = "Ресурс_ребусы/" + num + ".jpg" self.ui.reb.setPixmap(QtGui.QPixmap(path)) num = int(num) + 1 Resurse("ребус").write(num)
def reb(self): self.num = Resurse("mystery").read() self.num = int(self.num) + 1 self.ui.otvet.clear() if int(self.num) > 27: self.num = "0" Resurse("mystery").write(self.num) with open("resurse_mystery.txt", "r", encoding="utf-8") as file: text = file.readlines()[int(self.num)] self.ui.reb.setText(text) with open("keys_mystery.txt", "r", encoding="utf-8") as file: self.rez = file.readlines()[int(self.num)] self.rez = self.rez[:-1]
def svaip(self): if self.save < 30 and self.save != -5: self.save = self.save + 1 self.primer() else: if Resurse("пасхалка").read() == "0": Resurse("пасхалка").write(1) self.save_fun() else: print("none") self.save = 0 self.primer() print(self.save)
def go(self): text = self.ui.porol.text() if len(text)==0: self.ui.error.setText("Это поле не должно быть пустым!") self.ui.error.setVisible(True) self.error() else: self.ui.error.setVisible(False) Resurse("password", "password").write(text) Resurse("password").write(1) sub.Popen(["python.exe", "logic_control.py"]) sys.exit()
def proverka(self): text = self.ui.otvet.text().lower() if str(self.rez) == text: if self.lolch: Resurse("баллы").write( str(int(self.bal) + int(Resurse("bal-task").read()))) else: self.lolch = True self.rezult_color(0) QTimer.singleShot(1000, lambda: self.rezult_color(2)) self.heart() self.task() else: self.rezult_color(1) QTimer.singleShot(1000, lambda: self.rezult_color(2)) self.ui.otvet.clear()
def proverka(self): self.rez = Resurse(self.num, "keys_rebus").read() text = self.ui.otvet.text().lower() if self.rez == text: if self.lolch: Resurse("баллы").write(str(int(self.bal) + 1)) else: self.lolch = True self.rezult_color(0) QTimer.singleShot(1000, lambda: self.rezult_color(2)) self.heart() self.reb() else: self.rezult_color(1) QTimer.singleShot(1000, lambda: self.rezult_color(2)) self.ui.otvet.clear()
def setupUi(self, check): check.setObjectName("check") check.resize(402, 228) with open(Resurse("theme").read(), "r") as file: text = file.read() check.setStyleSheet(text) self.verticalLayoutWidget = QtWidgets.QWidget(check) self.verticalLayoutWidget.setGeometry(QtCore.QRect(10, 20, 381, 201)) self.verticalLayoutWidget.setObjectName("verticalLayoutWidget") self.verticalLayout = QtWidgets.QVBoxLayout(self.verticalLayoutWidget) self.verticalLayout.setContentsMargins(0, 0, 0, 0) self.verticalLayout.setObjectName("verticalLayout") self.label = QtWidgets.QLabel(self.verticalLayoutWidget) self.label.setAlignment(QtCore.Qt.AlignCenter) self.label.setWordWrap(True) self.label.setObjectName("label") self.verticalLayout.addWidget(self.label) self.horizontalLayout = QtWidgets.QHBoxLayout() self.horizontalLayout.setObjectName("horizontalLayout") self.yes = QtWidgets.QPushButton(self.verticalLayoutWidget) self.yes.setObjectName("yes") self.horizontalLayout.addWidget(self.yes) self.no = QtWidgets.QPushButton(self.verticalLayoutWidget) self.no.setObjectName("no") self.horizontalLayout.addWidget(self.no) self.verticalLayout.addLayout(self.horizontalLayout) self.retranslateUi(check) QtCore.QMetaObject.connectSlotsByName(check)
def setupUi(self, control_pass_give): control_pass_give.setObjectName("control_pass_give") control_pass_give.resize(531, 240) with open(Resurse("theme").read(), "r") as file: text = file.read() control_pass_give.setStyleSheet(text) self.porol = QtWidgets.QLineEdit(control_pass_give) self.porol.setGeometry(QtCore.QRect(280, 110, 241, 41)) self.porol.setObjectName("porol") self.label = QtWidgets.QLabel(control_pass_give) self.label.setGeometry(QtCore.QRect(10, 110, 241, 41)) self.label.setObjectName("label") self.error = QtWidgets.QLabel(control_pass_give) self.error.setGeometry(QtCore.QRect(280, 40, 241, 61)) self.error.setStyleSheet( "background-color: none;\ncolor: red;\nborder: none;") self.error.setScaledContents(False) self.error.setAlignment(QtCore.Qt.AlignCenter) self.error.setWordWrap(True) self.error.setObjectName("error") self.home = QtWidgets.QPushButton(control_pass_give) self.home.setGeometry(QtCore.QRect(10, 200, 91, 31)) self.home.setObjectName("home") self.go = QtWidgets.QPushButton(control_pass_give) self.go.setGeometry(QtCore.QRect(280, 200, 231, 31)) self.go.setObjectName("go") self.retranslateUi(control_pass_give) QtCore.QMetaObject.connectSlotsByName(control_pass_give) self.error.setVisible(False)
def setupUi(self, options): options.setObjectName("options") options.resize(793, 389) with open(Resurse("theme").read(), "r") as file: text = file.read() options.setStyleSheet(text) self.checkBox = QtWidgets.QCheckBox(options) self.checkBox.setGeometry(QtCore.QRect(430, 160, 341, 31)) self.checkBox.setLayoutDirection(QtCore.Qt.LeftToRight) self.checkBox.setCheckable(True) self.checkBox.setChecked(False) self.checkBox.setObjectName("checkBox") self.label = QtWidgets.QLabel(options) self.label.setGeometry(QtCore.QRect(30, 230, 400, 31)) self.label.setStyleSheet("") self.label.setObjectName("label") if Resurse("theme").read() == "css_dark.txt": self.label.setStyleSheet("background-color: none;\nborder: none;") self.horizontalSlider = QtWidgets.QSlider(options) self.horizontalSlider.setGeometry(QtCore.QRect(430, 230, 341, 31)) self.horizontalSlider.setMinimum(2) self.horizontalSlider.setMaximum(100) self.horizontalSlider.setOrientation(QtCore.Qt.Horizontal) self.horizontalSlider.setObjectName("horizontalSlider") self.svaip = QtWidgets.QPushButton(options) self.svaip.setGeometry(QtCore.QRect(30, 300, 341, 31)) self.svaip.setObjectName("svaip") self.home = QtWidgets.QPushButton(options) self.home.setGeometry(QtCore.QRect(690, 350, 91, 31)) self.home.setObjectName("home") self.svaip_2 = QtWidgets.QPushButton(options) self.svaip_2.setGeometry(QtCore.QRect(30, 160, 341, 31)) self.svaip_2.setObjectName("svaip_2") self.control = QtWidgets.QPushButton(options) self.control.setGeometry(QtCore.QRect(430, 300, 341, 31)) self.control.setObjectName("control") self.comboBox = QtWidgets.QComboBox(options) self.comboBox.setGeometry(QtCore.QRect(30, 90, 341, 31)) self.comboBox.setObjectName("comboBox") self.comboBox.addItems([ "Синяя тема", "Темная тема", "Розовая тема", "Коричневая тема", "Стильная тема" ]) self.retranslateUi(options) QtCore.QMetaObject.connectSlotsByName(options)
def control(self): password = int(Resurse("password").read()) if password: sub.Popen(["python.exe", "logic_control_pass_give.py"]) sys.exit() else: sub.Popen(["python.exe", "logic_control_pass_take.py"]) sys.exit()
def go(self): text = self.ui.porol.text() porol = Resurse("password", "password").read() if text != porol: self.ui.error.setText("Неверный пароль!") self.ui.porol.clear() self.ui.porol.setFocus() self.ui.error.setVisible(True) if Resurse("theme").read() == "css_style.txt": self.ui.porol.setStyleSheet( "border-right: 5px ridge darkred;\nborder-bottom: 5px ridge darkred;\n" ) else: self.ui.porol.setStyleSheet("border: 3px solid red") else: self.ui.error.setVisible(False) sub.Popen(["python.exe", "logic_control.py"]) sys.exit()
def setupUi(self, end): end.setObjectName("end") end.resize(402, 228) with open(Resurse("theme").read(), "r") as file: text = file.read() end.setStyleSheet(text) self.textBrowser = QtWidgets.QTextBrowser(end) self.textBrowser.setGeometry(QtCore.QRect(10, 10, 381, 201)) self.textBrowser.setObjectName("textBrowser") with open("text_control.txt", "r", encoding="utf-8") as file: self.textBrowser.setText(file.read()) self.retranslateUi(end) QtCore.QMetaObject.connectSlotsByName(end) QTimer.singleShot(5000, lambda: sys.exit())
def rezult_color(self, rezult): css_colors = ["Ресурс/logo_fin_green.png", "Ресурс/logo_fin_red.png"] if rezult == 0: self.ui.icon.setPixmap(QtGui.QPixmap(css_colors[0])) self.ui.label_3.setVisible(0) self.ui.true_l.setVisible(1) if rezult == 1: self.ui.icon.setPixmap(QtGui.QPixmap(css_colors[1])) self.ui.true_l.setVisible(0) self.ui.label_3.setVisible(1) if rezult == 2: self.ui.icon.setPixmap(QtGui.QPixmap(Resurse("logo").read())) self.ui.true_l.setVisible(0) self.ui.label_3.setVisible(0)
def __init__(self): super(mywindow, self).__init__() self.ui = Ui_options() self.ui.setupUi(self) self.bal = int(Resurse("баллы").read()) self.maxnum = int(Resurse("слайдер").read()) if int( Resurse("слайдер").read()) > 1 else 2 self.zn = int(Resurse("умножение").read()) self.ui.horizontalSlider.setValue(self.maxnum) self.ui.label.setText( f" Выбери до скольки ты умеешь считать: {self.maxnum}") self.ui.home.clicked.connect(self.home) self.ui.horizontalSlider.valueChanged[int].connect(self.val) self.ui.svaip.clicked.connect(self.svaip) self.ui.checkBox.stateChanged.connect(self.cb) self.ui.checkBox.setChecked(self.zn) self.ui.control.clicked.connect(self.control) self.ui.comboBox.activated.connect(self.theme) if Resurse("theme").read() == "css.txt": self.ui.comboBox.setCurrentIndex(0) if Resurse("theme").read() == "css_dark.txt": self.ui.comboBox.setCurrentIndex(1) if Resurse("theme").read() == "css_pink.txt": self.ui.comboBox.setCurrentIndex(2) if Resurse("theme").read() == "css_brow.txt": self.ui.comboBox.setCurrentIndex(3) if Resurse("theme").read() == "css_style.txt": self.ui.comboBox.setCurrentIndex(4) # if Resurse("обнулить").read() == "1": # self.obnul() self.ui.svaip_2.setToolTip( "Нажимая на эту кнопку, ты можешь посмотреть все свои <b>достижения!</b>" ) self.ui.checkBox.setToolTip( "Поставь здесь галочку, если ты умеешь <b>делить и умножать!</b>") self.ui.svaip.setToolTip( "Нажимая на эту кнопку, ты обнуляешь все свои <b>достижения и баллы!</b>" ) self.ui.control.setToolTip("Настройка <b>родительского контроля!</b>") self.ui.comboBox.setToolTip("<b>Выбери тему<b>, которая нравится!")
def __init__(self): super(tasks, self).__init__() self.ui = Ui_tasks() self.ui.setupUi(self) self.ui.pushButton.clicked.connect(self.option) self.ui.home.clicked.connect(self.home) self.ui.svaip.clicked.connect(self.task) self.ui.lol.clicked.connect(self.lol) self.ui.ask.clicked.connect(self.proverka) self.ui.task.setWordWrap(True) self.ui.otvet.setFocus() self.ui.otvet.returnPressed.connect(self.proverka) self.lolch = True self.s = 0 self.last = "Вася" self.last_ob = "Журнала" self.maxnum = int(Resurse("слайдер").read()) self.heart() self.task()
def setupUi(self, control): control.setObjectName("control") control.resize(671, 248) with open(Resurse("theme").read(), "r") as file: text = file.read() control.setStyleSheet(text) self.label = QtWidgets.QLabel(control) self.label.setGeometry(QtCore.QRect(0, 20, 671, 61)) self.label.setStyleSheet("background-color: none;\n" "font: 75 22pt \"Calibri\";\nborder: none;") self.label.setAlignment(QtCore.Qt.AlignCenter) self.label.setObjectName("label") self.label_2 = QtWidgets.QLabel(control) self.label_2.setGeometry(QtCore.QRect(340, 110, 311, 71)) self.label_2.setWordWrap(True) self.label_2.setObjectName("label_2") self.home = QtWidgets.QPushButton(control) self.home.setGeometry(QtCore.QRect(560, 210, 101, 31)) self.home.setObjectName("home") self.hour = QtWidgets.QSpinBox(control) self.hour.setGeometry(QtCore.QRect(20, 150, 101, 31)) self.hour.setObjectName("hour") self.min = QtWidgets.QSpinBox(control) self.min.setGeometry(QtCore.QRect(170, 150, 101, 31)) self.min.setObjectName("min") self.label_3 = QtWidgets.QLabel(control) self.label_3.setGeometry(QtCore.QRect(20, 110, 101, 31)) self.label_3.setAlignment(QtCore.Qt.AlignCenter) self.label_3.setObjectName("label_3") self.label_4 = QtWidgets.QLabel(control) self.label_4.setGeometry(QtCore.QRect(170, 110, 101, 31)) self.label_4.setAlignment(QtCore.Qt.AlignCenter) self.label_4.setObjectName("label_4") self.retranslateUi(control) QtCore.QMetaObject.connectSlotsByName(control)
def resurse_init(self): bal = Resurse("баллы") bal.write(self.bal)
def setupUi(self, rebus): rebus.setObjectName("rebus") rebus.resize(666, 394) with open(Resurse("theme").read(), "r") as file: text = file.read() rebus.setStyleSheet(text) self.bals = QtWidgets.QLabel(rebus) self.bals.setGeometry(QtCore.QRect(530, 50, 121, 31)) self.bals.setStyleSheet("font: 75 14pt \"Verdana\";\n" "background-color: none;\nborder: none;") self.bals.setAlignment(QtCore.Qt.AlignLeading | QtCore.Qt.AlignLeft | QtCore.Qt.AlignVCenter) self.bals.setObjectName("bals") self.heart = QtWidgets.QLabel(rebus) self.heart.setGeometry(QtCore.QRect(490, 50, 31, 31)) self.heart.setStyleSheet("background-color: none;\nborder: none;") self.heart.setText("") self.heart.setPixmap(QtGui.QPixmap(Resurse("heart").read())) self.heart.setScaledContents(True) self.heart.setObjectName("heart") self.icon_2 = QtWidgets.QLabel(rebus) self.icon_2.setGeometry(QtCore.QRect(10, 10, 61, 61)) self.icon_2.setStyleSheet("background-color: none;\nborder: none;") self.icon_2.setText("") self.icon_2.setPixmap(QtGui.QPixmap(Resurse("option").read())) self.icon_2.setScaledContents(True) self.icon_2.setWordWrap(False) self.icon_2.setOpenExternalLinks(False) self.icon_2.setObjectName("icon_2") self.pushButton = QtWidgets.QPushButton(rebus) self.pushButton.setGeometry(QtCore.QRect(10, 10, 61, 61)) self.pushButton.setStyleSheet("background-color: none;\nborder: none") self.pushButton.setText("") self.pushButton.setObjectName("pushButton") self.home = QtWidgets.QPushButton(rebus) self.home.setGeometry(QtCore.QRect(560, 350, 91, 31)) self.home.setObjectName("home") self.reb = QtWidgets.QLabel(rebus) self.reb.setGeometry(QtCore.QRect(150, 40, 331, 161)) self.reb.setStyleSheet("background-color: none;\nborder: none;") self.reb.setText("") self.reb.setPixmap(QtGui.QPixmap("Ресурс_ребусы/0.jpg")) self.reb.setScaledContents(True) self.reb.setWordWrap(False) self.reb.setObjectName("reb") self.otvet = QtWidgets.QLineEdit(rebus) self.otvet.setGeometry(QtCore.QRect(150, 260, 331, 51)) self.otvet.setStyleSheet("") self.otvet.setAlignment(QtCore.Qt.AlignCenter) self.otvet.setObjectName("otvet") self.ask = QtWidgets.QPushButton(rebus) self.ask.setGeometry(QtCore.QRect(150, 320, 331, 31)) self.ask.setStyleSheet("") self.ask.setObjectName("ask") self.lol = QtWidgets.QPushButton(rebus) self.lol.setGeometry(QtCore.QRect(490, 260, 141, 51)) self.lol.setObjectName("lol") self.label = QtWidgets.QLabel(rebus) self.label.setGeometry(QtCore.QRect(200, 210, 231, 41)) self.label.setAlignment(QtCore.Qt.AlignCenter) self.label.setObjectName("label") self.svaip = QtWidgets.QPushButton(rebus) self.svaip.setGeometry(QtCore.QRect(490, 210, 141, 41)) self.svaip.setObjectName("svaip") self.green = QtWidgets.QLabel(rebus) self.green.setGeometry(QtCore.QRect(150, 210, 41, 41)) self.green.setText("") self.green.setPixmap(QtGui.QPixmap("Ресурс/green_reb.png")) self.green.setObjectName("green") self.red1 = QtWidgets.QLabel(rebus) self.red1.setGeometry(QtCore.QRect(150, 210, 41, 41)) self.red1.setText("") self.red1.setPixmap(QtGui.QPixmap("Ресурс/red_reb.jpg")) self.red1.setObjectName("red1") self.red = QtWidgets.QLabel(rebus) self.red.setGeometry(QtCore.QRect(440, 210, 41, 41)) self.red.setText("") self.red.setPixmap(QtGui.QPixmap("Ресурс/red_reb.jpg")) self.red.setObjectName("red") self.green1 = QtWidgets.QLabel(rebus) self.green1.setGeometry(QtCore.QRect(440, 210, 41, 41)) self.green1.setText("") self.green1.setPixmap(QtGui.QPixmap("Ресурс/green_reb.png")) self.green1.setObjectName("green1") self.green.setVisible(False) self.red.setVisible(False) self.green1.setVisible(False) self.red1.setVisible(False) self.retranslateUi(rebus) QtCore.QMetaObject.connectSlotsByName(rebus)
def yes(self): Resurse("баллы").write(0) sub.Popen(["python.exe", "logic_options.py"]) sys.exit()
def theme(self, text): if text == 1: Resurse("theme").write("css_dark.txt") Resurse("logo").write("Ресурс/logo_fin_black.png") Resurse("heart").write("Ресурс/heart_black.png") Resurse("option").write("Ресурс/opt_ic_black.png") sub.Popen(["python.exe", "logic_options.py"]) sys.exit() if text == 2: Resurse("theme").write("css_pink.txt") Resurse("logo").write("Ресурс/logo_pink.png") Resurse("heart").write("Ресурс/heart_pink") Resurse("option").write("Ресурс/opt_pink.png") sub.Popen(["python.exe", "logic_options.py"]) sys.exit() if text == 4: Resurse("theme").write("css_style.txt") Resurse("logo").write("Ресурс/logo_fin.png") Resurse("heart").write("Ресурс/heart_style.png") Resurse("option").write("Ресурс/opt_ic.png") sub.Popen(["python.exe", "logic_options.py"]) sys.exit() if text == 3: Resurse("theme").write("css_brow.txt") Resurse("logo").write("Ресурс/logo_fin_brow.png") Resurse("heart").write("Ресурс/heart_brow.png") Resurse("option").write("Ресурс/opt_ic_brow.png") sub.Popen(["python.exe", "logic_options.py"]) sys.exit() if text == 0: Resurse("theme").write("css.txt") Resurse("logo").write("Ресурс/logo_fin.png") Resurse("heart").write( "Ресурс/Serdtse-s-chernoj-okantovkoj-narisovannoe.png") Resurse("option").write("Ресурс/opt_ic.png") sub.Popen(["python.exe", "logic_options.py"]) sys.exit()
def resTime(self): self.ui.min.setValue(int(Resurse("min").read())) self.ui.hour.setValue(int(Resurse("hour").read())) self.ui.min_2.setValue(int(Resurse("min_2").read())) self.ui.hour_2.setValue(int(Resurse("hour_2").read()))
def setupUi(self, calc): calc.setObjectName("calc") calc.resize(666, 394) with open(Resurse("theme").read(), "r") as file: text = file.read() calc.setStyleSheet(text) self.heart = QtWidgets.QLabel(calc) self.heart.setGeometry(QtCore.QRect(490, 50, 31, 31)) self.heart.setStyleSheet("background-color: none;\nborder: none;") self.heart.setText("") self.heart.setPixmap(QtGui.QPixmap(Resurse("heart").read())) self.heart.setScaledContents(True) self.heart.setObjectName("heart") self.bals = QtWidgets.QLabel(calc) self.bals.setGeometry(QtCore.QRect(530, 50, 121, 31)) self.bals.setStyleSheet("font: 75 14pt \"Verdana\";\n" "background-color: none;\nborder: none;") self.bals.setAlignment(QtCore.Qt.AlignLeading | QtCore.Qt.AlignLeft | QtCore.Qt.AlignVCenter) self.bals.setObjectName("bals") self.quest = QtWidgets.QLabel(calc) self.quest.setGeometry(QtCore.QRect(20, 210, 341, 71)) self.quest.setStyleSheet("") self.quest.setText("") self.quest.setObjectName("quest") self.ask = QtWidgets.QPushButton(calc) self.ask.setGeometry(QtCore.QRect(530, 210, 121, 71)) self.ask.setStyleSheet("") self.ask.setObjectName("ask") self.svaip = QtWidgets.QPushButton(calc) self.svaip.setGeometry(QtCore.QRect(530, 290, 121, 31)) self.svaip.setObjectName("svaip") self.icon = QtWidgets.QLabel(calc) self.icon.setGeometry(QtCore.QRect(270, 20, 131, 111)) self.icon.setStyleSheet("background-color: none;\nborder: none;") self.icon.setText("") self.icon.setPixmap(QtGui.QPixmap(Resurse("logo").read())) self.icon.setScaledContents(True) self.icon.setWordWrap(False) self.icon.setOpenExternalLinks(False) self.icon.setObjectName("icon") self.otvet = QtWidgets.QLineEdit(calc) self.otvet.setGeometry(QtCore.QRect(370, 210, 151, 71)) self.otvet.setStyleSheet("") self.otvet.setObjectName("otvet") self.home = QtWidgets.QPushButton(calc) self.home.setGeometry(QtCore.QRect(560, 350, 91, 31)) self.home.setObjectName("home") self.true_l = QtWidgets.QLabel(calc) self.true_l.setGeometry(QtCore.QRect(375, 170, 121, 31)) self.true_l.setStyleSheet( "background-color: none;\ncolor: green;\nborder: none;") self.true_l.setAlignment(QtCore.Qt.AlignCenter) self.true_l.setObjectName("true_l") self.true_l.setVisible(0) self.label_3 = QtWidgets.QLabel(calc) self.label_3.setGeometry(QtCore.QRect(375, 170, 141, 31)) self.label_3.setStyleSheet( "background-color: none;\ncolor: red;\nborder: none;") self.label_3.setAlignment(QtCore.Qt.AlignCenter) self.label_3.setObjectName("label_3") self.label_3.setVisible(0) self.icon_2 = QtWidgets.QLabel(calc) self.icon_2.setGeometry(QtCore.QRect(10, 10, 61, 61)) self.icon_2.setStyleSheet("background-color: none;\nborder: none;") self.icon_2.setText("") self.icon_2.setPixmap(QtGui.QPixmap(Resurse("option").read())) self.icon_2.setScaledContents(True) self.icon_2.setWordWrap(False) self.icon_2.setOpenExternalLinks(False) self.icon_2.setObjectName("icon_2") self.pushButton = QtWidgets.QPushButton(calc) self.pushButton.setGeometry(QtCore.QRect(10, 10, 61, 61)) self.pushButton.setStyleSheet("background-color: none;\nborder: none") self.pushButton.setText("") self.pushButton.setObjectName("pushButton") self.lol = QtWidgets.QPushButton(calc) self.lol.setGeometry(QtCore.QRect(370, 290, 151, 31)) self.lol.setObjectName("lol") self.retranslateUi(calc) QtCore.QMetaObject.connectSlotsByName(calc)
def home(self): home = Resurse("настройки") path = home.read() sub.Popen(["python.exe", path + ".py"]) sys.exit()
def option(self): opt = Resurse("настройки") opt.write("logic_calc") sub.Popen(["python.exe", "logic_options.py"]) sys.exit()
def task(self): self.col1 = "0" self.col2 = "0" self.col3 = "0" self.ui.task.clear() level = int(Resurse("leveltask").read()) def item(*index): index = rand.choice(index) if index == "food": self.ob1 = [ "конфеты", "банана", "мороженых", "леденца", "яблока", "йогурта", "эклера", "пироженых", "печенки", "конфетки", "жвачки" ] self.ob2 = [ "конфет", "бананов", "мороженых", "леденцов", "яблок", "йогуртов", "эклеров", "пироженых", "печенек", "конфеток", "жвачек" ] self.ob3 = [ "конфета", "банан", "мороженое", "леденец", "яблоко", "йогурт", "эклер", "пироженое", "печенье", "конфетка", "жвачка" ] if index == "furn": pass if index == "small": self.ob1 = [ "монеты", "карточки", "карандаша", "ручки", "ластика", "листочка", "гайки", "болтика", "пуговицы", "журнала", "газеты", "книги" ] self.ob2 = [ "монет", "карточек", "карандашей", "ручек", "ластиков", "листочков", "гаек", "болтиков", "пуговиц", "журналов", "газет", "книг" ] self.ob3 = [ "монета", "карточка", "карандаш", "ручка", "ластик", "листочек", "гайка", "болтик", "пуговица", "журнал", "газета", "книга" ] while True: g = rand.randint(0, len(self.ob1) - 1) if self.ob1[g] != self.last_ob: self.last_ob = g self.poz = g break def chelik(): mans = [ "Вася", "Роман", "Олег", "Виктор", "Дядя Петя", "Фёдор Семёнович", "Игнат", "Анна", "Жанна Петровна", "Маша", "Вера", "Света" ] mans2 = [ "Васи", "Ромы", "Олега", "Виктора", "Дяди Пети", "Фёдора Семёновича", "Игната", "Анны", "Жанны Петровны", "Машы", "Веры", "Светы" ] while True: d = rand.randint(0, len(mans) - 1) self.chel = mans[d] self.chel2 = mans2[d] if self.chel != self.last: self.last = self.chel break self.gen = 0 if self.chel[-1] == "а" else 1 self.gen2 = 0 if self.chel2[-1] == "а" else 1 def ret(num): if int(str(num)[-1]) < 5 and int(str(num)[-1]) != 0: if num > 20: if int(str(num)[-1]) == 1: v = self.ob3[self.poz] else: v = self.ob1[self.poz] elif num > 4: v = self.ob2[self.poz] elif num != 1: v = self.ob1[self.poz] else: v = self.ob3[self.poz] else: v = self.ob2[self.poz] return v def in1(): self.col1 = ret(self.num) self.col2 = ret(self.num2) self.col3 = self.ob2[self.poz] def one(): chelik() sign = rand.choice(["+", "-"]) while True: self.num = rand.randint(2, self.maxnum) self.num2 = rand.randint(2, self.maxnum) if sign == "+": if self.num + self.num2 <= self.maxnum: self.rez = self.num + self.num2 break if sign == "-": if self.num - self.num2 > -1: self.rez = self.num - self.num2 break item("small", "food") in1() if sign == "+": if rand.randint(0, 1) == 1: dei1 = "купил" if self.gen else "купила" dei2 = "него" if self.gen else "неё" self.ui.task.setText( f"{self.chel} {dei1} в магазине {self.num} {self.col1}, а дома у {dei2} есть ещё {self.num2} {self.col2}.\nСколько всего {self.col3} имеет {self.chel}?" ) else: dei1 = "принёс" if self.gen else "принесла" dei2 = "его" if self.gen else "её" self.ui.task.setText( f"{self.chel} {dei1} {self.num} {self.col1}, а {dei2} друг принёс ещё {self.num2} {self.col2}.\nСколько всего {self.col3} они принесли?" ) if sign == "-": if rand.randint(0, 1) == 1: dei1 = "он" if self.gen else "она" dei2 = "отдал" if self.gen else "отдала" self.ui.task.setText( f"У {self.chel2} есть {self.num} {self.col1}, {self.num2} {self.col2} {dei1} {dei2} другу. Сколько теперь {self.col3} у {self.chel2}?" ) else: item("food") in1() dei1 = "купил" if self.gen else "купила" dei2 = "он" if self.gen else "она" dei3 = "съел" if self.gen else "съела" dei4 = "него" if self.gen else "неё" self.ui.task.setText( f"{self.chel} {dei1} в магазине {self.num} {self.col1}, {self.num2} {self.col2} {dei2} {dei3}. Сколько теперь у {dei4} {self.col3}" ) def two(): var = rand.randint(1, 8) while True: self.num1 = rand.randint(1, self.maxnum) self.num2 = rand.randint(1, self.maxnum) self.num3 = rand.randint(1, self.maxnum) if var == 1 or var == 5: if self.num1 + self.num2 + self.num3 <= self.maxnum: self.rez = self.num1 + self.num2 + self.num3 break if var == 2 or var == 6: if self.num1 + self.num2 - self.num3 <= self.maxnum: self.rez = self.num1 + self.num2 - self.num3 break if var == 3 or var == 7: if self.num1 - self.num2 + self.num3 <= self.maxnum: self.rez = self.num1 - self.num2 + self.num3 break if var == 4 or var == 8: if self.num1 - self.num2 - self.num3 <= self.maxnum: self.rez = self.num1 - self.num2 - self.num3 break if var == 1: dei1 = "положил" if self.gen else "положила" self.ui.task.setText( "На столе было {self.num1} {self.col1}, {self.chel} {dei1} ещё {self.num2} {self.col2}, а потом ещё {self.num1}.\nСколько всего {self.ob2[self.poz]} теперь на столе?" ) if var == 2: dei = "" if self.gen else "" self.ui.task.setText("") def three(): pass if level < 10: one() elif level < 20: if rand.random(): one() else: two() else: n = rand.ranint(0, 2) if n == 0: one() if n == 1: two() if n == 2: three()
def error(self): if Resurse("theme").read() == "css_style.txt": self.ui.porol.setStyleSheet("border-right: 5px ridge darkred;\nborder-bottom: 5px ridge darkred;\n") else: self.ui.porol.setStyleSheet("border: 3px solid red")