tooltip

class jukeboxcore.gui.widgets.tooltip.WidgetToolTip(orientation=PySide.QtCore.Qt.Orientation.Horizontal, alignment=None, offset=20, interval=1000, size=PySide.QtCore.QSize(160, 90), triggerevent=PySide.QtCore.QEvent.Type.ToolTip, parent=None, flags=PySide.QtCore.Qt.WindowType.CustomizeWindowHint)[source]

Bases: PySide.QtGui.QWidget

A ToolTip that can be installed on a widget via WidgetToolTip.install_tooltip()

The tooltip is a selector for added widgets. The widgets are rendered to icons that are placed onto Buttons. If a button is clicked the widget receives focus.

Warning

Setting the layout after initialisation has no effect at the moment.

There are a few properties and setters that can be changed. The affect might only take place after calling WidgetToolTip.show(). Properties and setters:

:WidgetToolTip.alignment(): property for the alignment relative to the mouse :WidgetToolTip.offset(): property for the offset relativ to the alignment :WidgetToolTip.triggerevent(): property for the event that triggers the tooltip :WidgetToolTip.setup_size(): setter for the size of one cell/button :WidgetToolTip.setup_cyatimer(): setter for the time the widget waits before closing

To use this tooltip for any widget that triggers a ToolTip event:

  1. Create the WidgetToolTip widget
  2. Install it on a widget
  3. Add Widgets to the WidgetToolTip

Example:

mainwidget = QtGui.QWidget()
widget1 = QtGui.QWidget()
widget2 = QtGui.QWidget()
# Step 1 with the default parameters
tooltip = WidgetToolTip(orientation=QtCore.Qt.Horizontal,
                        alignment=QtCore.Qt.AlignLeft | QtCore.Qt.AlignVCenter,
                        offset=20,
                        parent=None,
                        flags=QtCore.Qt.CustomizeWindowHint)
# Step 2
tooltip.install_tooltip(mainwidget)
# Step 3
tooltip.add_widget(widget1)
tooltip.add_widget(widget2)

Initialize the ToolTip in the given orientation with an optional parent and windowflags.

Parameters:
  • orientation (QtCore.Qt.Orientation) – the orientation of the tooltip. horizontal or vertical
  • parent (QtGui.QWidget) – the parent of the widget
  • alignment (QtCore.Qt.Alignment | None) – affcts the positon of the popup relative to the mouse. If None, align left and vcenter is chosen Use left, right, hcenter, top, bottom and vcenter only. Everything else will be ignored.
  • offset (int) – The offset to the alignment in pixels
  • interval (int) – The time to wait for the tooltip to close in miliseconds
  • size (QtCore.QSize) – The size of one cell/button
  • triggerevent (QtCore.QEvent.Type) – The event that triggers the tooltip
  • flags (QtCore.QtWindowFlags) – the windowflags
Raises:

TypeError

setup_layout(orientation=None)[source]

Setup the layout for the tooltip in the given orientation

Parameters:layout (QtCore.Qt.Orientation | None) – the orentation of the layout
Returns:None
Return type:None
Raises:None
setup_size(width, height)[source]

Set the width and height for one cell in the tooltip

This is inderectly acomplished by setting the iconsizes for the buttons.

Parameters:
  • width (int) – the width of one cell, min. is 7 -> icon width = 0
  • height (int) – the height of one cell, min. is 6 -> icon height = 0
Returns:

None

Return type:

None

Raises:

None

setup_cyatimer(interval)[source]

Setup the timer that will close the widget after the mouse left the widget for the time of interval

Parameters:interval (int) – the time that the tooltip waits before it dissapears in milliseconds
Returns:None
Return type:None
Raises:None
event(event)[source]

Reimplementation of QWidget.event

The widget is closed, when the window is deactivated. The widget is closed after the set interval if the mouse leaves the widget. The timer is stops when the mouse enters the widget before the interval ends. On show, the added widgets are rendered for the tooltip into buttons. The buttons are used to set the widget in focus.

create_button(widget)[source]

Create a button that has the given widget rendered as an icon

Parameters:widget (QtGui.QWidget) – the widget to render as icon
Returns:the created button
Return type:QtGui.QAbstractButton
Raises:None
update_button(button, widget)[source]

Update the icon of the button with the given widget

if the widget does not is invalid, it is deleted from the tooltip automatically.

Parameters:
  • button (QtGui.QAbstractButton) – the button to update
  • widget (QtGui.QWidget) – the widget to render as icon
Returns:

None

Return type:

None

Raises:

None

update_all_buttons()[source]

Update all buttons

Returns:None
Return type:None
Raises:None
focus_widget(checked=None, w=None)[source]

Focus the given widget. Checked is ignored and only used as a slot for QAbstractButton.clicked.

Parameters:
  • checked (bool) – The checked state of the button that was clicked
  • w (QtGui.QWidget) – the widget to focus
Returns:

None

Raises:

None

add_widget(widget)[source]

Add the given widget to the tooltip

Parameters:widget (QtGui.QWidget) – the widget to add
Returns:None
Return type:None
Raises:None
remove_widget(widget)[source]

Remove the given widget from the tooltip

Parameters:widget (QtGui.QWidget) – the widget to remove
Returns:None
Return type:None
Raises:KeyError
eventFilter(watched, event)[source]

Filter ToolTip events and display this tooltip widget, if watched requests a tooltip.

Parameters:
  • watched (QtCore.QObject) – The watched object
  • event (QtCore.QEvent) – The event sent by watched
Returns:

True if the event was processed. False if the event should be passed on.

Return type:

bool

Raises:

None

get_position()[source]

Return a recommended position for this widget to appear

This implemenation returns a position so that the widget is vertically centerd on the mouse and 10 pixels left of the mouse

Returns:the position
Return type:QPoint
Raises:None
install_tooltip(parent)[source]

Intall the tooltip on the parent so that it is shown when parent requests a tooltip

Parameters:parent (QObject) – the parent object
Returns:None
Return type:None
Raises:None
alignment[source]

Get the alginment of the tooltip relative to the mouse

Returns:alignment
Return type:QtCore.Qt.Alignment
Raises:None
offset[source]

Return offset to the alignment in pixels

Returns:offset
Return type:int
Raises:None
triggerevent[source]

Return triggerevent

Returns:triggerevent
Return type:QtCore.QEvent.Type
Raises:None
get_widgets()[source]

Return all registered Widgets

Returns:list of widgets
Return type:list
Raises:None
staticMetaObject = <PySide.QtCore.QMetaObject object at 0x00000000086F7948>
show()[source]

Reimplementation that moves the tooltip and updates the buttons

Returns:None
Return type:None
Raises:None
class jukeboxcore.gui.widgets.tooltip.JB_WindowToolTip(orientation=PySide.QtCore.Qt.Orientation.Horizontal, alignment=None, offset=20, interval=1000, size=PySide.QtCore.QSize(160, 90), triggerevent=PySide.QtCore.QEvent.Type.ToolTip, parent=None, flags=PySide.QtCore.Qt.WindowType.CustomizeWindowHint)[source]

Bases: jukeboxcore.gui.widgets.tooltip.WidgetToolTip

Initialize the ToolTip in the given orientation with an optional parent and windowflags.

Parameters:
  • orientation (QtCore.Qt.Orientation) – the orientation of the tooltip. horizontal or vertical
  • parent (QtGui.QWidget) – the parent of the widget
  • alignment (QtCore.Qt.Alignment | None) – affcts the positon of the popup relative to the mouse. If None, align left and vcenter is chosen Use left, right, hcenter, top, bottom and vcenter only. Everything else will be ignored.
  • offset (int) – The offset to the alignment in pixels
  • interval (int) – The time to wait for the tooltip to close in miliseconds
  • size (QtCore.QSize) – The size of one cell/button
  • triggerevent (QtCore.QEvent.Type) – The event that triggers the tooltip
  • flags (QtCore.QtWindowFlags) – the windowflags
Raises:

TypeError

staticMetaObject = <PySide.QtCore.QMetaObject object at 0x00000000086F75C8>
show()[source]

Reimplementation of show to update all currently available JB_MainWindows

Returns:None
Return type:None
Raises:None