Skip to main content

PyQt QLabel which can resize the font responsively accordance with window's size change

Project description

pyqt-responsive-label

PyQt QLabel which can resize the font responsively accordance with window's size change

Requirements

  • PyQt5 >= 5.8

Setup

python -m pip install pyqt-responsive-label

Method Overview

  • setAcceptTextChange(f: bool) - Choose the option that this should accept text change(paintEvent) or not.

Example

from PyQt5.QtWidgets import QApplication, QVBoxLayout, QWidget

from pyqt_responsive_label import ResponsiveLabel





class Widget(QWidget):

    def __init__(self):

        super().__init__()

        self.__initUi()



    def __initUi(self):

        responsiveLabel = ResponsiveLabel(self)

        responsiveLabel.setText('ABC')



        lay = QVBoxLayout()

        lay.addWidget(responsiveLabel)



        self.setMinimumSize(responsiveLabel.sizeHint())

        self.setLayout(lay)





if __name__ == "__main__":

    import sys



    app = QApplication(sys.argv)

    widget = Widget()

    widget.show()

    app.exec_()

Result

Like below, label font size is changing accordance with window's size.

image

image

Note: Since v0.0.3, text is smaller than result image above for avoiding excessive width problem.

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-responsive-label-0.0.3.tar.gz (3.1 kB view hashes)

Uploaded Source

Built Distribution

pyqt_responsive_label-0.0.3-py3-none-any.whl (3.9 kB view hashes)

Uploaded Python 3

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