fxwidgets
Scripts related to the QtWidgets module.
FXApplication
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 |
---|---|---|---|
parent |
QtWidget
|
Parent widget. Defaults to |
None
|
icon |
QPixmap
|
The QPixmap icon. |
None
|
title |
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. |
closeEvent
Removes the parent of the dialog and closes it.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
event |
QCloseEvent
|
The close event. |
required |
mousePressEvent
Closes the dialog when any mouse button except the right one is pressed.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
event |
QMouseEvent
|
The mouse press event. |
required |
set_dialog_icon
Sets the dialog's icon.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
icon |
QPixmap
|
The QPixmap icon. |
None
|
set_dialog_title
Sets the dialog's title.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
title |
str
|
The title of the dialog. |
None
|
FXMainWindow
Bases: QMainWindow
Customized QMainWindow class.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
parent |
QWidget
|
Parent widget. Defaults to |
None
|
icon |
str
|
Path to the window icon image. Defaults to |
None
|
title |
str
|
Title of the window. Defaults to |
None
|
size |
Tuple[int, int]
|
Window size as width and height.
Defaults to |
None
|
documentation |
str
|
URL to the tool's documentation.
Defaults to |
None
|
version |
str
|
Version label for the window.
Defaults to |
None
|
company |
str
|
Company name for the window.
Defaults to |
None
|
color_a |
str
|
Color to be applied to the window.
Defaults to |
None
|
color_b |
str
|
Color to be applied to the window.
Defaults to |
None
|
ui_file |
str
|
Path to the UI file for loading.
Defaults to |
None
|
Attributes:
Name | Type | Description |
---|---|---|
window_icon |
QIcon
|
The icon of the window. |
window_title |
str
|
The title of the window. |
window_size |
QSize
|
The size of the window. |
window_flags |
WindowFlags
|
The window flags. |
documentation |
str
|
The documentation string. |
project |
str
|
The project name. |
version |
str
|
The version string. |
company |
str
|
The company name. |
color_a |
str
|
The color A. |
color_b |
str
|
The color B. |
ui_file |
str
|
The UI file path. |
ui |
QWidget
|
The loaded UI from the UI file. Note that this attribute
is only accessible if you're defining a UI file through |
CRITICAL |
int
|
Constant for critical log level. |
ERROR |
int
|
Constant for error log level. |
WARNING |
int
|
Constant for warning log level. |
SUCCESS |
int
|
Constant for success log level. |
INFO |
int
|
Constant for info log level. |
about_action |
QAction
|
Action for the "About" menu item. |
hide_action |
QAction
|
Action for the "Hide" menu item. |
hide_others_action |
QAction
|
Action for the "Hide Others" menu item. |
close_action |
QAction
|
Action for the "Close" menu item. |
check_updates_action |
QAction
|
Action for the "Check for Updates..." menu item. |
settings_action |
QAction
|
Action for the "Settings" menu item. |
window_on_top_action |
QAction
|
Action for the "Always On Top" menu item. |
minimize_window_action |
QAction
|
Action for the "Minimize" menu item. |
maximize_window_action |
QAction
|
Action for the "Maximize" menu item. |
open_documentation_action |
QAction
|
Action for the "Documentation" menu item. |
previous_action |
QAction
|
Action for the "Previous" toolbar item. |
next_action |
QAction
|
Action for the "Next" toolbar item. |
refresh_action |
QAction
|
Action for the "Refresh" toolbar item. |
home_action |
QAction
|
Action for the "Home" toolbar item. |
menu_bar |
QMenuBar
|
The menu bar of the window. |
icon_menu |
QMenu
|
The icon menu of the menu bar. |
main_menu |
QMenu
|
The main menu of the menu bar. |
about_menu |
QAction
|
The "About" menu item in the main menu. |
check_updates_menu |
QAction
|
The "Check for Updates..." menu item in the main menu. |
close_menu |
QAction
|
The "Close" menu item in the main menu. |
hide_main_menu |
QAction
|
The "Hide" menu item in the main menu. |
hide_others_menu |
QAction
|
The "Hide Others" menu item in the main menu. |
edit_menu |
QMenu
|
The edit menu of the menu bar. |
settings_menu |
QAction
|
The "Settings" menu item in the edit menu. |
window_menu |
QMenu
|
The window menu of the menu bar. |
minimize_menu |
QAction
|
The "Minimize" menu item in the window menu. |
maximize_menu |
QAction
|
The "Maximize" menu item in the window menu. |
on_top_menu |
QAction
|
The "Always On Top" menu item in the window menu. |
help_menu |
QMenu
|
The help menu of the menu bar. |
open_documentation_menu |
QAction
|
The "Documentation" menu item in the help menu. |
toolbar |
QToolBar
|
The toolbar of the window. |
previous_toolbar |
QAction
|
The "Previous" toolbar item. |
next_toolbar |
QAction
|
The "Next" toolbar item. |
refresh_toolbar |
QAction
|
The "Refresh" toolbar item. |
home_toolbar |
QAction
|
The "Home" toolbar item. |
about_dialog |
QDialog
|
The "About" dialog. |
banner |
QLabel
|
The banner of the window. |
status_line |
QFrame
|
A custom colored status line resting on top of the status bar. |
status_bar |
FXStatusBar
|
The status bar of the window. |
project_label |
QLabel
|
The project label in the status bar. |
version_label |
QLabel
|
The version label in the status bar. |
company_label |
QLabel
|
The company label in the status bar. |
Examples:
Outside a DCC (standalone)
>>> application = fxgui.FXApplication()
>>> window = fxwidgets.FXMainWindow(
... icon="path/to/icon.png",
... title="My Custom Window",
... size=(800, 600),
... documentation="https://my_tool_docs.com",
... project="Awesome Project",
... version="v1.0.0",
... company="© Super Company",
... version="v1.0.0",
... ui_file="path/to/ui_file.ui",
... )
>>> window.show()
>>> window.set_statusbar_message("Window initialized", window.INFO)
>>> sys.exit(app.exec_())
Inside a DCC (Houdini)
>>> houdini_window = fxdcc.get_houdini_main_window()
>>> window = fxwidgets.FXMainWindow(
... parent=houdini_window,
... ui_file="path/to/ui_file.ui",
... )
>>> window.show()
>>> window.set_statusbar_message("Window initialized", window.INFO)
Inside a DCC (Houdini), hide toolbar, menu bar ans status bar
>>> houdini_window = fxdcc.get_houdini_main_window()
>>> window = fxwidgets.FXMainWindow(
... parent=houdini_window,
... ui_file="path/to/ui_file.ui",
... )
>>> window.toolbar.hide()
>>> window.menu_bar.hide()
>>> window.status_bar.hide()
>>> window.show()
Inside a DCC (Houdini), override the fxgui
stylesheet with the Houdini one
>>> houdini_window = fxdcc.get_houdini_main_window()
>>> window = fxwidgets.FXMainWindow(
... parent=houdini_window,
... ui_file="path/to/ui_file.ui",
... )
>>> window.setStyleSheet(hou.qt.styleSheet())
>>> window.show()
>>> window.set_statusbar_message("Window initialized", window.INFO)
setCentralWidget
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 |
---|---|---|---|
widget |
QWidget
|
The widget to set as the central widget. |
required |
Note
Overrides the base class method.
setWindowTitle
Override the setWindowTitle
method to use _set_window_title
.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
title |
str
|
The new window title. |
required |
set_banner_text
Sets the text of the banner.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
text |
str
|
The text to set in the banner. |
required |
set_colors
Sets the accent color of the window.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
color_a |
str
|
The first color. |
required |
color_b |
str
|
The second color. |
required |
set_company_label
Sets the company label in the status bar.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
company |
str
|
The company name. |
required |
Note
Overrides the base class method.
set_project_label
Sets the project label in the status bar.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
project |
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 |
---|---|---|---|
color_a |
str
|
The first color of the gradient. |
required |
color_b |
str
|
The second color of the gradient. |
required |
set_version_label
Sets the version label in the status bar.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
version |
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.
FXPasswordLineEdit
FXSplashScreen
Bases: QSplashScreen
Customized QSplashScreen class.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
image_path |
str
|
Path to the image to be displayed on the splash screen. |
None
|
icon |
str
|
Path to the icon to be displayed on the splash screen. |
None
|
title |
str
|
Title text to be displayed. Defaults to
|
None
|
information |
str
|
Information text to be displayed. Defaults to a placeholder text. |
None
|
show_progress_bar |
bool
|
Whether to display a progress bar. Defaults to False. |
False
|
project |
str
|
Project name. Defaults to |
None
|
version |
str
|
Version information. Defaults to |
None
|
company |
str
|
Company name. Defaults to |
None
|
color_a |
str
|
Color A to be applied to the splash
screen. Defaults to |
_COLOR_A_DEFAULT
|
color_b |
str
|
Color B to be applied to the splash
screen. Defaults to |
_COLOR_B_DEFAULT
|
fade_in |
bool
|
Whether to apply a fade-in effect on the splash screen. Defaults to False. |
False
|
Attributes:
Name | Type | Description |
---|---|---|
pixmap |
QPixmap
|
The image on the splash screen. Dewfaults to
|
icon |
QIcon
|
The icon of the splash screen. Defaults to |
title |
str
|
Title text to be displayed. Defaults to |
information |
str
|
Information text to be displayed. Defaults to a placeholder Lorem Ipsum text. |
show_progress_bar |
bool
|
Whether to display a progress bar.
Defaults to |
project |
str
|
Project name. Defaults to |
version |
str
|
Version information. Defaults to |
company |
str
|
Company name. Defaults to |
color_a |
str
|
Color A applied to the splash screen. |
color_b |
str
|
Color B applied to the splash screen. |
fade_in |
bool
|
Whether to apply a fade-in effect on the
splash screen. Defaults to |
title_label |
QLabel
|
Label for the title text. |
info_label |
QLabel
|
Label for the information text. |
progress_bar |
QProgressBar
|
Progress bar widget. Only created if
|
copyright_label |
QLabel
|
Label for the copyright information. |
fade_timer |
QTimer
|
Timer for the fade-in effect. Only created if
|
Examples:
>>> app = QApplication(sys.argv)
>>> splash = FXSplashScreen(
... image_path="path_to_your_image.png",
... title="My Awesome App",
... information="Loading...",
... show_progress_bar=True,
... project="Cool Project",
... version="v1.2.3",
... company="My Company Ltd.",
... fade_in=True,
... )
>>> splash.progress(50)
>>> splash.show()
>>> splash.progress(100)
>>> splash.close()
>>> sys.exit(app.exec_())
FXStatusBar
Bases: QStatusBar
Customized QStatusBar class.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
parent |
QWidget
|
Parent widget. Defaults to |
None
|
project |
str
|
Project name. Defaults to |
None
|
version |
str
|
Version information. Defaults to |
None
|
company |
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. |
clearMessage
Clears the message from the status bar.
Note
Overrides the base class method.
showMessage
showMessage(
message: str,
severity_type: int = 4,
duration: float = 2.5,
time: bool = True,
logger: Optional[Logger] = None,
set_color: bool = True,
)
Display a message in the status bar with a specified severity.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
message |
str
|
The message to be displayed. |
required |
severity_type |
int
|
The severity level of the message.
Should be one of |
4
|
duration |
float
|
The duration in seconds for which
the message should be displayed. Defaults to |
2.5
|
time |
bool
|
Whether to display the current time before
the message. Defaults to |
True
|
logger |
Logger
|
A logger object to log the message.
Defaults to |
None
|
set_color |
bool
|
Wheter to set the status bar color depending on the log
verbosity. Defaults to |
True
|
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 |
---|---|---|---|
parent |
QWidget
|
The parent widget. Defaults to None. |
None
|
icon |
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("perm_media"), "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.
FXWidget
Bases: QWidget