singleton
_singleton
¶
Singleton metaclass for Qt widgets.
Classes:
| Name | Description |
|---|---|
FXSingleton |
Metaclass for Qt classes that are singletons. |
Classes¶
FXSingleton
¶
Bases: type(QObject)
flowchart TD
fxgui.fxwidgets._singleton.FXSingleton[FXSingleton]
click fxgui.fxwidgets._singleton.FXSingleton href "" "fxgui.fxwidgets._singleton.FXSingleton"
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. |