Giter VIP home page Giter VIP logo

pyqt-toast's Introduction

pyqt-toast

PyQt Toast (Small message displayed on the screen, visible for a short time)

Help Wanted

If you are good at PyQt, i kindly ask you to make setDuration work :)

Requirements

PyQt5 >= 5.14

Setup

python -m pip install pyqt-toast

Usage

  • Toast(text='This is toast', duration=3, parent=self) - Constructor. Giving parent argument to self value helps toast to maintain its place after window got moved.

Note: You have to declare this one time as a class variable at initializing point(e.g. __initUi) or else new one will pop up even though last one is still showing.

  • setPosition(pos: QPoint) - Place center of the toast at the given position.
  • setFont(font: QFont) - Set the font of text in toast. Toast's size will be automatically changed based on text's size.
  • setForegroundColor(color) - Set the text(foreground) color. color argument can be both str(6-digits hex color string), QColor types.
  • setBackgroundColor(color) - Set the background color. color argument can be both str(6-digits hex color string), QColor types.
  • setOpacity(opacity: float) - Set the opacity of toast.
  • setDuration(duration: int) - Set the duration of toast. - This doesn't work currently ..
  • setAlignment(alignment) - Set the alignment of text.

Example

Code Sample

from PyQt5.QtWidgets import QWidget, QApplication, QPushButton, QGridLayout

from pyqt_toast import Toast


class ToastExample(QWidget):
    def __init__(self):
        super().__init__()
        self.__initUi()

    def __initUi(self):
        btn = QPushButton('Krabby Patty secret formula')
        self.__toast = Toast(text='The Krabby Patty formula is the sole property of the Krusty Krab and is only to be discussed in part or in whole with its creator Mr. Krabs. Duplication of this formula is punishable by law. Restrictions apply, results may vary.', duration=3, parent=self)
        btn.clicked.connect(self.__toast.show)
        lay = QGridLayout()
        lay.addWidget(btn)
        self.setLayout(lay)


if __name__ == "__main__":
    import sys

    app = QApplication(sys.argv)
    toastExample = ToastExample()
    toastExample.show()
    app.exec_()

Result

toast_example.mp4

pyqt-toast's People

Contributors

yjg30737 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

pyqt-toast's Issues

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.