文本编辑器中的文本:
Hello
Goodbye
Jack
Max
现在当我按下按钮插入12之后或之前:
Hello12
Goodbye12
Jack12
Max12
代码:
from PyQt5.QtWidgets import (QPushButton,QApplication,QWidget,QTextEdit,QVBoxLayout)
import sys
class MyApp(QWidget):
def __init__ (self):
super().__init__()
self.initUI()
def initUI(self):
self.btn = QPushButton('MyFirstButton',self)
self.vbox = QVBoxLayout(self)
self.txt_ed = QTextEdit(self)
self.vbox.addWidget(self.txt_ed)
self.vbox.addWidget(self.btn)
self.btn.clicked.connect(self.btn_func)
self.setGeometry(300,300,300,450)
self.setWindowTitle('MyTextApp')
self.show()
def btn_func(self):
pass
#? 1-What can I write here to when I pressed the button , delete all blank lines in QTextEdit
#? 2. How can I do this:
#text in TextEditor:
#Hello
#Goodbye
#Jack
#Max
#-----------------------------
#now when I pressed the button:
#Hello12
#Goodbye12
#Jack12
#Max12
#-----------------------------
#insert 12 after or before.
if __name__ == '__main__':
app = QApplication(sys.argv)
ex = MyApp()
sys.exit(app.exec_())
相关问题 更多 >
编程相关推荐