Skip to content

Main Window

An enhanced QMainWindow with built-in theme support, status bar, and DCC integration.

Preview

FXMainWindow

FXMainWindow

Bases: FXThemeAware, QMainWindow

Customized QMainWindow class.

Parameters:

Name Type Description Default

parent

QWidget

Parent widget. Defaults to hou.qt.mainWindow().

None

icon

str

Path to the window icon image. Defaults to None.

None

title

str

Title of the window. Defaults to None.

None

size

Tuple[int, int]

Window size as width and height. Defaults to None.

None

documentation

str

URL to the tool's documentation. Defaults to None.

None

version

str

Version label for the window. Defaults to None.

None

company

str

Company name for the window. Defaults to Company.

None

ui_file

str

Path to the UI file for loading. Defaults to None.

None

set_stylesheet

bool

Whether to set the default stylesheet. Defaults to True.

True

Methods:

Name Description
closeEvent

Handle the window close event.

get_available_themes

Get a list of all available theme names.

hide_banner

Hides the banner.

hide_status_line

Hides the status line.

setCentralWidget

Override the QMainWindow's setCentralWidget method.

setWindowTitle

Override the setWindowTitle method.

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.

closeEvent

closeEvent(event: QCloseEvent) -> None

Handle the window close event.

Parameters:

Name Type Description Default

event

QCloseEvent

The close event.

required

get_available_themes

get_available_themes() -> List[str]

Get a list of all available theme names.

Returns:

Type Description
List[str]

List[str]: List of theme names (e.g., ["dark", "light"]).

Examples:

>>> window = FXMainWindow()
>>> themes = window.get_available_themes()
>>> print(themes)  # ['dark', 'light']

hide_banner

hide_banner() -> None

Hides the banner.

hide_status_line

hide_status_line() -> None

Hides the status line.

setCentralWidget

setCentralWidget(widget: QWidget) -> None

Override the QMainWindow's setCentralWidget method.

Ensures 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

setWindowTitle(title: str) -> None

Override the setWindowTitle method.

Parameters:

Name Type Description Default

title

str

The new window title.

required

set_banner_icon

set_banner_icon(icon: QIcon, size: int = 20) -> None

Sets the icon of the banner.

Parameters:

Name Type Description Default

icon

QIcon

The icon to set in the banner.

required

size

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

text

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

company

str

The company name.

required

set_project_label

set_project_label(project: str) -> None

Sets the project label in the status bar.

Parameters:

Name Type Description Default

project

str

The project name.

required

set_status_line_colors

set_status_line_colors(color_a: str, color_b: str) -> None

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_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

theme

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:

>>> window = FXMainWindow()
>>> window.show()
>>> window.set_theme("light")
>>> window.set_theme("dark")

set_ui_file

set_ui_file(ui_file: str) -> None

Sets the UI file and loads the UI.

Parameters:

Name Type Description Default

ui_file

str

Path to the UI file to load.

required

set_version_label

set_version_label(version: str) -> None

Sets the version label in the status bar.

Parameters:

Name Type Description Default

version

str

The version string.

required

show_banner

show_banner() -> None

Shows the banner.

show_status_line

show_status_line() -> None

Shows the status line.

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_theme() -> str

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:

>>> window = FXMainWindow()
>>> window.show()
>>> new_theme = window.toggle_theme()
>>> print(f"Switched to {new_theme} theme")