示例#1
0
class Example(QWidget):
    btns = []

    def __init__(self):
        super().__init__()
        self.initUI()
        self.s = 0

    def initUI(self):
        self.setGeometry(1000, 500, 1000, 500)
        self.setWindowTitle('Фокус со словами')

        self.stat = QStatusBar(self)
        self.stat.resize(980, 20)
        self.stat.move(10, 470)

        self.layout = QHBoxLayout()

        ltrs = 'абвгдеёжзийклмнопрстуфхцчшщъыьэюя'
        for i in range(len(ltrs)):
            self.btns.append(QPushButton(self))
            self.btns[i].setText(ltrs[i].upper())
            self.btns[i].resize(20, 20)
            self.btns[i].move((i + 1) * 10 + 20 * i, 10)
            self.layout.addWidget(self.btns[i])
            self.btns[i].clicked.connect(self.pressed_ltr)

        self.table = QTableWidget(self)
        self.table.move(10, 50)
        self.table.resize(980, 410)
        self.table.setColumnCount(5)
        self.table.setHorizontalHeaderLabels(['ID', 'Название', 'Жанр',
                                                    'Год', 'Продолжительность'])
        self.table.setRowCount(0)
        self.fill_table()

    def pressed_ltr(self):
        a = self.sender().text()
        self.fill_table(a)

    def fill_table(self, ltr=''):
        with sqlite3.connect('films_db.sqlite') as con:
            cur = con.cursor()
            res = cur.execute(f"""SELECT * FROM Films WHERE title like '{ltr}%'""").fetchall()
            self.table.setRowCount(len(res))
            for i, row in enumerate(res):
                for j, elem in enumerate(row):
                    self.table.setItem(
                        i, j, QTableWidgetItem(str(elem)))
            self.table.resizeColumnsToContents()
            if len(res) > 0:
                self.stat.showMessage(f'Нашлось {len(res)} результатов')
            else:
                self.stat.showMessage('К сожалению, ничего не нашлось')
示例#2
0
文件: main.py 项目: padayu/yandex2
class Form(QWidget, Ui_Form):
    def __init__(self):
        super().__init__()
        self.setupUi(self)
        self.statusbar = QStatusBar(self)
        self.statusbar.move(0, 420)
        self.statusbar.resize(494, 20)   
        
        self.comboBox.addItem("Молотый")
        self.comboBox.addItem("В зернах")
        
        self.pushButton.clicked.connect(self.coffee)
        
        self.mode = 0
        
    def clear(self):
        self.lineEdit.clear()
        self.lineEdit_2.clear()
        self.lineEdit_3.clear()
        self.lineEdit_4.clear()
        self.lineEdit_5.clear()
        
    def coffee(self):
        if self.mode == 0:
            if self.lineEdit.text():
                try:
                    name = self.lineEdit.text()
                    degree = self.lineEdit_2.text()
                    bg = self.comboBox.currentText()
                    desc = self.lineEdit_3.text()
                    price = int(self.lineEdit_4.text())
                    vol = int(self.lineEdit_5.text())
                    win.cur.execute(f"""
                    INSERT INTO coffee(name, degree, bg, description, price, volume) 
                    VALUES('{name}', '{degree}', '{bg}', '{desc}', {price}, {vol})
                    """)
                    win.con.commit()
                    self.statusbar.clearMessage()
                    win.update()
                    self.close()                    
                except Exception:
                    self.statusbar.showMessage("Неправильный формат ввода")
        elif self.mode == 1:
            if self.lineEdit.text():
                try:
                    cid = int(self.row[0].text())
                    name = self.lineEdit.text()
                    degree = self.lineEdit_2.text()
                    bg = self.comboBox.currentText()
                    desc = self.lineEdit_3.text()
                    price = int(self.lineEdit_4.text())
                    vol = int(self.lineEdit_5.text())
                    win.cur.execute(f"""
                    UPDATE coffee
                    SET name = '{name}'
                    WHERE id = {cid}
                    """)
                    win.cur.execute(f"""
                    UPDATE coffee
                    SET degree = '{degree}'
                    WHERE id = {cid}
                    """)
                    win.cur.execute(f"""
                    UPDATE coffee
                    SET bg = '{bg}'
                    WHERE id = {cid}
                    """)
                    win.cur.execute(f"""
                    UPDATE coffee
                    SET description = '{desc}'
                    WHERE id = {cid}
                    """)
                    win.cur.execute(f"""
                    UPDATE coffee
                    SET price = {price}
                    WHERE id = {cid}
                    """)
                    win.cur.execute(f"""
                    UPDATE coffee
                    SET volume = {vol}
                    WHERE id = {cid}
                    """)
                    win.con.commit()
                    self.statusbar.clearMessage()
                    win.update()
                    self.close()                    
                except Exception as error:
                    self.statusbar.showMessage("Неправильный формат ввода")
                    print(error)
        
    def setvalues(self):
        self.row = []
        rn = win.tableWidget.selectedItems()[0].row()
        for i in range(7):
            self.row.append(win.tableWidget.item(rn, i))
        self.lineEdit.setText(self.row[1].text())
        self.lineEdit_2.setText(self.row[2].text())
        self.lineEdit_3.setText(self.row[4].text())
        self.lineEdit_4.setText(self.row[5].text())
        self.lineEdit_5.setText(self.row[6].text())
        if self.row[3].text() == "Молотый":
            self.comboBox.setCurrentIndex(0)
        else:
            self.comboBox.setCurrentIndex(1)
示例#3
0
class MainWidget(QWidget):
    """Виджет главного окна (включает добавление одежды и генерацию образа)"""
    def __init__(self, parent):
        super().__init__(parent=parent)
        uic.loadUi('widget.ui', self)
        self.setGeometry(0, 55, 572, 541)

        self.InitUi()

        self.type_clothes = [
            self.radioButton, self.radioButton_2, self.radioButton_3,
            self.radioButton_4
        ]
        self.radioButton.setChecked(True)
        self.weather_season = [
            self.radioButton_6, self.radioButton_7, self.radioButton_8,
            self.radioButton_21
        ]
        self.radioButton_21.setChecked(True)

    def InitUi(self):
        self.btn_add_photo.setStyleSheet(ANIMATION_BTN)
        self.btn_add_photo.clicked.connect(self.add_photo)

        self.btn_add_clothes.clicked.connect(self.add_clothes_to_db)

        self.connect_to_db = sqlite3.connect('wardrobe.sqlite')

        dict_clothes = get_dict_clothes(self.connect_to_db,
                                        self.parent().user_id)
        self.dict_clothes = {}
        for garment in dict_clothes:
            self.dict_clothes[garment[1]] = self.dict_clothes.get(
                garment[1], {})
            self.dict_clothes[garment[1]][garment[2]] = self.dict_clothes[garment[1]].get(garment[2], []) + \
                                                        [(garment[0],
                                                          garment[3],
                                                          garment[4])]

        self.status = QStatusBar(self.parent())
        self.status.move(0, 585)
        self.status.resize(220, 30)

        self.pushButton_look.clicked.connect(self.change_widget)
        self.pushButton_adding.clicked.connect(self.change_widget)
        self.current_index_widget = 1

        self.months = {
            "01": "Winter",
            "02": "Winter",
            "03": "Spring",
            "04": "Spring",
            "05": "Spring",
            "06": "Summer",
            "07": "Summer",
            "08": "Summer",
            "09": "Autumn",
            "10": "Autumn",
            "11": "Autumn",
            "12": "Winter",
        }
        self.btn_generate.clicked.connect(self.generate_look_today)

        self.img_outwear.hide()
        self.img_underwear.hide()
        self.img_footwear.hide()
        self.img_jackets.hide()
        self.label_10.hide()
        self.label_11.hide()
        self.label_12.hide()
        self.label_13.hide()
        """Убрать потом"""
        self.shadow = QGraphicsDropShadowEffect()
        self.shadow.setBlurRadius(40)
        self.shadow.setXOffset(4)
        self.shadow.setYOffset(9)
        self.shadow.setColor(QColor(0, 0, 0, 30))
        self.widget.setGraphicsEffect(self.shadow)

        self.make_shadow()
        self.img_outwear.setGraphicsEffect(self.shadow)
        self.make_shadow()
        self.img_underwear.setGraphicsEffect(self.shadow)
        self.make_shadow()
        self.img_footwear.setGraphicsEffect(self.shadow)
        self.make_shadow()
        self.img_jackets.setGraphicsEffect(self.shadow)
        "0 2px 7px 0 rgba(10,10,10,.05), 3px 27px 54px -34px rgba(0,0,0,.47)"

    def make_shadow(self):
        self.shadow = QGraphicsDropShadowEffect()
        self.shadow.setBlurRadius(25)
        self.shadow.setXOffset(3)
        self.shadow.setYOffset(8)
        self.shadow.setColor(QColor(0, 0, 0, 18))

    def change_widget(self):
        """Смена виджетов (добавление одежды и генерация)"""
        self.stackedWidget.setCurrentIndex(self.current_index_widget)
        if self.current_index_widget == 0:
            self.current_index_widget = 1
        else:
            self.current_index_widget = 0

    def change_status(self, msg, color):
        self.status.setStyleSheet("color: " + color + ";")
        self.status.showMessage(msg)

    def add_photo(self):
        self.fname = QFileDialog.getOpenFileName(self, 'Выбрать фото', '')[0]

    def find_middle_color_img(self, fname):
        im = Image.open(fname)
        pixels = im.load()
        x, y = im.size
        rgb = (0, 0, 0)
        for i in range(x):
            for j in range(y):
                now_rgb = pixels[i, j]
                rgb = [elem + now_rgb[i] for i, elem in enumerate(rgb)]
        return f"{rgb[0] // (x * y)}, {rgb[1] // (x * y)}, {rgb[2] // (x * y)}"

    def read_image(self, filename):
        try:
            fin = open(filename, "rb")
            img = fin.read()
            return img
        except IOError as e:
            print("Error %d: %s" % (e.args[0], e.args[1]))
            sys.exit(1)
        finally:
            if fin:
                fin.close()

    def add_clothes_to_db(self):
        """Главная функция добавления одежды"""
        if self.check_error_in_forms_add_clothes():
            text_type_clothes = list(
                filter(lambda radiobtn: radiobtn.isChecked(),
                       self.type_clothes))[0].text()
            text_weather_season = list(
                filter(lambda radiobtn: radiobtn.isChecked(),
                       self.weather_season))[0].text()
            name_clothes = self.line_name_clothes.text()
            medium_color_img = self.find_middle_color_img(self.fname)
            img_for_db = sqlite3.Binary(self.read_image(self.fname))

            cur = self.connect_to_db.cursor()
            userid = self.parent().user_id
            cur.execute(
                "INSERT INTO clothes(photo, weather, type, mediumcolor, name, userid) "
                "VALUES (?, ?, ?, ?, ?, ?)", (
                    img_for_db,
                    text_weather_season,
                    text_type_clothes,
                    medium_color_img,
                    name_clothes,
                    userid,
                ))
            self.connect_to_db.commit()

            self.line_name_clothes.setText("")

            self.add_cache(text_weather_season, text_type_clothes,
                           medium_color_img, name_clothes, img_for_db)

            self.change_status("Successful", "green")

    def add_cache(self, weather, type, medium_color, name_clothes, img_for_db):
        """Добавление кэша(вызывается функцией add_clothes_to_db)"""
        cur = self.connect_to_db.cursor()
        id_clothes = cur.execute("SELECT id from clothes").fetchall()
        id_clothes.sort(key=lambda x: x[0])
        self.dict_clothes[weather] = self.dict_clothes.get(weather, {})
        self.dict_clothes[weather][type] = self.dict_clothes[weather].get(
            type, []) + [(id_clothes[-1][0], medium_color, name_clothes)]

        with open(PATH_FOLDER_PHOTO + str(id_clothes[-1][0]) + '.jpg',
                  'tw',
                  encoding='utf-8') as f:
            pass
        f = open(PATH_FOLDER_PHOTO + str(id_clothes[-1][0]) + '.jpg', "wb")
        f.write(img_for_db)

    def check_error_in_forms_add_clothes(self):
        if self.line_name_clothes.text() == "":
            self.change_status("Name is not filled", "red")
            return False
        try:
            if self.fname:
                pass
        except AttributeError:
            self.change_status("Photo is not filled", "red")
            return False
        self.parent().statusBar().showMessage("")
        return True

    def generate_look_today(self):
        """Главная функция генерации образа"""
        self.show_and_hide_elem_clothes()

        self.label_not_selected.hide()
        month = self.months[dt.datetime.now().strftime("%m")]
        weather_clothes = self.dict_clothes.get(month, False)
        if not (weather_clothes):
            self.status.setStyleSheet("color: red;")
            self.status.showMessage("No suitable clothes")
            return False
        self.outerwear_clothes = weather_clothes.get("Outwear", False)
        self.underwear_clothes = weather_clothes.get("Underwear", False)
        self.footwear_clothes = weather_clothes.get("Footwear", False)
        self.jackets_and_coat_clothes = weather_clothes.get(
            "Jackets, coat", False)

        if self.check_existence_required_types_clothing():
            if self.footwear_clothes and self.jackets_and_coat_clothes:
                self.display_сlothes_in_widget(
                    ("outwear", choice(self.outerwear_clothes)),
                    ("underwear", choice(self.underwear_clothes)),
                    ("footwear", choice(self.footwear_clothes)),
                    ("jackets", choice(self.jackets_and_coat_clothes)))
            elif self.footwear_clothes:
                self.display_сlothes_in_widget(
                    ("outwear", choice(self.outerwear_clothes)),
                    ("underwear", choice(self.underwear_clothes)),
                    ("footwear", choice(self.footwear_clothes)))
            elif self.jackets_and_coat_clothes:
                self.display_сlothes_in_widget(
                    ("outwear", choice(self.outerwear_clothes)),
                    ("underwear", choice(self.underwear_clothes)),
                    ("jackets", choice(self.jackets_and_coat_clothes)))
            else:
                self.display_сlothes_in_widget(
                    ("outwear", choice(self.outerwear_clothes)),
                    ("underwear", choice(self.underwear_clothes)))

    def show_and_hide_elem_clothes(self):
        """Функция, показывающая карточки одежды при нажатии на кнопку для генерации"""
        self.label_not_selected.hide()
        self.img_outwear.show()
        self.img_underwear.show()
        self.img_footwear.show()
        self.img_jackets.show()
        self.label_10.show()
        self.label_11.show()
        self.label_12.show()
        self.label_13.show()

    def check_existence_required_types_clothing(self):
        if not (self.outerwear_clothes) or not (self.underwear_clothes):
            self.change_status("Not clothes for generate look", "red")
            return False
        elif not (self.footwear_clothes):
            self.change_status("Genered imperfect look", "yellow")
            return True
        return True

    def display_сlothes_in_widget(self, *clothes):
        """Функия, заполняющая карточки изображением и текстом"""
        for thing in clothes:
            self.now_pixmap_clothes = self.create_pixmap_clothes(thing[1][0])
            if thing[0] == "outwear":
                self.img_outwear.setPixmap(self.now_pixmap_clothes)
                self.label_name_outwear.setText(thing[1][2].title())
            if thing[0] == "underwear":
                self.img_underwear.setPixmap(self.now_pixmap_clothes)
                self.label_name_underwear.setText(thing[1][2].title())
            if thing[0] == "footwear":
                self.img_footwear.setPixmap(self.now_pixmap_clothes)
                self.label_name_footwear.setText(thing[1][2].title())
            if thing[0] == "jackets":
                self.img_jackets.setPixmap(self.now_pixmap_clothes)
                self.label_name_jackets.setText(thing[1][2].title())

    def create_pixmap_clothes(self, clothes_id: int):
        self.pixmap = QPixmap(PATH_FOLDER_PHOTO + str(clothes_id) + ".jpg")
        return self.pixmap.scaled(self.img_outwear.size().width() + 20,
                                  self.img_outwear.size().height() - 40)
示例#4
0
文件: 3hw.py 项目: Egor-05/Yandex2
class Example(QWidget):
    btns = []
    btn_text_X = True
    field = [['', '', ''], ['', '', ''], ['', '', '']]
    s = 0
    win = False

    def __init__(self):
        super().__init__()
        self.initUI()
        self.s = 0

    def initUI(self):
        self.setGeometry(340, 240, 240, 340)
        self.setWindowTitle('Фокус со словами')

        self.rb1 = QRadioButton(self)
        self.rb1.setText('X')
        self.rb1.move(85, 20)
        self.rb1.setChecked(True)

        self.rb2 = QRadioButton(self)
        self.rb2.setText('O')
        self.rb2.move(125, 20)

        self.bg = QButtonGroup(self)
        self.bg.addButton(self.rb1)
        self.bg.addButton(self.rb2)
        self.bg.buttonClicked.connect(self.check)

        self.stat = QStatusBar(self)
        self.stat.resize(100, 30)
        self.stat.move(100, 260)

        self.btn = QPushButton(self)
        self.btn.setText('Новая игра')
        self.btn.resize(self.btn.sizeHint())
        self.btn.move(100, 300)
        self.btn.clicked.connect(self.new_game)

        x = -50
        y = -20
        for j in range(9):
            x = -50 if j % 3 == 0 else x
            if j % 3 == 0:
                y += 70
            x += 70
            self.btns.append(QPushButton(self))
            self.btns[j].setText('')
            self.btns[j].resize(60, 60)
            self.btns[j].move(x, y)
            self.btns[j].clicked.connect(self.btn_ispressed)

    def btn_ispressed(self):
        a = self.sender()
        if self.s < 9 and a.text() == '' and not self.win:
            b = self.btns.index(a)
            c = 'X' if self.btn_text_X else 'O'
            a.setText(c)
            self.field[b // 3][b % 3] = c.lower()
            self.s += 1
            self.check_win()
            self.btn_text_X = not self.btn_text_X

    def check(self):
        if self.s == 0:
            self.btn_text_X = self.rb1.isChecked()

    def check_win(self):
        for i in range(3):
            s = ''.join([self.field[i][j] for j in range(3)])
            if 'ooo' in s:
                self.stat.showMessage('Выйграл O!')
                self.win = True
            elif 'xxx' in s:
                self.stat.showMessage('выйграл X!')
                self.win = True
        for i in range(3):
            s = ''.join([self.field[j][i] for j in range(3)])
            if 'ooo' in s:
                self.stat.showMessage('Выйграл O!')
                self.win = True
            elif 'xxx' in s:
                self.stat.showMessage('Выйграл X!')
                self.win = True
        if self.field[0][0] + self.field[1][1] + self.field[2][2] == 'xxx':
            self.stat.showMessage('Выйграл X!')
            self.win = True
        elif self.field[0][0] + self.field[1][1] + self.field[2][2] == 'ooo':
            self.stat.showMessage('Выйграл O!')
            self.win = True
        elif self.field[0][2] + self.field[1][1] + self.field[2][0] == 'xxx':
            self.stat.showMessage('Выйграл X!')
            self.win = True
        elif self.field[0][2] + self.field[1][1] + self.field[2][0] == 'ooo':
            self.stat.showMessage('Выйграл O!')
            self.win = True
        if self.s == 9 and not self.win:
            self.stat.showMessage('Ничья!')

    def new_game(self):
        self.btn_text_X = True
        self.field = [['', '', ''], ['', '', ''], ['', '', '']]
        self.s = 0
        self.win = False
        for i in range(len(self.btns)):
            self.btns[i].setText('')
            self.stat.showMessage('')
示例#5
0
文件: main.py 项目: In228/projects
class Grafics(QMainWindow):
    def __init__(self):
        super().__init__()
        self.flag_theme = True
        uic.loadUi('ui/graph.ui', self)
        # В словарь добавляются основные графики
        self.EXCHANGE_RATES = {
            'Линейная функция': 'y = a * x + b',
            'Степенная функция': 'y = x ** a',
            'Обратно пропорциональная функция': 'y = a / x',
            'Квадратичная функция': 'y = a * x ** 2 + b * x + c'
        }
        # В выпадающий список добавляется словарь с ключами
        self.comboBox.addItems(self.EXCHANGE_RATES.keys())
        # И по изменению запускается функция
        self.comboBox.currentIndexChanged.connect(self.func)
        # Флаг нужен для того чтобы перерисовывать заново окно, позже мы это увидим
        self.flag = True
        self.work_btn.clicked.connect(self.work)
        self.dopBtn.clicked.connect(self.dopWork)
        # Вызывается функция
        self.func()
        # Рисуются компоненты для дополнительного окна
        self.statusBar = QStatusBar(self)
        self.statusBar.move(150, 150)
        self.statusBar.resize(259, 23)
        self.work_btn2 = QPushButton('Построить', self)
        self.work_btn2.move(290, 79)
        self.work_btn2.resize(159, 23)
        self.work_btn2.setStyleSheet(
            'background-color: qlineargradient(spread:pad, x1:1, y1:1, x2:0.034, y2:0,'
            ' stop:0 rgba(255, 255, 111, 255), stop:1 rgba(255, 255, 255, 255));')
        self.work_btn2.clicked.connect(self.work2)
        self.work_btn2.hide()
        self.dopLineEdit = QLineEdit(self)
        self.dopLineEdit.move(130, 79)
        self.dopLineEdit.resize(159, 23)
        self.dopLineEdit.setText('y = (x) ** -4')
        self.dopLineEdit.hide()
        self.help_btn = QPushButton('Помощь', self)
        self.help_btn.move(10, 79)
        self.help_btn.resize(118, 23)
        self.help_btn.setStyleSheet(
            'background-color: qlineargradient(spread:pad, x1:1, y1:1, x2:0.034, y2:0,'
            ' stop:0 rgba(255, 255, 111, 255), stop:1 rgba(255, 255, 255, 255));')
        self.help_btn.clicked.connect(self.help)
        self.actionBlack_theme.triggered.connect(self.mode)
        self.actionStandart_theme.triggered.connect(self.mode)
        self.help_btn.hide()

    def mode(self):
        if self.flag_theme:
            buttons = ['comboBox', 'work_btn', 'dopBtn', 'help_btn', 'work_btn2', 'spinBox',
                       'spinBox_2', 'spinBox_3', 'dopLineEdit']
            buttons2 = ['label', 'label_2', 'label_3', 'label_4', 'label_5']
            for i in buttons:
                eval('self.' + f'{i}').setStyleSheet("background-color: rgb(200, 200, 200);")
            self.setStyleSheet('background-color: rgb(50, 50, 50);')
            for i in buttons2:
                eval('self.' + f'{i}').setStyleSheet("color: rgb(200, 200, 200);")
            self.flag_theme = False
        else:
            buttons = ['comboBox', 'work_btn', 'dopBtn', 'help_btn', 'work_btn2', 'spinBox',
                       'spinBox_2', 'spinBox_3']
            buttons2 = ['label', 'label_2', 'label_3', 'label_4', 'label_5']
            for i in buttons:
                eval('self.' + f'{i}').setStyleSheet("background-color: qlineargradient(spread:pad,"
                                                     " x1:1, y1:1, x2:0.034, y2:0, stop:0 rgba(255, 255,"
                                                     " 111, 255), stop:1 rgba(255, 255, 255, 255));")
            for i in buttons2:
                eval('self.' + f'{i}').setStyleSheet("color: rgb(0, 0, 0);")
            self.setStyleSheet('background-color: rgb(200, 200, 200);')
            self.flag_theme = True

    def func(self):
        # Метод выводит в label функцию, значение словаря и показывает поля для ввода коэфициэнта
        self.spinBox_3.hide()
        self.label_5.hide()
        self.spinBox_2.hide()
        self.label_4.hide()
        self.spinBox.hide()
        self.label_3.hide()
        self.spinBox.setValue(0)
        self.spinBox_2.setValue(0)
        self.spinBox_3.setValue(0)
        self.label_2.setText(self.EXCHANGE_RATES[self.comboBox.currentText()])
        if self.comboBox.currentText() == 'Линейная функция':
            self.spinBox.show()
            self.label_3.show()
            self.spinBox_2.show()
            self.label_4.show()
        elif self.comboBox.currentText() == 'Степенная функция':
            self.spinBox.show()
            self.label_3.show()
        elif self.comboBox.currentText() == 'Обратно пропорциональная функция':
            self.spinBox.show()
            self.label_3.show()
        elif self.comboBox.currentText() == 'Квадратичная функция':
            self.spinBox_3.show()
            self.label_5.show()
            self.spinBox_2.show()
            self.label_4.show()
            self.spinBox.show()
            self.label_3.show()

    def dopWork(self):
        # Дополнительная функция скрывает основными методы для показа новых и отрисовки более сложных графиков
        if self.flag:
            self.spinBox_3.hide()
            self.label_5.hide()
            self.spinBox_2.hide()
            self.label_4.hide()
            self.spinBox.hide()
            self.label_3.hide()
            self.comboBox.hide()
            self.label_2.hide()
            self.work_btn.hide()
            self.dopBtn.setText('Вернуть обратно.')
            self.dopLineEdit.show()
            self.work_btn2.show()
            self.help_btn.show()
            self.flag = False
        else:
            # Скрывается дополнитнльные методы отрисовки и показываются основные
            self.comboBox.show()
            self.label_2.show()
            self.work_btn.show()
            self.dopLineEdit.hide()
            self.work_btn2.hide()
            self.help_btn.hide()
            self.statusBar.showMessage('')
            self.dopBtn.setText('Более сложные графики')
            self.flag = True
            self.func()

    def work2(self):
        # Функция для отрисовки усложненных графиков
        try:
            if self.dopLineEdit.text().find('y = ') < self.dopLineEdit.text().find(
                'x') and self.dopLineEdit.text().find('y =') != -1 and self.dopLineEdit.text().find(
                '(') < self.dopLineEdit.text().find('x') and self.dopLineEdit.text().find(
                ')') > self.dopLineEdit.text().find('x') and self.dopLineEdit.text().find(
                '(') != -1 and self.dopLineEdit.text().find(')') != -1:
                self.statusBar.showMessage('')
                self.GraphWidget.clear()
                if '** 0.' in self.dopLineEdit.text() or '** (' in self.dopLineEdit.text():
                    a = []
                    b = []
                    for i in range(0, 11):
                        try:
                            a.append(eval(self.dopLineEdit.text().replace('x', f'{i}')[4:]))
                            b.append(i)
                        except ZeroDivisionError:
                            continue
                    self.GraphWidget.plot(b, a)
                else:
                    a = []
                    b = []
                    for i in range(-10, 1):
                        try:
                            a.append(eval(self.dopLineEdit.text().replace('x', f'{i}')[4:]))
                            b.append(i)
                        except ZeroDivisionError:
                            continue
                    self.GraphWidget.plot(b, a)
                    a = []
                    b = []
                    for i in range(0, 11):
                        try:
                            a.append(eval(self.dopLineEdit.text().replace('x', f'{i}')[4:]))
                            b.append(i)
                        except ZeroDivisionError:
                            continue
                    self.GraphWidget.plot(b, a)
            else:
                self.statusBar.showMessage(f'Неправильный формат ввода функции!')
        except NameError:
            pass

    def help(self):
        self.help = Help_Window()
        self.help.show()

    def work(self):
        # Основной метод для отрисовки графика
        self.GraphWidget.clear()
        # Проверяется по ключу какой график надо строить
        if self.comboBox.currentText() == 'Линейная функция':
            self.GraphWidget.plot([i for i in range(-10, 11)],
                                  [self.spinBox.value() * i + self.spinBox_2.value() for i in range(-10, 11)])
        elif self.comboBox.currentText() == 'Степенная функция' and self.spinBox.value() < 0:
            self.GraphWidget.plot([i for i in range(-10, 1) if i != 0],
                                  [i ** self.spinBox.value() for i in range(-10, 1) if i != 0])
            self.GraphWidget.plot([i for i in range(1, 11) if i != 0],
                                  [i ** self.spinBox.value() for i in range(1, 11) if i != 0])
        elif self.comboBox.currentText() == 'Степенная функция':
            self.GraphWidget.plot([i for i in range(-10, 11)],
                                  [i ** self.spinBox.value() for i in range(-10, 11)])
        elif self.comboBox.currentText() == 'Обратно пропорциональная функция':
            self.GraphWidget.plot([i for i in range(-10, 1) if i != 0],
                                  [self.spinBox.value() / i for i in range(-10, 1) if i != 0])
            self.GraphWidget.plot([i for i in range(1, 11) if i != 0],
                                  [self.spinBox.value() / i for i in range(1, 11) if i != 0])
        elif self.comboBox.currentText() == 'Квадратичная функция':
            self.GraphWidget.plot([i for i in range(-10, 11)],
                                  [self.spinBox.value() * i ** 2 + self.spinBox_2.value() * i + self.spinBox_3.value()
                                   for i in range(-10, 11)])