# Python 3 # -*- coding: utf-8 -*- import sys from PyQt4 import QtCore, QtGui from PyQt4.QtGui import (QWidget, qApp, QAction, QApplication, QHBoxLayout, QVBoxLayout, QGridLayout, QLabel, QLineEdit, QTextEdit, QPushButton, QComboBox, QCheckBox, QRadioButton, QFrame, QScrollArea, QTabWidget, QSizePolicy, QGroupBox, QFileDialog, QPlainTextEdit) from PyQt4.QtGui import QIcon, QPixmap, QPalette, QTextCursor from PyQt4.QtCore import QSize # ЦВЕТА ПОЛЕЙ sss_vivod = ("background-color: #456173; color: #f2f2f0; font: 14pt 'Courier New'") # ГРАФИКА class Window(QWidget): def __init__(self, parent=None): QWidget.__init__(self, parent) self.resize(200, 200) # шир / выс окна self.setWindowTitle('Заголовок') # Заголовок # БЛОК РАЗМЕТКИ #grid_os = QGridLayout() vbox = QVBoxLayout() # --- --- self.pole_1 = QTextEdit() # --- self.pole_2 = QPlainTextEdit() # --- --- self.tab = QTabWidget() self.tab.currentChanged.connect(self.on_tab) self.tab.addTab(self.pole_1, 'Читать') self.tab.addTab(self.pole_2, 'Править') self.tab.setCurrentIndex(1) vbox.addWidget(self.tab) # --- self.setLayout(vbox) # ЛОГИКА def on_tab(self): tab_index = self.tab.currentIndex() if tab_index == 0: text = self.pole_2.toPlainText() print(text) self.pole_1.clear() self.pole_1.append('<br>'.join(text)) # КОНЕЦ if __name__ == "__main__": app = QApplication(sys.argv) window = Window() window.show() sys.exit(app.exec_())
Текст для вставки:
————————————————
ьпаш швпы жывап
<b>gfdngn gfds g d;fdg fg</b> gfd g
kmgkmg df sg gs ggsd g
nj gfd gdfg g do dgdo