我用一个计时器解决了这个问题,把它检查出来。不介意我导入的模块,也懒得删除无用的模块。
from PyQt5.QtWidgets import (QMessageBox,QApplication, QWidget, QToolTip, QPushButton,
QDesktopWidget, QMainWindow, QAction, qApp, QToolBar, QVBoxLayout,
QComboBox,QLabel,QLineEdit,QGridLayout,QMenuBar,QMenu,QStatusBar,
QTextEdit,QDialog,QFrame,QProgressBar,QHBoxLayout,QGraphicsDropShadowEffect,
QCheckBox
)
from PyQt5 import QtCore, QtWidgets, QtGui
from PyQt5.QtGui import QIcon,QFont,QPixmap,QPalette,QWindow
from PyQt5.QtCore import QCoreApplication, Qt,QBasicTimer, QTimer,QPoint,QSize
import PyQt5.QtWidgets,PyQt5.QtCore
class Settings(QMainWindow):
def __init__(self):
super().__init__()
self.set_widget = QMainWindow(self)
self.setWindowFlags(QtCore.Qt.FramelessWindowHint)
#size
self.setFixedSize(900,423)
#line
self.line_edit = QLineEdit(self)
self.line_edit.setGeometry(100,100,400,35)
self.line_edit.setStyleSheet("color: white;"
"background-color: rgb(0,0,0);"
"border: 1px solid white;"
"border-radius: 10px;"
"font: bold 15pt 'Comic Sans MS'")
self.timer26 = QTimer(self)
self.timer26.timeout.connect(self.timergo)
self.timer26.start(90)
self.cnt = 0
self.lst = ""
def timergo(self):
text = "I'm a text has interval between the letters"
try:
self.lst += text[self.cnt]
self.line_edit.setText("".join(str(self.lst[::])))
self.cnt+=1
except:
print ("index error")
#or just pass
self.show()
app1 = QApplication(sys.argv)
app1.setStyleSheet("QMainWindow{background-color: rgb(0,0,0);border: 2px solid rgb(20,20,20)}")
ex1 = Settings()
sys.exit(app1.exec_())
这应该是相对容易的一个计时器。缓存最终的文本字符串和表示字符串中位置的整数。每当定时器启动时,添加另一个字符。 –
@JonHarper你能举个实例吗? – GLHF