PyQt QLabel which can resize the font responsively accordance with window's size change
- PyQt5 >= 5.8
python -m pip install pyqt-responsive-label
setAcceptTextChange(f: bool)
- Choose the option that this should accept text change(paintEvent
) or not.
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.
Note: Since v0.0.3, text is smaller than result image above for avoiding excessive width problem.
- pyqt-timer-label - Application which is using the package.