Switching layouts

We now have two layouts:

  1. Select crop type layout
  2. View crop status layout

Our interface must be able to switch between these layouts to produce the required functionality for our program. The switch between layouts occurs as the user presses the "Create simulation" button:

Interface design

To switch between the layouts we need to keep track of them both. Thankfully, PyQt provides a widget that does just that: QStackedLayout. This widget functions as you would expect, it keeps a list of all the available layouts and enables you to decide which one of the layouts is visible (i.e. at the top of the stack).

Therefore, when the user presses the "Create simulation" button not only will they instantiate the required crop type but they will tell the stacked layout to change which layout is visible at the top of the stack.

The video demonstrates this.

Task 3b

Use the above video to add the ability to switch between the layouts.