Skip to content

QtPopout#

Contextual popouts that point back to a target widget.

Screenshot#

qt popout

Example#

Source: examples/qt_popout.py

"""QtPopout example."""

from qtpy.QtWidgets import QApplication, QPushButton, QVBoxLayout, QWidget

from qtextra.config import THEMES
from qtextra.widgets.qt_popout import PopoutAnimationType, QtPopout


def create_popout():
    """Create a popout."""
    animation_type = PopoutAnimationType.FADE_IN
    QtPopout.init(
        title=f"Displaying using {animation_type}",
        content="Here you can add custom text that will be displayed below the title.",
        parent=widget,
        animation_type=animation_type,
        target=button,
        is_closable=True,
    )


app = QApplication([])

widget = QWidget()
widget.setMinimumSize(600, 300)
THEMES.apply(widget)

layout = QVBoxLayout()
widget.setLayout(layout)

layout.addWidget(button := QPushButton("Press me to see popout"))
button.clicked.connect(create_popout)
widget.show()
create_popout()

app.exec_()

Notes#

  • Use popouts for contextual explanations that should stay near the triggering control.

API#

Qt Class#

QWidget

Signals#

evt_closed#

Methods#

Popout.

exec(pos: QPoint, animation_type=PopoutAnimationType.SLIDE_UP) #

Show calendar view.

fade_out() -> None #

init(title: str, content: str, icon: Union[QIcon, str] = None, image: Union[str, QPixmap, QImage] = None, is_closable=False, target: Union[QWidget, QPoint] = None, parent=None, animation_type: PopoutAnimationType = PopoutAnimationType.SLIDE_UP, close_on_delete=True) classmethod #

Create and show a Popout using the default view.

Parameters:

Name Type Description Default
title str

the title of teaching tip

required
content str

the content of teaching tip

required
icon Union[QIcon, str]

the icon of teaching tip

None
image Union[str, QPixmap, QImage]

the image of teaching tip

None
is_closable

whether to show the close button

False
target Union[QWidget, QPoint]

the target widget or position to show Popout

None
parent

parent window

None
animation_type PopoutAnimationType

Popout animation type

SLIDE_UP
close_on_delete

whether delete Popout automatically when Popout is evt_closed

True

setShadowEffect(blurRadius=35, offset=(0, 8)) #

Add shadow to dialog.