0

Output I got

DEBUG:git.repo.base:Cmd(['git', 'clone', '-v', 'https://github.com/addddd123/Osdag', 'new_update'])'s unused stdout: <br><br>
QObject: Cannot create children for a parent that is in a different thread.<br><br>
(Parent is QTextDocument(0x55d03b8d0a70), parent's thread is QThread(0x55d0380e7b10), current thread is threadclass(0x7fb988009ab0)
QObject::connect: Cannot queue arguments of type 'QTextCursor'<br><b>
(Make sure 'QTextCursor' is registered using qRegisterMetaType().)

Whole gui works fine even download repo but genrate error
Cannot create children for a parent that is in a different thread, parent's thread is QThread, current thread is threadclass

class mainwin():

    def __init__(self):
        super().__init__()
        msgbox = QMessageBox()
        msgbox.setText(msg)
        update_btn=msgbox.addButton('Update', QMessageBox.YesRole)
        update_btn.clicked.connect(self.thread_fxn)

    def thread_fxn()
        self.thread = threadclass()
        self.thread.start()


class threadclass(QThread):        
    def run(self):
        # QMessageBox.information(self,'Info',"Downloading... Started")
        try:                 
            git.Repo.clone_from('https://github.com/addddd123/Osdag', 'new_update')
            QMessageBox.information(self,"info","Download repo successfully")
        except:
            QMessageBox.information(self,'Info',"No internet!!")
            # QMessageBox.information(self,'Info',"Downloaded Successfully")
        if platform == "linux" or platform == "linux2":
            print("linux system")
            os.system('./update.sh')
        elif platform == "win32":
            import subprocess
            print("windows system")
            subprocess.call([r'update.bat'])
        else:
            pass
eyllanesc
  • 235,170
  • 19
  • 170
  • 241
  • 1
    You can't create widgets in other threads than the main thread . To open the message box, you could use a signal to emit the message that you want displayed and connect this to some slot (could be a method in `mainwin`) to open the message box in the main thread. – Heike May 16 '21 at 09:21
  • @Heike I did exactly same earlier but as I am cloning repository , it takes little time and till that time Gui freezes , shows two options force quit or wait – Adnan Sheikh May 16 '21 at 16:09

0 Answers0