Skip to main content

PyQt text box which is movable, auto-resizable by text size. Parent class is QGraphicsWidget.

Project description

pyqt-textbox-graphics-widget

PyQt text box which is movable, auto-resizable by text size. Parent class is QGraphicsWidget.

Requirements

  • PyQt5 >= 5.8

Setup

python -m pip install pyqt-textbox-graphics-widget

Usage

You can move the box if you drag any areas near the border. If you click any areas near the middle of the box, cursor will be shown to let you write something down. Box will be auto-resized by text size. (See the result below)

Example

Code Sample

from PyQt5.QtWidgets import QApplication, QGraphicsView, QGraphicsScene, QMainWindow

from pyqt_textbox_graphics_widget import TextBoxGraphicsWidget





class DiagramMainWindow(QMainWindow):

    def __init__(self):

        super().__init__()

        self.__initUi()



    def __initUi(self):

        view = QGraphicsView()



        self.__scene = QGraphicsScene()

        self.__scene.setSceneRect(0, 0, 400, 400)

        

        textBox = TextBoxGraphicsWidget()

        self.__scene.addItem(textBox)

        view.setScene(self.__scene)



        self.setCentralWidget(view)





if __name__ == "__main__":

    import sys



    app = QApplication(sys.argv)

    diagramMainWindow = DiagramMainWindow()

    diagramMainWindow.show()

    sys.exit(app.exec_())

Result

https://user-images.githubusercontent.com/55078043/153204254-cd5776c3-54c3-47a5-9285-98229b0376b1.mp4

See Also

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pyqt-textbox-graphics-widget-0.0.1.tar.gz (3.4 kB view hashes)

Uploaded Source

Built Distribution

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page