ui#

Various generic utility classes and functions used to define the UI.

bookmarks.ui.MESSAGE_BOX_STYLESHEET#

Stylesheet used to style our custom QMessageBox.

Type

str

bookmarks.ui.PUSH_BUTTON_STYLESHEET#

Stylesheet used to style our custom QPushButton.

Type

str

Classes:

AbstractListModel([parent])

Generic list model used to store custom data.

ClickableIconButton(pixmap, colors, size[, ...])

A utility class for creating a square icon button.

ErrorBox(*args, **kwargs)

Informative message box used for notifying the user of an error.

GalleryItem(label, data, thumbnail[, ...])

Custom QLabel used by the GalleryWidget to display an image.

GalleryWidget([columns, item_height, label, ...])

A generic gallery widget used to let the user pick an item.

Label(text[, color, parent])

LineEdit([parent])

Custom line edit widget with a single underline.

ListOverlayWidget([parent])

Widget used to display a status message over the list widget.

ListViewWidget([default_message, ...])

A custom list widget used to display selectable item.

ListWidget([default_message, default_icon, ...])

A custom list widget used to display selectable item.

ListWidgetDelegate

Custom delegate to display label-like QListWidgetItems.

MessageBox(*args, **kwargs)

Informative message box used for notifying the user of an event.

OkBox(*args, **kwargs)

Informative message box used for notifying the user of success.

PaintedButton(text[, height, width, parent])

Custom button class.

PaintedLabel(text[, color, size, parent])

QLabel used for static aliased label.

Functions:

add_description(text[, label, color, ...])

Utility method for adding a description field.

add_label(text[, parent])

Utility method for creating a label.

add_line_edit(label[, parent])

Utility method for adding a line editor.

add_row(label[, color, padding, height, ...])

Utility method for creating a row widget.

get_group([parent, vertical, margin])

Utility method for creating a group widget.

get_icon(name[, color, size, opacity, resource])

Utility method for retuning a QIcon to use in the context menu.

paint_background_icon(name, widget)

Paints a decorative background icon to the middle of the given widget.

class bookmarks.ui.AbstractListModel(parent=None)[source]#

Bases: QAbstractListModel

Generic list model used to store custom data.

Methods:

data(self, index[, role])

flags(self, index)

index(self, row[, column, parent])

rowCount(self[, parent])

data(self, index: PySide2.QtCore.QModelIndex, role: int = PySide2.QtCore.Qt.ItemDataRole.DisplayRole) Any[source]#
flags(self, index: PySide2.QtCore.QModelIndex) PySide2.QtCore.Qt.ItemFlags[source]#
index(self, row: int, column: int = 0, parent: PySide2.QtCore.QModelIndex = Invalid(PySide2.QtCore.QModelIndex)) PySide2.QtCore.QModelIndex[source]#
rowCount(self, parent: PySide2.QtCore.QModelIndex = Invalid(PySide2.QtCore.QModelIndex)) int[source]#
class bookmarks.ui.ClickableIconButton(pixmap, colors, size, description='', state=False, parent=None)[source]#

Bases: QLabel

A utility class for creating a square icon button.

Parameters
  • pixmap (str) – The name of the resource file without the extension.

  • colors (tuple(QColor, QColor)) – A tuple of QColors, for enabled and

  • disabled states.

  • size (int) – The value for width and height.

  • description (str) – A user readable description of the action the button

  • performs.

  • parent (QObject) – The widget’s parent.

Signals:

clicked (QtCore.Signal()): doubleClicked (QtCore.Signal()): message (QtCore.Signal(str)):

Returns

Description of returned object.

Return type

type

Methods:

contextMenuEvent(event)

Event handler.

enterEvent(event)

Event handler.

leaveEvent(event)

Event handler.

mouseDoubleClickEvent(event)

Event handler.

mouseReleaseEvent(event)

Event handler.

paintEvent(event)

Event handler.

pixmap(self)

contextMenuEvent(event)[source]#

Event handler.

enterEvent(event)[source]#

Event handler.

leaveEvent(event)[source]#

Event handler.

mouseDoubleClickEvent(event)[source]#

Event handler.

mouseReleaseEvent(event)[source]#

Event handler.

paintEvent(event)[source]#

Event handler.

pixmap(self) PySide2.QtGui.QPixmap[source]#
class bookmarks.ui.ErrorBox(*args, **kwargs)[source]#

Bases: MessageBox

Informative message box used for notifying the user of an error.

class bookmarks.ui.GalleryItem(label, data, thumbnail, height=common.size(common.size_row_height) * 2, parent=None)[source]#

Bases: QLabel

Custom QLabel used by the GalleryWidget to display an image.

Parameters
  • label (str) – An informative label.

  • data (str) – The item’s data. This will be emitted by the clicked signal.

  • thumbnail (str) – Path to an image file.

  • height (int or float, optional) – The item’s width/height in pixels.

Methods:

enterEvent(self, event)

leaveEvent(self, event)

mouseReleaseEvent(self, ev)

paintEvent(self, arg__1)

enterEvent(self, event: PySide2.QtCore.QEvent) None[source]#
leaveEvent(self, event: PySide2.QtCore.QEvent) None[source]#
mouseReleaseEvent(self, ev: PySide2.QtGui.QMouseEvent) None[source]#
paintEvent(self, arg__1: PySide2.QtGui.QPaintEvent) None[source]#
class bookmarks.ui.GalleryWidget(columns=5, item_height=common.size(common.size_row_height) * 2, label='Pick an item', parent=None)[source]#

Bases: QDialog

A generic gallery widget used to let the user pick an item.

itemSelected#

Emitted when the user clicks the item.

Type

Signal -> str

Methods:

init_data()

Initializes data.

item_generator()

Abstract method used to generate the values needed to display items.

paintEvent(self, event)

showEvent(event)

Show event handler.

init_data()[source]#

Initializes data.

item_generator()[source]#

Abstract method used to generate the values needed to display items.

Yields

tuple (str, str, str) – An informative label, user data and thumbnail image path.

paintEvent(self, event: PySide2.QtGui.QPaintEvent) None[source]#
showEvent(event)[source]#

Show event handler.

class bookmarks.ui.Label(text, color=common.color(common.color_secondary_text), parent=None)[source]#

Bases: QLabel

Methods:

enterEvent(event)

Event handler.

leaveEvent(event)

Event handler.

showEvent(event)

Event handler.

enterEvent(event)[source]#

Event handler.

leaveEvent(event)[source]#

Event handler.

showEvent(event)[source]#

Event handler.

class bookmarks.ui.LineEdit(parent=None)[source]#

Bases: QLineEdit

Custom line edit widget with a single underline.

class bookmarks.ui.ListOverlayWidget(parent=None)[source]#

Bases: QWidget

Widget used to display a status message over the list widget.

Methods:

paintEvent(event)

Custom paint event used to paint the widget's message.

paintEvent(event)[source]#

Custom paint event used to paint the widget’s message.

class bookmarks.ui.ListViewWidget(default_message='No items', default_icon='icon', parent=None)[source]#

Bases: QListView

A custom list widget used to display selectable item.

Methods:

eventFilter(widget, event)

Event filter handler.

mouseMoveEvent(self, e)

resizeEvent(self, e)

eventFilter(widget, event)[source]#

Event filter handler.

mouseMoveEvent(self, e: PySide2.QtGui.QMouseEvent) None[source]#
resizeEvent(self, e: PySide2.QtGui.QResizeEvent) None[source]#
class bookmarks.ui.ListWidget(default_message='No items', default_icon='icon', parent=None)[source]#

Bases: QListWidget

A custom list widget used to display selectable item.

Methods:

addItem(-> None)

eventFilter(widget, event)

Event filter handler.

resizeEvent(self, e)

addItem(self, item: PySide2.QtWidgets.QListWidgetItem) None[source]#
addItem(self, label: str) None
eventFilter(widget, event)[source]#

Event filter handler.

resizeEvent(self, e: PySide2.QtGui.QResizeEvent) None[source]#
class bookmarks.ui.ListWidgetDelegate[source]#

Bases: QStyledItemDelegate

Custom delegate to display label-like QListWidgetItems.

Methods:

createEditor(parent, option, index)

Custom editor for editing the template's name.

paint(self, painter, option, index)

sizeHint(self, option, index)

updateEditorGeometry(editor, option, index)

Updates the size of the editor widget.

createEditor(parent, option, index)[source]#

Custom editor for editing the template’s name.

paint(self, painter: PySide2.QtGui.QPainter, option: PySide2.QtWidgets.QStyleOptionViewItem, index: PySide2.QtCore.QModelIndex) None[source]#
sizeHint(self, option: PySide2.QtWidgets.QStyleOptionViewItem, index: PySide2.QtCore.QModelIndex) PySide2.QtCore.QSize[source]#
updateEditorGeometry(editor, option, index)[source]#

Updates the size of the editor widget.

class bookmarks.ui.MessageBox(*args, **kwargs)[source]#

Bases: QDialog

Informative message box used for notifying the user of an event.

buttonClicked#

Emitted when the user click a button.

Type

Signal -> str

Methods:

done(self, arg__1)

eventFilter(widget, event)

Event filter handler.

exec_(self)

hide(self)

open(self)

sizeHint()

Returns a size hint.

done(self, arg__1: int) None[source]#
eventFilter(widget, event)[source]#

Event filter handler.

exec_(self) int[source]#
hide(self) None[source]#
open(self) None[source]#
sizeHint()[source]#

Returns a size hint.

class bookmarks.ui.OkBox(*args, **kwargs)[source]#

Bases: MessageBox

Informative message box used for notifying the user of success.

class bookmarks.ui.PaintedButton(text, height=None, width=None, parent=None)[source]#

Bases: QPushButton

Custom button class.

Methods:

paintEvent(event)

Event handler.

paintEvent(event)[source]#

Event handler.

class bookmarks.ui.PaintedLabel(text, color=common.color(common.color_text), size=common.size(common.size_font_medium), parent=None)[source]#

Bases: QLabel

QLabel used for static aliased label.

Methods:

enterEvent(event)

Event handler.

leaveEvent(event)

Event handler.

paintEvent(event)

Event handler.

enterEvent(event)[source]#

Event handler.

leaveEvent(event)[source]#

Event handler.

paintEvent(event)[source]#

Event handler.

bookmarks.ui.add_description(text, label=' ', color=common.color(common.color_secondary_text), padding=common.size(common.size_margin), parent=None)[source]#

Utility method for adding a description field.

Returns

the added QLabel.

Return type

QLabel

bookmarks.ui.add_label(text, parent=None)[source]#

Utility method for creating a label.

Returns

label widget.

Return type

QLabel

bookmarks.ui.add_line_edit(label, parent=None)[source]#

Utility method for adding a line editor.

Returns

line editor widget.

Return type

QLineEdit

bookmarks.ui.add_row(label, color=common.color(common.color_secondary_text), padding=common.size(common.size_margin), height=common.size(common.size_row_height), cls=None, vertical=False, parent=None)[source]#

Utility method for creating a row widget.

Returns

The newly created row.

Return type

QWidget

bookmarks.ui.get_group(parent=None, vertical=True, margin=common.size(common.size_margin))[source]#

Utility method for creating a group widget.

Returns

group widget.

Return type

QGroupBox

bookmarks.ui.get_icon(name, color=common.color(common.color_disabled_text), size=common.size(common.size_row_height), opacity=1.0, resource=common.GuiResource)[source]#

Utility method for retuning a QIcon to use in the context menu.

Parameters
  • name (str) – The name of the icon.

  • color (QColor or None) – The color of the icon.

  • size (QtGui.QSize or None) – The size of the icon.

  • opacity (float) – The opacity of the icon.

  • resource (str) – The resource source for the icon.

Returns

The QIcon.

Return type

QtGui.QIcon

bookmarks.ui.paint_background_icon(name, widget)[source]#

Paints a decorative background icon to the middle of the given widget.

Parameters
  • name (str) – The image’s name.

  • widget (QWidget) – The widget to paint on.