Skip to content

main_window

_main_window

Custom main window widget.

Classes:

Name Description
FXMainWindow

Customized QMainWindow class.

Classes

FXMainWindow

FXMainWindow(
    parent: Optional[QWidget] = None,
    icon: Optional[str] = None,
    title: Optional[str] = None,
    size: Optional[Tuple[int, int]] = None,
    documentation: Optional[str] = None,
    project: Optional[str] = None,
    version: Optional[str] = None,
    company: Optional[str] = None,
    ui_file: Optional[str] = None,
    set_stylesheet: bool = True,
)

Bases: FXThemeAware, QMainWindow


              flowchart TD
              fxgui.fxwidgets._main_window.FXMainWindow[FXMainWindow]
              fxgui.fxstyle.FXThemeAware[FXThemeAware]

                              fxgui.fxstyle.FXThemeAware --> fxgui.fxwidgets._main_window.FXMainWindow
                


              click fxgui.fxwidgets._main_window.FXMainWindow href "" "fxgui.fxwidgets._main_window.FXMainWindow"
              click fxgui.fxstyle.FXThemeAware href "" "fxgui.fxstyle.FXThemeAware"
            

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
center_on_screen

Center the window on the primary screen.

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.

Functions
center_on_screen
center_on_screen() -> None

Center the window on the primary screen.

This method centers the window on the available screen geometry, accounting for taskbars and other system UI elements.

Examples:

>>> window = FXMainWindow()
>>> window.resize(800, 600)
>>> window.center_on_screen()
>>> window.show()
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: Optional[Union[QIcon, str]], size: int = 20) -> None

Sets the icon of the banner.

Parameters:

Name Type Description Default
icon Optional[Union[QIcon, str]]

The icon to set in the banner. Can be a QIcon or an icon name string for theme-aware icons.

required
size int

The size of the icon. Defaults to 20.

20
Note

Using an icon name string (e.g., "widgets") is recommended for theme-aware icons that automatically update when the theme changes.

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")