Main Area¶
Adding an own Widget¶
The MainArea
is a mdi (multi document interface). Therefore it’s
possible to display multiple widgets in it. The following example demonstrates
how to add a widget to the MDI area:
from PyQt5 import QtWidgets app = gui.GostyApp.Instance() main_area = app.perspective.main_area label = QtWidgets.QLabel("Hello World") main_area.AddWidget("The beginning..", label)
-
class
MainArea
¶ - It is implemented as a MDI (multi document interface). This allows you to add custom widgets to it.
-
AddPersistentWidget
(title, name, widget[, window_state])¶ Add a widget whose geometry is preserved across application relaunches. For widgets that are volatile, use
AddWidget()
If tabbed mode is enabled, the widget geometry is ignored.Parameters: - title (
str
) – string that is displayed in the gui. - name (
QWindowState
) – is the unique name (within the scope of the main area) for the widget that is used to restore and save the widget geometry. - widget (
QWidget
) – is the widget to be added to the main area. - window_state – custom window_state for the widget. See Qt Documentation to learn more about WindowStates.
- title (
-
AddPersistentWidget
(title, name, widget, width, height, x, y) - Add a widget whose geometry is preserved across application relaunches For widgets that are volatile, use #AddWidget() If tabbed mode is enabled, the widget geometry is ignored.
Parameters: - title (
str
) – string that is displayed in the gui - name (
str
) – is the unique name (within the scope of the main area) for the widget that is used to restore and save the widget geometry. - widget (
QWidget
) – is the widget to be added to the main area - width (
int
) – width of the widget inside the mdi - height (
int
) – height of the widget inside the mdi - x (
int
) – x position of the widget inside the mdi - y (
int
) – y position of the widget inside the mdi
- title (
-
AddWidget
(title, widget)¶ Add volatile widget.
Parameters: - title (
str
) – string that is displayed in the gui. - widget (
QWidget
) – is the widget to be added to the main area.
- title (
-
ShowSubWindow
(widget)¶ Display the given widget inside the main area. This method can be used to make a widget visible that has been added to the mdi area. This method should only be called if you are sure, that the widget has been added to the main area. Otherwise, there might be unexpected behavior!
Parameters: widget ( QWidget
) – widget which you want to make visible
-
HideSubWindow
(widget)¶ Brief hides the given widget inside the main area. This method can be used to hide a widget that has been added to this mdi area. This method should only be called if you are sure, that the widget has been added to the main area. Otherwise, there might be unexpected behavior!
Parameters: widget ( QWidget
) – widget which you want to hide
-
EnableTabbedMode
(tabbed_mode)¶ Brief switch between free window and tabbed window mode.
Parameters: tabbed_mode ( bool
) – whether you want to enable or disable the tabbed mode. Default is True.
-