I have the following program but it turns out that when it has to pass the text the program gets stuck and does not show letter by letter
import sys
from PySide2.QtWidgets import *
from PySide2.QtCore import *
from time import sleep
from mensaje import Ui_MainWindow
class mensaje(QMainWindow):
def __init__(self, parent=None):
super(mensaje, self).__init__(parent)
self.mensaje = Ui_MainWindow()
self.mensaje.setupUi(self)
self.mensaje.pushButton_2.clicked.connect(self.typetext)
def typetext(self):
t = "hello world"
a = ""
for i in t:
a = a + i
self.mensaje.texto.setText(a)
sleep(0.5)
if __name__ == "__main__":
app = QApplication(sys.argv)
app.setQuitOnLastWindowClosed(True)
myapp = mensaje()
myapp.show()
sys.exit(app.exec_())
You have to implement the logic of getting each letter every T second using a QTimer (not time.sleep) and insert the text, you should not replace all the text: