1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335
|
Layout
================================================================================
.. currentmodule:: ost.gui
Most of the widgets are organized in a big main window which is divided into
four parts: the :class:`MainArea` and three panels (which are organized by the
:class:`PanelManager`) containing one or more smaller widgets:
.. image:: images/100208_OpenStructure_UI_Colored.png
The panels primarily contain widgets interacting with the 3D window.
Drag and Drop support
--------------------------------------------------------------------------------
The user interface of OpenStructure supports drag and drop events. Every file
format that is supported by Openstructure can be opened by dragging and dropping
it on the main window. When a Python script (ending with .py) is being dropped
on the UI, the script will be executed. For any other file type (for example PDB
files, images and density maps), OpenStructure will try to load the file and
display it in the 3D window, in the data viewer for images or in the sequence
viewer for sequences.
Perspective
--------------------------------------------------------------------------------
.. class:: Perspective
The perspective manages the layout of the widgets inside the main window.
It contains important classes which itself manages again a sub part of the whole layout.
You can get the active perspective object from the gosty app:
.. code-block:: python
app = gui.GostyApp.Instance()
perspective = app.perspective
.. method:: GetMainArea()
Returns the main area which is used in this perspective.
:rtype: :class:`MainArea`
.. method:: GetMenu(name)
Get QMenu that corresponds to the given name.
If it does not exist, it will be created and returned.
:param name: The name of the menu
:type arg2: :class:`str`
:rtype: :class:`QMenu`
.. method:: GetMenuBar()
Returns the Menubar of the Application. Can be used to add some menupoints.
:rtype: :class:`QMenuBar`
.. method:: GetPanels()
The PanelManager class organizes all the widgets in the side panels.
Returns the PanelManager instance which is used in this perspective.
:rtype: :class:`PanelManager`
.. method:: HideAllBars()
Hides all side bars. Can be used if the MainArea should be expanded to full size.
.. method:: StatusMessage(message)
Set a status message. This method can also be called from Qt as slot.
:param message: The message that will be displayed in the status bar.
:type message: :class:`str`
Main Area
--------------------------------------------------------------------------------
Adding an own Widget
^^^^^^^^^^^^^^^^^^^^
The :class:`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:
.. code-block:: python
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.
.. method:: AddPersistentWidget(title, name, widget [, window_state])
Add a widget whose geometry is preserved across application relaunches.
For widgets that are volatile, use :meth:`AddWidget`
If tabbed mode is enabled, the widget geometry is ignored.
:param title: string that is displayed in the gui.
:type title: :class:`str`
:param name: is the unique name (within the scope of the main area) for the widget that is used to restore and save the widget geometry.
:type name: :class:`str`
:param widget: is the widget to be added to the main area.
:type widget: :class:`QWidget`
:param window_state: custom window_state for the widget. See Qt Documentation to learn more about WindowStates.
:type name: :class:`QWindowState`
.. method:: AddPersistentWidget(title, name, widget, width, height, x, y)
:noindex:
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.
:param title: string that is displayed in the gui
:type title: :class:`str`
:param name: is the unique name (within the scope of the main area) for the widget that is used to restore and save the widget geometry.
:type name: :class:`str`
:param widget: is the widget to be added to the main area
:type widget: :class:`QWidget`
:param width: width of the widget inside the mdi
:type width: :class:`int`
:param height: height of the widget inside the mdi
:type height: :class:`int`
:param x: x position of the widget inside the mdi
:type x: :class:`int`
:param y: y position of the widget inside the mdi
:type y: :class:`int`
.. method:: AddWidget(title, widget)
Add volatile widget.
:param title: string that is displayed in the gui.
:type title: :class:`str`
:param widget: is the widget to be added to the main area.
:type widget: :class:`QWidget`
.. method:: 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!
:param widget: widget which you want to make visible
:type widget: :class:`QWidget`
.. method:: 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!
:param widget: widget which you want to hide
:type widget: :class:`QWidget`
.. method:: EnableTabbedMode(tabbed_mode)
Brief switch between free window and tabbed window mode.
:param tabbed_mode: whether you want to enable or disable the tabbed mode. Default is True.
:type tabbed_mode: :class:`bool`
Panels
--------------------------------------------------------------------------------
View Modes
^^^^^^^^^^
Each side panel can have different view modes. View modes can display the widgets
which are held by the Side Panel in a different style. Every panel has the
`splitter` and the `tabbed` view mode. The view mode can be changed in the Window
menu of the Menubar:
.. image:: images/100622_view_modes.png
Drag and Drop
^^^^^^^^^^^^^
The widgets which are held by a Side Panel can be moved to another position in
the panel or even to another side panel. The widget can be moved by simply
clicking on the border of the widget and drag and drop it to the desired position.
The drag and drop feature is currently supported by the splitter as well as the tabbed view mode.
Adding a custom Widget
^^^^^^^^^^^^^^^^^^^^^^
The Left-, Bottom- and Right Panel are organized by the
:class:`PanelManager`.
It is only possible to display a widget which is in the widget pool of the
PanelManager class. Once a widget is in the pool all the methods of the
PanelManager class can be used to display/hide the widget in any position
of the panels. OpenStructure remembers the size and location of a Widget
and thus OpenStructure should look the same after restarting it.
The following example shows, how to add a PyQt Widget to the widget pool
and finally display it in the right side bar:
.. code-block:: python
from PyQt5 import QtWidgets
qwidget = QtWidgets.QLabel("Test")
widget = gui.Widget(qwidget)
panels = gui.GostyApp.Instance().perspective.GetPanels()
panels.AddWidgetToPool("Test Label",widget)
panels.AddWidget(gui.PanelPosition.RIGHT_PANEL, widget)
.. class:: PanelManager
Class which organizes all widgets which are in the side panels
This class handles all side bar widgets. It can be used to display, hide or move a widget to a :class:`PanelBar`. There are three Bars (left, bottom, right) which are organized by this class.
Whenever a widget is being removed or added it checks first if the widget type is known and if there are available instances.
.. method:: AddWidget(pos, widget[, hidden])
Display a Widget in a PanelBar.
With this method you can add a widget to the given PanelBar. The widget which finally will be added to the gui will be created from the WidgetRegistry.
If the WidgetPool does not know the class name of the given widget or if there are no instances left, nothing will happen.
:param pos: Indicates which PanelBar is affected.
:type pos: :data:`PanelPosition`
:param widget: the widget will not directly added to the PanelBar. The class_name will be used to identify the widget in the WidgetRegistry which will return a fresh instance of this class.
:type arg3: :class:`int`
:param hidden: marks if the class should be displayed in the gui. Default the widget will be shown. By default False is set
:type hidden: bool
.. method:: AddWidgetByName(pos, class_name, hidden)
Display a Widget in a PanelBar
Same as :meth:`AddWidget`
:param pos: Indicates which PanelBar is affected.
:type pos: :class:`PanelPosition`
:param class_name: the class_name of the widget you would like to add.
:type class_name: :class:`str`
:param hidden: marks if the class should be displayed in the gui. Default the widget will be shown.
:type hidden: bool
.. method:: AddWidgetToPool(class_name, limit)
Add a widget to the widget pool.
The widget must already be in the WidgetRegistry.
If you are not sure if the Widget is in the WidgetRegistry, use the other `AddWidgetToPool` Method instead.
:param class_name: class name of class which should be added to the widget pool.
:type class_name: :class:`str`
:param limit: amount of parallel instances allowed (-1 if infinite)
:type limit: :class:`int`
.. method:: AddWidgetToPool(name, widget)
:noindex:
Add a widget to the widget pool. Same as :meth:`AddWidgetToPool`
:param name: Name which is displayed in the gui.
:type name: :class:`str`
:param widget: Widget which will be added to the WidgetPool of this class and the WidgetRegistry.
:type widget: :class:`Widget`
.. method:: GetMenu()
The GetMenu method returns a QMenu reference, which contains various actions. The action states will be updated automatically.
Returns a reference to a QMenu which can be used for example in a QMenuBar.
:rtype: :class:`QObject`
.. method:: GetQObject()
Get the SIP-QObject (QObject), learn more about :doc:`python_cpp`.
:rtype: :class:`QObject`
.. method:: RemoveWidget(widget)
Remove a Widget out of a PanelBar
The widget will be removed if it is in a PanelBar
:param arg2: widget which should be removed
:type arg2: :class:`Widget`
.. data:: PanelPosition
This enum indicates the Position of the Panel
* BOTTOM_PANEL
The bottom panel
* LEFT_PANEL
The left panel
* RIGHT_PANEL
The right panel
Menubar
--------------------------------------------------------------------------------
Adding an new Menupoint
^^^^^^^^^^^^^^^^^^^^^^^
It is really straightforward to add a custom menupoint. Since the menubar is
exported to Python it is even easier to create such e menupoint. The following example
describes how this is done within Python and PyQt:
.. code-block:: python
from PyQt5 import QtWidgets
menu_bar = gui.GostyApp.Instance().perspective.GetMenuBar()
test_action = QtWidgets.QAction('Test Menu Point', menu_bar)
test = menu_bar.addMenu('&Test')
test.addAction(test_action)
The MenuBar class is a normal Qt QMenubar (see the Qt Documentation for more information
about QMenubar). By getting the Menubar from the perspective, it is automatically
converted to a SIP Object which can be used within python.
The Inspector Gadget
--------------------------------------------------------------------------------
.. currentmodule:: ost.gui
With our Inspector Gadget it is straightforward to modify rendering and coloring
options of scene objects without using the keyboard:
.. image:: images/100614_Inspector_gadget.png
The render and coloring options affect only the currently selected objects of
the scene win. The Shortcut `Ctrl+I` toggles the visibility of the inspector.
|