import sys
import os
import time
import random
import threading
from PySide6 import QtCore, QtWidgets, QtGui

count = 0
args = []
args.append(count)

def threadfunc(args):
    
    for x in range(10000):
        print(args)
    pass



class MyWidget(QtWidgets.QWidget):
    def __init__(self):
        super().__init__()

        self.hello = ["Hallo Welt", "Hei maailma", "Hola Mundo", "Привет мир"]

        self.button = QtWidgets.QPushButton("Click me!")
        self.text = QtWidgets.QLabel("Hello World",
                                     alignment=QtCore.Qt.AlignCenter)

        self.layout = QtWidgets.QVBoxLayout(self)
        self.layout.addWidget(self.text)
        self.layout.addWidget(self.button)
        self.button.clicked.connect(self.magic)

        self.progress = QtWidgets.QProgressBar(self)
        self.progress.resize(800,30)
        self.progress.setValue(0)
        self.messagebox = QtWidgets.QMessageBox(parent=self, icon=QtWidgets.QMessageBox.Information)
        self.thread = threading.Thread(None, threadfunc, args=args)

    @QtCore.Slot()
    def magic(self):
        self.text.setText(random.choice(self.hello))
        if(self.progress.value() != 100):
            self.progress.setValue(self.progress.value()+1)
        if(self.progress.value() == 10):
            self.messagebox.setWindowTitle("INFO")
            self.messagebox.setText("Abgeschlossen!")
            self.messagebox.show()
            self.thread.start()
            


if __name__ == "__main__":
    app = QtWidgets.QApplication([])
    
    widget = MyWidget()

    widget.resize(800, 600) #Setzt die Anfangsfenstergröße
    widget.setFixedSize(widget.size()) #Fixiert die vordefinierte Größe
    widget.show()
    #Mainloop
    sys.exit(app.exec())