Web Analytics Made Easy - Statcounter
Skip to content

Dynamic Layouts

Once you have used a layout to create a Window, you cannot change that layout directly. You also cannot use it in another Window. Once "used" a layout, the list of lists variable, can't be tampered with.

Adding To Layouts

You can add elements to a window by using the Window.extend_layout method to add new elements to a container element.

You can also delete an element by making the element invisible. Invisible elements are not deleted entirely, they are simply no longer a visible part of your window. You can make them visible again later should you want.

There are 2 calls that will enable you to make your layouts dynamic. One specifically modifies the layout for the Window. The other adds a new Tab to an existing tab.

Window.extend_layout

You can add onto any layout within the window. This includes container elements already in the window.

TabGroup.add_tab

The add_tab call is needed because using the extend_layout call will not enable you to add a Tab to a TabGroup. extand_layout will enable you to add to an existing Tab's layout, but you can't add a new Tab and thus need to use the add_tab call to add a new Tab.

Example - Adding and Deleting Items

FedExDemo

A simple example of a FedEx Package Tracking application shows one of the frequently used use cases for dynamic layouts. You will find this application in the Demo Programs. It's named Demo_Desktop_Widget_FedEx_Package_Tracking.py

Try It - Dynamic Layouts

This is a simplified version of the FedEx Package Tracking Demo Program that you can run and explore.

The basic concept is that a row of elements is added or deleted from the window. To add a row of elements you will add a single Column element. The Window.extend_layout method is called to add the Column element to an existing Column element that was in the window's original layout.

Deleting the row is accomplished by making the Column element invisible. To make any element invisible, you call the element's update method and set the parameter visible=False