I want to make an interactive tutorial for special textdocuments. I would like to be able to insert text by the program and also have the user to add something.
I would like to have the text appear char by char. I tried this, but it just blocks the window from appearing completely, until the text is written out
import sys
import time
from PyQt5 import QtWidgets as qtw
def __init__(self):
super().__init__()
def write_intro(self):
welcome_string = "Welcome!"
for i in range(0, len(welcome_string)):
time.sleep(0.2)
self.insertPlainText(welcome_string[i])
class Text_Script(qtw.QTextEdit):
def __init__(self):
super().__init__()
def write_intro(self):
welcome_string = "Welcome!"
for i in range(0, len(welcome_string)):
time.sleep(0.2)
self.insertPlainText(welcome_string[i])
To copy to clipboard, switch view to plain text mode
calling in the main window
import sys
from Text_Script import Text_Script
from PyQt5 import QtWidgets as qtw
def __init__(self):
super().__init__()
self.init_me()
def init_me(self):
self.text_script = Text_Script()
self.layout().addWidget(self.text_script)
self.layout().addWidget(self.next_btn)
self.showMaximized()
self.text_script.write_intro()
if __name__ == '__main__':
mw = Lastenheft()
sys.exit(app.exec())
import sys
from Text_Script import Text_Script
from PyQt5 import QtWidgets as qtw
class Lastenheft(qtw.QWidget):
def __init__(self):
super().__init__()
self.init_me()
def init_me(self):
self.setLayout(qtw.QVBoxLayout())
self.text_script = Text_Script()
self.next_btn = qtw.QPushButton("Next")
self.layout().addWidget(self.text_script)
self.layout().addWidget(self.next_btn)
self.showMaximized()
self.text_script.write_intro()
if __name__ == '__main__':
app = qtw.QApplication(sys.argv)
mw = Lastenheft()
sys.exit(app.exec())
To copy to clipboard, switch view to plain text mode
Is there a way to achieve this?
Bookmarks