Giter VIP home page Giter VIP logo

pyqt-explanation-balloon's Introduction

pyqt-explanation-balloon

PyQt explanation balloon

Requirements

  • PyQt5 >= 5.8

Setup

python -m pip install pyqt-explanation-balloon

Preview

Explanation balloon can be used to explain certain widget. You can close this balloon with X button at the top right.

image

You can set the widget which you want to describe with balloon.

You can also set the size and content of balloon with constructor. Check the class overview below.

This explanation balloon is perfectly responsive to window's resize/move/activate/deactivate event.

Text alignment is set to the center, word is wrapped at word boundaries.

Class/Method Overview

  • ExplanationBalloon(widget, width: float, height: float, text: str) - Constructor. widget is the widget which is supposed to be explained by explanation balloon.
  • setBackgroundColor(color: QColor) - Set the background color. Text color will be also changed automatically based on background color.
  • setFont(font: QFont) - Default function of Qt. You can set the font of text.

Example

from PyQt5.QtGui import QFont, QColor
from PyQt5.QtWidgets import QMainWindow, QPushButton, QApplication, QVBoxLayout, QWidget

from pyqt_explanation_balloon.explanationBalloon import ExplanationBalloon


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

    def __initUi(self):
        btn = QPushButton('Show explanation balloon')

        lay = QVBoxLayout()
        lay.addWidget(btn)

        mainWidget = QWidget()
        mainWidget.setLayout(lay)

        self.setCentralWidget(mainWidget)

        self.__eb = ExplanationBalloon(btn, 300.0, 200.0, 'This is explanation balloon made out of PyQt')
        self.__eb.setFont(QFont('Arial', 14))
        self.__eb.setBackgroundColor(QColor(50, 50, 50, 255))
        btn.clicked.connect(self.__eb.show)


if __name__ == "__main__":
    import sys

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

Result

image

pyqt-explanation-balloon's People

Contributors

yjg30737 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.