PySide Advanced Examples/en

Introduction
The purpose of this page is to cover advanced level examples of the PySide GUI manager (there are accompanying pages PySide Beginner Examples and PySide Intermediate Examples).

By using the PySide module from inside FreeCAD, you have full control over its interface. You can for example:
 * Add your own panels, widgets and toolbars
 * Add or hide elements to existing panels
 * Change, redirect or add connections between all those elements

Create Reference to the Main Window
If you want to work on the FreeCAD interface, the very first thing to do is create a reference to the FreeCAD main window:

Browse the Children of the Main Window
Then, you can for example browse through all the widgets of the interface:

The widgets in a Qt interface are usually nested into "container" widgets, so the children of our main window can themselves contain other children. Depending on the widget type, there are a lot of things you can do. Check the API documentation to see what is possible.

Add New Widget Manually
Adding a new widget, for example a dockWidget (which can be placed in one of FreeCAD's side panels) is easy:

You could then add stuff directly to your widget:

Add New Widget by Creating UI Object
But a preferred method is to create a UI object which will do all of the setup of your widget at once. The big advantage is that such an UI object can be created graphically with the Qt Designer program. A typical object generated by Qt Designer is like this:

To use it, you just need to apply it to your freshly created widget like this:

Loading the UI from a Qt Designer .ui File
The key to loading a UI file successfully is to use the full path to the file. As an example, the Addon Manager does it like this: