Aduct.add_to_notebook(element, notebook, position=-1)

Adds an element to the notebook at given position.

When the given element is already a child of some container, the function removes it from the parent and adds the notebook to parent. Then the orphan element is added to notebook at position.

  • element (Element) – The element to be added to notebook.
  • notebook (Notebook) – The notebook to which element has to be added
  • position (int) – The position at which element has to be inserted. When not provided, it takes up value of -1, which inserts the element as last page.

TypeError – When given element is not a Element.

Aduct.add_to_paned(child1, child2, paned, position)

Adds the children to given paned determined by position.

The main child child1 is added at first panel if position is 1 or second panel if position is 2. With respect to position of child1, child2 is added at the complement panel. When position is neither 1 nor 2, nothing is done. If child1 is already a child of parent, it is removed from the parent and paned is added back in its position. Then, the orphans child1 and child2 are added at requred places.

  • child1 (Gtk.Widget) – The main child which has to be added at given position.
  • child2 (Gtk.Widget) – The other child which has to be added at the complement of given position. It has to be an orphan.
  • paned (Paned) – The paned to which the children has to be added.
  • position (int) – An integer value that is either 1 or 2. The complement of 1 is 2 and vice-versa.
Aduct.add_to_view(child, view)

Adds a child to the view.

If child is not an orphan, it is removed from its parent and view is added back in its place. Then child is added to view.

  • child (Gtk.Widget or Aduct.Element.Element) – The child that has to be added to view. It has to be an orphan.
  • view (View) – The view to which child has to be added.


This function is given as a fall-back case and should never be used blindly without knowing the properties of child and view. When the view already has a child or requires more information about adding it, exceptions are raised. Still, the view may try its best to add the child at the possible place, only when it can.

Incase of view being a Notebook, it appends the child to the last position. But it requires child to be a Element. So at either case, you still have limitations that may end up in a weird result. For the same reasons, child has to be an orphan.

Aduct.change_child_at_element(element, provider, child_name)

Changes the child at given element with a child of given name provided by provider.

The previous child at element is cleared, after which the new child is added.

  • element (Element) – The element whose child has to be changed.
  • provider (Provider) – The provider that acts as source of child.
  • child_name (str) – The name of child to be added to element.

Gets the interface starting from the given top level.

Parameters:top_level (View) – A view which acts as the root widget.
Returns:A dictionary with properties to build interface.
Return type:dict
Aduct.remove_element(element, view)

Removes the given element from view.

When view is a Bin, it clears element. For other types of views, it removes element. Then, if the number of children in view is one, it replaces view with the other child of view.

  • element (Element) – The element to be removed.
  • view (View) – The view from which element has to be removed.
Aduct.replace_child(view, child1, child2)

Replaces the given child of a view with another child.

  • view (View) – The view whose child has to be replaced.
  • child1 (Gtk.Widget) – The child of given view which has to be replaced.
  • child2 (Gtk.Widget) – The child which replaces child1 in view.

TypeError – Raised when the given view is not a View

Aduct.set_interface(interface_dict, top_level, creator_maps, init_maps)

Sets the interface starting from given the top level.

  • interface_dict (dict) – A dictionary that can be used to set interface.
  • top_level (View) – The root widget from which the interface has to be set.
  • creator_maps (dict) – A dictionary of format {key: (func, args, kwargs)}, that is used to create the required object. The object is then created using func(*args, **kwargs) and is substitued as value in interface_dict which has key key.
  • init_maps (dict) – A dictionary of format {key: object} already initialized objects. The occurences of key in inerface_dict is then replaced with object.

The widget that was previous child of top_level, None if top_level has no child.

Return type: