TransWikia.com

metaclass conflict: the metaclass of a derived class must be a (non-strict) subclass of the metaclasses of all its base

Stack Overflow на русском Asked by 3xtyL on January 24, 2021

line 29, in class gui(QtWidgets,QMainWindow):
TypeError: metaclass conflict: the metaclass of a derived class must be a (non-strict) subclass of the metaclasses of all its bases

import json
import sys
import os
import youtube_dl
from PyQt5 import QtCore, QtGui, QtWidgets
from file import Ui_MainWindow
from PyQt5.QtWidgets import QApplication, QMainWindow


class downloader(QtCore.QThread):
    mysignal = QtCore.pyqtSignal(str)

    def __init__(self, parent=None):
        super().__init__(parent)
        self.url = None

    def run(self):
        self.mysignal.emit("Скачивание началось!")

        with youtube_dl({}) as ydl:
            ydl.download([self.url])

        self.mysignal.emit("Скачивание завершено!")
        self.mysignal.emit("Готово!")

    def init_args(self, url):
        self.utl = url

class gui(QtWidgets,QMainWindow):
    def __init__(self, parent = None):
        super().__init__(parent)
        self.ui = Ui_MainWindow()
        self.ui.setupUi(self)

        self.download_folder = None
        self.ui.pushButton.clicked.connect(self.get_folder)
        self.ui.pushButton_2.clicked.connect(self.start)
        self.mythread = downloader()
        self.mythread.mysignal.connect(self.handler)

    def start(self):
        if len(self.ui.lineEdit.text()) > 5:
            if self.download_folder != None:
                link = self.ui.lineEdit.text()
                self.mythread.init_args(link)
                self.mythread.start()
                self.locker(True)
            else:
                QtWidgets.QMessageBox.warning(self, "Ошибка", "Папка не выбрана")
        else:
            QtWidgets.QMessageBox.warning(self, "Ошибка", "Ссылка на видео не указана")

    def get_folder(self):
        self.download_folder = QtWidgets.QFileDialog.getExistingDirectory(self, "Выбрать папку для сохранения")
        os.chdir(self.download_folder)

    def handler(self, value):
        if value == "finish":
            self.locker(False)

        self.ui.label.appendPlaynText(value)


    def locker(self, lock_value):
        base = [self.ui.pushButton, self.ui.pushButton_2]

        for item in base:
            item.setDisabled(lock_value)


app = QtWidgets.QApplication(sys.argv)
MainWindow = QtWidgets.QMainWindow()
ui = Ui_MainWindow()
ui.setupUi(QMainWindow)
MainWindow.show()
sys.exit(app.exec_())

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP