Skip to content

PyQt widget which can find and replace text in the QTextEdit/QTextBrowser

License

Notifications You must be signed in to change notification settings

yjg30737/pyqt-find-replace-text-widget

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

57 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

pyqt-find-replace-text-widget

PyQt widget which can find and replace text in the QTextEdit/QTextBrowser

Class Overview

  • FindReplaceTextWidget
  • ReplaceTextWidget (This module is supposed to be submodule of FindReplaceTextWidget)

Requirements

  • PyQt5 >= 5.8

Setup

python -m pip install pyqt-find-replace-text-widget

Included package

Example

I show you my full code sample. Set up this package, copy and paste this code to your IDE and run.

from PyQt5.QtWidgets import QMainWindow, QApplication, QGridLayout, QWidget, QTextEdit
from pyqt_find_replace_text_widget.findReplaceTextWidget import FindReplaceTextWidget


class MainWindow(QMainWindow):
    def __init__(self):
        super().__init__()
        self.__initUi()

    def __initUi(self):
        self.__te = QTextEdit()
        self.__te.setStyleSheet('QTextEdit { selection-background-color: lightblue; }')

        self.__w = FindReplaceTextWidget(self.__te)

        lay = QGridLayout()
        lay.addWidget(self.__w)
        lay.addWidget(self.__te)

        mainWidget = QWidget()
        mainWidget.setLayout(lay)

        self.setCentralWidget(mainWidget)


if __name__ == "__main__":
    import sys

    app = QApplication(sys.argv)
    mainWindow = MainWindow()
    mainWindow.show()
    sys.exit(app.exec_())

Result

Note: Button icons in preview are obsolete. Back then button icons were PNG, but now these are brand-new good looking SVG!

example.mp4

Note

There is exclude button but i don't add feature on it. I will add proper feature on that one.. or someone please do this instead of me, so busy..