fxwidgets
FXWidgets - Custom Qt widgets for fxgui.
This package provides a collection of custom Qt widgets built on top of qtpy, offering enhanced functionality and consistent styling for DCC applications.
All public classes are re-exported here for backward compatibility
from fxgui.fxwidgets import FXMainWindow, FXSplashScreen
Or import from the package directly
from fxgui import fxwidgets window = fxwidgets.FXMainWindow()
Classes:
| Name | Description |
|---|---|
FXApplication |
Customized QApplication class. |
FXCamelCaseValidator |
Validator for camelCase without special characters or numbers. |
FXCapitalizedLetterValidator |
Validator for names that must start with a capital letter and contain |
FXCollapsibleWidget |
A widget that can expand or collapse its content. |
FXColorLabelDelegate |
A custom delegate to paint items with specific colors and icons based |
FXElidedLabel |
A QLabel that elides text with '...' when it doesn't fit. |
FXFloatingDialog |
A floating dialog that appears at the cursor's position. |
FXIconLineEdit |
A line edit that displays an icon on the left or right side. |
FXLettersUnderscoreValidator |
Validator for letters and underscores, with optional numbers support. |
FXLowerCaseValidator |
Validator for lowercase letters only, with optional numbers and |
FXMainWindow |
Customized QMainWindow class. |
FXOutputLogHandler |
Custom logging handler that sends log messages to an output log widget. |
FXOutputLogWidget |
A reusable read-only output log widget for displaying application logs. |
FXPasswordLineEdit |
A custom widget that includes a password line edit with a show/hide button. |
FXResizedScrollArea |
A custom scroll area that emits a signal when resized. |
FXSingleton |
Metaclass for Qt classes that are singletons. |
FXSortedTreeWidgetItem |
Custom |
FXSplashScreen |
Customized QSplashScreen class. |
FXStatusBar |
Customized QStatusBar class. |
FXSystemTray |
A system tray icon with a context menu. |
FXThumbnailDelegate |
Custom item delegate for showing thumbnails in tree/list views. |
FXWidget |
|
FXApplication
Bases: QApplication
Customized QApplication class.
On initialization, the application loads the previously saved theme from persistent storage. If no theme was saved, defaults to "dark".
Methods:
| Name | Description |
|---|---|
instance |
Return the existing instance or create a new one if it doesn't |
FXCamelCaseValidator
Bases: QRegularExpressionValidator
Validator for camelCase without special characters or numbers.
This validator ensures input follows camelCase format: starts with a lowercase letter, followed by zero or more groups of an uppercase letter followed by lowercase letters.
Examples:
>>> from qtpy.QtWidgets import QLineEdit
>>> line_edit = QLineEdit()
>>> line_edit.setValidator(FXCamelCaseValidator())
FXCapitalizedLetterValidator
Bases: QValidator
Validator for names that must start with a capital letter and contain only letters.
This validator ensures the first character is uppercase and all characters are alphabetic.
Examples:
>>> from qtpy.QtWidgets import QLineEdit
>>> line_edit = QLineEdit()
>>> line_edit.setValidator(FXCapitalizedLetterValidator())
Methods:
| Name | Description |
|---|---|
fixup |
Automatically capitalize the first letter. |
validate |
Allow only letters and must start with a capital letter. |
FXCollapsibleWidget
Bases: QWidget
A widget that can expand or collapse its content.
The widget consists of a header with a toggle button and a content area that can be shown or hidden with an animation effect.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
Optional[QWidget]
|
Parent widget. |
None
|
|
str
|
Title displayed in the header. |
''
|
|
int
|
Duration of expand/collapse animation in ms. |
150
|
|
int
|
Maximum height for content area when expanded (0 = no limit). |
300
|
|
Optional[Union[QIcon, str]]
|
Optional icon to display before the title. Can be a QIcon, an icon name string (for fxicons), or None. |
None
|
Examples:
>>> from qtpy.QtWidgets import QLabel, QVBoxLayout
>>> collapsible = FXCollapsibleWidget(title="Settings")
>>> layout = QVBoxLayout()
>>> layout.addWidget(QLabel("Option 1"))
>>> layout.addWidget(QLabel("Option 2"))
>>> collapsible.set_content_layout(layout)
>>>
>>> # With an icon
>>> collapsible_with_icon = FXCollapsibleWidget(
... title="Settings",
... title_icon="settings"
... )
Methods:
| Name | Description |
|---|---|
__init__ |
Initialize the collapsible section. |
get_title |
Get the current title text. |
get_title_icon |
Get the current title icon. |
set_content_layout |
Set the layout for the content area. |
set_title |
Set the title text. |
set_title_icon |
Set an icon to display before the title. |
__init__
__init__(
parent: Optional[QWidget] = None,
title: str = "",
animation_duration: int = 150,
max_content_height: int = 300,
title_icon: Optional[Union[QIcon, str]] = None,
)
Initialize the collapsible section.
get_title
Get the current title text.
Returns:
| Type | Description |
|---|---|
str
|
The current title text. |
get_title_icon
Get the current title icon.
Returns:
| Type | Description |
|---|---|
Optional[QIcon]
|
The current title icon, or None if no icon is set. |
set_content_layout
set_content_layout(content_layout: QLayout) -> None
Set the layout for the content area.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
QLayout
|
The layout to set for the content area. |
required |
set_title
set_title(title: str) -> None
Set the title text.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
str
|
The title text to display. |
required |
set_title_icon
set_title_icon(icon: Union[QIcon, str, None]) -> None
Set an icon to display before the title.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
Union[QIcon, str, None]
|
The icon to display. Can be: - A QIcon instance - A string icon name (resolved via fxicons.get_icon) - None to remove the icon |
required |
Examples:
FXColorLabelDelegate
Bases: QStyledItemDelegate
A custom delegate to paint items with specific colors and icons based on their text content.
Methods:
| Name | Description |
|---|---|
__init__ |
Initializes the delegate with a dictionary of colors and icons. |
paint |
Paints the item with the specified colors and icons. |
sizeHint |
Provides the size hint for the item. |
__init__
__init__(
colors_icons: Dict[str, Tuple[QColor, QColor, QColor, QIcon, bool]],
parent: Optional[QWidget] = None,
margin_left: int = 2,
margin_top: Optional[int] = None,
margin_bottom: Optional[int] = None,
)
Initializes the delegate with a dictionary of colors and icons.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
Dict[str, Tuple[QColor, QColor, QColor, QIcon, bool]]
|
A dictionary where keys are text patterns and values are tuples containing background color, border color, text/icon color, icon, and a boolean indicating if the icon should be colored. |
required |
|
Optional[QWidget]
|
The parent object. |
None
|
|
int
|
The left margin for the text and icon. Defaults to 2. |
2
|
|
Optional[int]
|
The top margin for the text and icon. Defaults to
|
None
|
|
Optional[int]
|
The bottom margin for the text and icon. Defaults to
|
None
|
paint
Paints the item with the specified colors and icons.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
QPainter
|
The painter used to draw the item. |
required |
|
QStyleOptionViewItem
|
The style options for the item. |
required |
|
QModelIndex
|
The model index of the item. |
required |
sizeHint
Provides the size hint for the item.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
QStyleOptionViewItem
|
The style options for the item. |
required |
|
QModelIndex
|
The model index of the item. |
required |
Returns:
| Type | Description |
|---|---|
QSize
|
The size hint for the item. |
FXElidedLabel
Bases: QLabel
A QLabel that elides text with '...' when it doesn't fit.
This label automatically truncates text and adds an ellipsis when the text is too long to fit within the available space.
Methods:
| Name | Description |
|---|---|
resizeEvent |
Re-elide text when the label is resized. |
setText |
Set the text and store the full text for elision. |
FXFloatingDialog
Bases: QDialog
A floating dialog that appears at the cursor's position. It closes when any mouse button except the right one is pressed.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
QtWidget
|
Parent widget. Defaults to |
None
|
|
QPixmap
|
The QPixmap icon. |
None
|
|
str
|
The dialog title. |
None
|
Attributes:
| Name | Type | Description |
|---|---|---|
dialog_icon |
QIcon
|
The icon of the dialog. |
dialog_title |
str
|
The title of the dialog. |
drop_position |
QPoint
|
The drop position of the dialog. |
dialog_position |
Tuple[int, int]
|
The position of the dialog. |
parent_package |
int
|
Whether the dialog is standalone application, or belongs to a DCC parent. |
popup |
bool
|
Whether the dialog is a popup or not. |
Methods:
| Name | Description |
|---|---|
closeEvent |
Removes the parent of the dialog and closes it. |
mousePressEvent |
Closes the dialog when any mouse button except the right one is pressed. |
set_dialog_icon |
Sets the dialog's icon. |
set_dialog_title |
Sets the dialog's title. |
show_under_cursor |
Moves the dialog to the current cursor position and displays it. |
closeEvent
closeEvent(event: QCloseEvent) -> None
Removes the parent of the dialog and closes it.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
QCloseEvent
|
The close event. |
required |
mousePressEvent
mousePressEvent(event: QMouseEvent) -> None
Closes the dialog when any mouse button except the right one is pressed.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
QMouseEvent
|
The mouse press event. |
required |
set_dialog_icon
set_dialog_icon(icon: Optional[QPixmap] = None) -> None
Sets the dialog's icon.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
QPixmap
|
The QPixmap icon. |
None
|
set_dialog_title
set_dialog_title(title: str = None) -> None
Sets the dialog's title.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
str
|
The title of the dialog. |
None
|
FXIconLineEdit
Bases: QLineEdit
A line edit that displays an icon on the left or right side.
The icon is theme-aware and will refresh automatically when the application theme changes.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
Optional[str]
|
The name of the icon to display. |
None
|
|
str
|
The position of the icon ('left' or 'right'). |
'left'
|
|
Optional[QWidget]
|
The parent widget. |
None
|
Methods:
| Name | Description |
|---|---|
resizeEvent |
Reposition the icon when the line edit is resized. |
FXLettersUnderscoreValidator
Bases: QRegularExpressionValidator
Validator for letters and underscores, with optional numbers support.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
bool
|
If |
False
|
|
Optional[QWidget]
|
Parent widget. |
None
|
Examples:
>>> from qtpy.QtWidgets import QLineEdit
>>> line_edit = QLineEdit()
>>> line_edit.setValidator(FXLettersUnderscoreValidator(allow_numbers=True))
FXLowerCaseValidator
Bases: QRegularExpressionValidator
Validator for lowercase letters only, with optional numbers and underscores support.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
bool
|
If |
False
|
|
bool
|
If |
False
|
|
Optional[QWidget]
|
Parent widget. |
None
|
Examples:
>>> from qtpy.QtWidgets import QLineEdit
>>> line_edit = QLineEdit()
>>> line_edit.setValidator(FXLowerCaseValidator(allow_numbers=True))
FXMainWindow
Bases: QMainWindow
Customized QMainWindow class.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
QWidget
|
Parent widget. Defaults to |
None
|
|
str
|
Path to the window icon image. Defaults to |
None
|
|
str
|
Title of the window. Defaults to |
None
|
|
Tuple[int, int]
|
Window size as width and height.
Defaults to |
None
|
|
str
|
URL to the tool's documentation.
Defaults to |
None
|
|
str
|
Version label for the window.
Defaults to |
None
|
|
str
|
Company name for the window.
Defaults to |
None
|
|
str
|
Path to the UI file for loading.
Defaults to |
None
|
|
bool
|
Whether to set the default stylesheet.
Defaults to |
True
|
Methods:
| Name | Description |
|---|---|
get_available_themes |
Get a list of all available theme names. |
hide_banner |
Hides the banner. |
hide_status_line |
Hides the status line. |
setCentralWidget |
Overrides the QMainWindow's setCentralWidget method to ensure that the |
setWindowTitle |
Override the |
set_banner_icon |
Sets the icon of the banner. |
set_banner_text |
Sets the text of the banner. |
set_company_label |
Sets the company label in the status bar. |
set_project_label |
Sets the project label in the status bar. |
set_status_line_colors |
Set the colors of the status line. |
set_theme |
Set the theme of the window. |
set_ui_file |
Sets the UI file and loads the UI. |
set_version_label |
Sets the version label in the status bar. |
show_banner |
Shows the banner. |
show_status_line |
Shows the status line. |
statusBar |
Returns the FXStatusBar instance associated with this window. |
toggle_theme |
Toggle the theme of the window to the next available theme. |
get_available_themes
setCentralWidget
setCentralWidget(widget)
Overrides the QMainWindow's setCentralWidget method to ensure that the status line is always at the bottom of the window and the banner is always at the top.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
QWidget
|
The widget to set as the central widget. |
required |
Note
Overrides the base class method.
setWindowTitle
setWindowTitle(title: str) -> None
Override the setWindowTitle method to use _set_window_title.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
str
|
The new window title. |
required |
set_banner_icon
Sets the icon of the banner.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
QIcon
|
The icon to set in the banner. |
required |
|
int
|
The size of the icon. Defaults to 20. |
20
|
set_banner_text
set_banner_text(text: str) -> None
Sets the text of the banner.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
str
|
The text to set in the banner. |
required |
set_company_label
set_company_label(company: str) -> None
Sets the company label in the status bar.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
str
|
The company name. |
required |
Note
Overrides the base class method.
set_project_label
set_project_label(project: str) -> None
Sets the project label in the status bar.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
str
|
The project name. |
required |
Note
Overrides the base class method.
set_status_line_colors
Set the colors of the status line.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
str
|
The first color of the gradient. |
required |
|
str
|
The second color of the gradient. |
required |
set_theme
set_theme(theme: str) -> str
Set the theme of the window.
This method can be called from external code to apply a specific theme, including when running inside a DCC like Houdini, Maya, or Nuke where you don't have direct access to QApplication.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
str
|
The theme name to apply (e.g., "dark", "light", or custom). |
required |
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
The theme that was applied. |
Examples:
set_version_label
set_version_label(version: str) -> None
Sets the version label in the status bar.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
str
|
The version string. |
required |
Note
Overrides the base class method.
statusBar
statusBar() -> FXStatusBar
Returns the FXStatusBar instance associated with this window.
Returns:
| Name | Type | Description |
|---|---|---|
FXStatusBar |
FXStatusBar
|
The FXStatusBar instance associated with this window. |
Note
Overrides the base class method.
toggle_theme
Toggle the theme of the window to the next available theme.
This method can be called from external code to cycle through themes, including when running inside a DCC like Houdini, Maya, or Nuke where you don't have direct access to QApplication.
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
The new theme that was applied. |
Examples:
FXOutputLogHandler
Bases: Handler
Custom logging handler that sends log messages to an output log widget.
This handler is used internally by FXOutputLogWidget to capture
log messages and display them in the widget.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
FXOutputLogWidget
|
The |
required |
Methods:
| Name | Description |
|---|---|
emit |
Emit a log record to the output log widget. |
FXOutputLogWidget
Bases: QWidget
A reusable read-only output log widget for displaying application logs.
This widget provides a text display area that captures and shows logging output from the application. It supports ANSI color codes, search functionality, and log throttling for performance.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
Optional[QWidget]
|
Parent widget. |
None
|
|
bool
|
If |
False
|
Signals
log_message: Emitted when a log message is received (for thread-safe delivery).
Examples:
>>> from fxgui import fxwidgets
>>> log_widget = fxwidgets.FXOutputLogWidget(capture_output=True)
>>> log_widget.show()
Methods:
| Name | Description |
|---|---|
__init__ |
Initialize the output log widget. |
append_log |
Append text to the log output with ANSI color conversion. |
clear_log |
Clear the log output. |
closeEvent |
Handle widget close event to restore output streams. |
keyPressEvent |
Handle keyboard shortcuts. |
restore_output_streams |
Remove logging handler from all loggers where it was added. |
__init__
Initialize the output log widget.
append_log
append_log(text: str) -> None
Append text to the log output with ANSI color conversion.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
str
|
Text to append (may contain ANSI color codes). |
required |
closeEvent
Handle widget close event to restore output streams.
FXPasswordLineEdit
Bases: QWidget
A custom widget that includes a password line edit with a show/hide button.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
Optional[QWidget]
|
The parent widget. |
None
|
|
str
|
The position of the icon ('left' or 'right'). |
'right'
|
Methods:
| Name | Description |
|---|---|
toggle_reveal |
Toggles the echo mode between password and normal, and changes the |
FXResizedScrollArea
Bases: QScrollArea
A custom scroll area that emits a signal when resized.
This widget extends QScrollArea to emit a resized signal whenever
the widget is resized, which is useful for responsive layouts.
Signals
resized: Emitted when the scroll area is resized.
Examples:
Methods:
| Name | Description |
|---|---|
resizeEvent |
Emit the resized signal when the widget is resized. |
FXSingleton
Bases: type(QObject)
Metaclass for Qt classes that are singletons.
This metaclass ensures that only one instance of each class can exist. If an instance already exists, it returns the existing instance instead of creating a new one. Each subclass gets its own singleton instance.
Examples:
>>> from fxgui import fxwidgets
>>>
>>> class MySingletonWindow(fxwidgets.FXMainWindow, metaclass=fxwidgets.FXSingleton):
... pass
>>>
>>> window1 = MySingletonWindow()
>>> window2 = MySingletonWindow()
>>> assert window1 is window2 # Same instance
Methods:
| Name | Description |
|---|---|
reset_instance |
Reset the singleton instance. Useful for testing or cleanup. |
FXSortedTreeWidgetItem
Bases: QTreeWidgetItem
Custom QTreeWidgetItem that provides natural sorting for strings
containing numbers. This is useful for sorting items like version numbers
or other strings where numeric parts should be ordered numerically.
For example, this class will sort the following strings in the correct human-friendly order:
- "something1"
- "something9"
- "something17"
- "something25"
Instead of the default sorting order:
- "something1"
- "something17"
- "something25"
- "something9"
Methods:
| Name | Description |
|---|---|
__lt__ |
Override the less-than operator to provide a custom sorting logic. |
__lt__
__lt__(other: FXSortedTreeWidgetItem) -> bool
Override the less-than operator to provide a custom sorting logic.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
FXSortedTreeWidgetItem
|
Another instance of |
required |
Returns:
| Type | Description |
|---|---|
bool
|
|
bool
|
the natural sort order, |
FXSplashScreen
Bases: QSplashScreen
Customized QSplashScreen class.
Methods:
| Name | Description |
|---|---|
paintEvent |
Override to draw the pixmap with rounded corners. |
set_border |
Set the border around the splash screen. |
set_company_label |
Set the company name for the splash screen. |
set_corner_radius |
Set the corner radius for rounded corners. |
set_icon |
Set the icon for the splash screen. |
set_information_text |
Set the information text for the splash screen. |
set_overlay_opacity |
Set the opacity of the grey overlay background. |
set_pixmap |
Set the pixmap for the splash screen. |
set_progress |
Set the progress value for the splash screen. |
set_project_label |
Set the project name for the splash screen. |
set_title |
Set the title for the splash screen. |
set_version_label |
Set the version information for the splash screen. |
toggle_fade_in |
Toggle the fade-in effect for the splash screen. |
toggle_progress_bar_visibility |
Toggle the visibility of the progress bar. |
set_border
Set the border around the splash screen.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
int
|
The border width in pixels. Use 0 for no border. |
required |
|
str
|
The border color as a hex string. |
'#555555'
|
set_company_label
set_company_label(company: str) -> None
Set the company name for the splash screen.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
str
|
The company name. |
required |
set_corner_radius
set_corner_radius(radius: int) -> None
Set the corner radius for rounded corners.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
int
|
The corner radius in pixels. Use 0 for sharp corners. |
required |
set_icon
set_icon(icon_path: str) -> None
Set the icon for the splash screen.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
str
|
The path to the icon file. |
required |
set_information_text
set_information_text(information: str) -> None
Set the information text for the splash screen.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
str
|
The information text. |
required |
set_overlay_opacity
set_overlay_opacity(opacity: float) -> None
Set the opacity of the grey overlay background.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
float
|
The opacity value between 0.0 (transparent) and 1.0 (opaque). |
required |
set_pixmap
set_pixmap(image_path: str) -> None
Set the pixmap for the splash screen.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
str
|
The path to the image file. |
required |
set_progress
Set the progress value for the splash screen.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
int
|
The progress value. |
required |
|
int
|
The maximum progress value. Defaults to |
100
|
set_project_label
set_project_label(project: str) -> None
Set the project name for the splash screen.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
str
|
The project name. |
required |
set_title
set_title(title: str) -> None
Set the title for the splash screen.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
str
|
The title string. |
required |
set_version_label
set_version_label(version: str) -> None
Set the version information for the splash screen.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
str
|
The version string. |
required |
toggle_fade_in
toggle_fade_in(fade_in: bool) -> None
Toggle the fade-in effect for the splash screen.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
bool
|
Whether to fade in the splash screen. |
required |
toggle_progress_bar_visibility
toggle_progress_bar_visibility(show: bool) -> None
Toggle the visibility of the progress bar.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
bool
|
Whether to show the progress bar. |
required |
FXStatusBar
Bases: QStatusBar
Customized QStatusBar class.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
QWidget
|
Parent widget. Defaults to |
None
|
|
str
|
Project name. Defaults to |
None
|
|
str
|
Version information. Defaults to |
None
|
|
str
|
Company name. Defaults to |
None
|
Attributes:
| Name | Type | Description |
|---|---|---|
project |
str
|
The project name. |
version |
str
|
The version string. |
company |
str
|
The company name. |
icon_label |
QLabel
|
The icon label. |
message_label |
QLabel
|
The message label. |
project_label |
QLabel
|
The project label. |
version_label |
QLabel
|
The version label. |
company_label |
QLabel
|
The company label. |
Methods:
| Name | Description |
|---|---|
clearMessage |
Clears the message from the status bar. |
hide_status_line |
Hide the status line and border line. |
resizeEvent |
Handle resize to position the status line and border correctly. |
set_status_line_colors |
Set the status line gradient colors. |
showMessage |
Display a message in the status bar with a specified severity. |
show_status_line |
Show the status line and border line. |
clearMessage
Clears the message from the status bar.
Note
Overrides the base class method.
resizeEvent
Handle resize to position the status line and border correctly.
set_status_line_colors
Set the status line gradient colors.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
str
|
The first color of the gradient. |
required |
|
str
|
The second color of the gradient. |
required |
showMessage
showMessage(
message: str,
severity_type: int = 4,
duration: float = 2.5,
time: bool = True,
logger: Optional[Logger] = None,
set_color: bool = True,
pixmap: Optional[QPixmap] = None,
background_color: Optional[str] = None,
)
Display a message in the status bar with a specified severity.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
str
|
The message to be displayed. |
required |
|
int
|
The severity level of the message.
Should be one of |
4
|
|
float
|
The duration in seconds for which
the message should be displayed. Defaults to |
2.5
|
|
bool
|
Whether to display the current time before
the message. Defaults to |
True
|
|
Logger
|
A logger object to log the message.
Defaults to |
None
|
|
bool
|
Whether to set the status bar color depending on
the log verbosity. Defaults to |
True
|
|
QPixmap
|
A custom pixmap to be displayed in the
status bar. Defaults to |
None
|
|
str
|
A custom background color for
the status bar. Defaults to |
None
|
Examples:
To display a critical error message with a red background
>>> self.showMessage(
... "Critical error occurred!",
... severity_type=self.CRITICAL,
... duration=5,
... logger=my_logger,
... )
Note
You can either use the FXMainWindow instance to retrieve the
verbosity constants, or the fxwidgets module.
Overrides the base class method.
FXSystemTray
Bases: QObject
A system tray icon with a context menu.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
QWidget
|
The parent widget. Defaults to None. |
None
|
|
str
|
The icon path. Defaults to None. |
None
|
Attributes:
| Name | Type | Description |
|---|---|---|
tray_icon |
QSystemTrayIcon
|
The system tray icon. |
quit_action |
QAction
|
The action to quit the application. |
tray_menu |
QMenu
|
The tray menu. |
Methods:
| Name | Description |
|---|---|
show |
Shows the system tray icon. |
on_tray_icon_activated |
Shows the tray menu above the taskbar. |
closeEvent |
Closes the application. |
Examples:
>>> app = FXApplication()
>>> system_tray = FXSystemTray()
>>> hello_action = QAction(
... fxicons.get_icon("visibility"), "Set Project", system_tray
... )
>>> system_tray.tray_menu.insertAction(
... system_tray.quit_action, hello_action
... )
>>> system_tray.tray_menu.insertSeparator(system_tray.quit_action)
>>> system_tray.show()
>>> app.exec_()
Note
Inherits from QObject, not QSystemTrayIcon.
add_action
add_action(action: QAction) -> None
Adds an action to the tray menu.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
QAction
|
The action to add to the tray menu. |
required |
set_icon
set_icon(icon_path: str) -> None
Sets a new icon for the system tray.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
str
|
The path to the new icon. |
required |
FXThumbnailDelegate
Bases: QStyledItemDelegate
Custom item delegate for showing thumbnails in tree/list views.
This delegate displays items with thumbnails, titles, descriptions, and status indicators. It supports Markdown formatting in descriptions and tooltips.
Note
Store data in items using the following roles:
- Qt.UserRole + 1 (bool): Whether to show the thumbnail.
- Qt.UserRole + 2 (str): Path to the thumbnail image.
- Qt.UserRole + 3 (str): Description text (supports Markdown).
- Qt.UserRole + 4 (QColor): Status dot indicator color.
- Qt.UserRole + 5 (QColor): Status label background color.
- Qt.UserRole + 6 (str): Status label text.
- Qt.UserRole + 7 (bool): Whether to show the status dot.
- Qt.UserRole + 8 (bool): Whether to show the status label.
Properties
show_thumbnail: Whether to show thumbnails globally. show_status_dot: Whether to show the status dot indicator globally. show_status_label: Whether to show the status label globally.
Note
Global properties and per-item roles work together: - An element is shown only if BOTH global property is True AND per-item role is True (or None/unset). - Setting per-item role to False hides that element for that item.
Examples:
>>> from fxgui import fxwidgets
>>> from qtpy.QtWidgets import QTreeWidget, QTreeWidgetItem
>>> from qtpy.QtCore import Qt
>>> from qtpy.QtGui import QColor
>>>
>>> tree = QTreeWidget()
>>> delegate = fxwidgets.FXThumbnailDelegate()
>>> delegate.show_thumbnail = True
>>> delegate.show_status_dot = True
>>> delegate.show_status_label = True
>>> tree.setItemDelegate(delegate)
>>>
>>> item = QTreeWidgetItem(tree, ["My Item"])
>>> item.setData(0, fxwidgets.FXThumbnailDelegate.THUMBNAIL_VISIBLE_ROLE, True)
>>> item.setData(0, fxwidgets.FXThumbnailDelegate.THUMBNAIL_PATH_ROLE, "/path/to/image.png")
>>> item.setData(0, fxwidgets.FXThumbnailDelegate.DESCRIPTION_ROLE, "**Bold** description")
>>> item.setData(0, fxwidgets.FXThumbnailDelegate.STATUS_DOT_COLOR_ROLE, QColor("green"))
>>> # Hide status dot for this specific item
>>> item.setData(0, fxwidgets.FXThumbnailDelegate.STATUS_DOT_VISIBLE_ROLE, False)
Methods:
| Name | Description |
|---|---|
__init__ |
Initialize the thumbnail delegate. |
helpEvent |
Provide Markdown-formatted tooltips. |
markdown_to_html |
Convert Markdown text to HTML. |
markdown_to_plain_text |
Convert Markdown text to plain text by removing formatting. |
paint |
Paint the item at the given index. |
sizeHint |
Return the size hint for the item at the given index. |
Attributes:
| Name | Type | Description |
|---|---|---|
show_status_dot |
bool
|
Whether the status dot is shown. |
show_status_label |
bool
|
Whether the status label is shown. |
show_thumbnail |
bool
|
Whether thumbnails are shown globally. |
show_thumbnail
property
writable
Whether thumbnails are shown globally.
Individual items can override via THUMBNAIL_VISIBLE_ROLE.
__init__
__init__(parent: Optional[QWidget] = None)
Initialize the thumbnail delegate.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
Optional[QWidget]
|
The parent widget. |
None
|
helpEvent
Provide Markdown-formatted tooltips.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
The help event. |
required | |
|
The view widget. |
required | |
|
QStyleOptionViewItem
|
Style options. |
required |
|
QModelIndex
|
The model index. |
required |
Returns:
| Type | Description |
|---|---|
bool
|
True if the event was handled. |
markdown_to_html
staticmethod
markdown_to_html(text: str) -> str
Convert Markdown text to HTML.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
str
|
Markdown-formatted text. |
required |
Returns:
| Type | Description |
|---|---|
str
|
HTML-formatted text. |
markdown_to_plain_text
staticmethod
markdown_to_plain_text(text: str) -> str
Convert Markdown text to plain text by removing formatting.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
str
|
Markdown-formatted text. |
required |
Returns:
| Type | Description |
|---|---|
str
|
Plain text with Markdown formatting removed. |
paint
Paint the item at the given index.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
QPainter
|
The painter to use for drawing. |
required |
|
QStyleOptionViewItem
|
The style options for the item. |
required |
|
QModelIndex
|
The model index of the item. |
required |
sizeHint
Return the size hint for the item at the given index.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
QStyleOptionViewItem
|
The style options for the item. |
required |
|
QModelIndex
|
The model index of the item. |
required |
Returns:
| Type | Description |
|---|---|
QSize
|
The size hint for the item. |
FXWidget
Bases: QWidget