Creating the layouts

Creating the crop selection layout

Now that we have the RadioButtonWidget() class we are ready to start thinking about the crop selection layout itself. Remember, the design is as follows:

The video below demonstrates how to construct the layout and to test to ensure that it displays correctly.

Task 2b

Use the above video to help you construct the crop selection layout.

Instantiating the crops

Now that we have created a the crop selection layout and tested it to ensure it displays correctly we must add the actual functionality to this interface.

When you click the Create Crop button, a crop of selected type should be instantiated. To do this we must connect the event of pressing the button to a method that will perform the necessary action to instantiate the crop.

The video below demonstrates how to do this.

Task 2c

Use the above video to add the ability to instantiate a crop from the user interface.

Creating the crop status view layout

The second layout our interface requires needs to monitor the status of the crop and to enable the user to grow the crop either automatically or manually. In our design it looks as follows:

It terms of layouts, a vertical layout would not be sufficient as there are two clear columns of widgets. We will need a grid layout for this interface.

In PyQt a grid layout is indexed from the top-left hand-side cell and the indexing begins at zero. In this grid we will have the following widgets:

(0,0) - A picture (QGraphicsView)

(1,0) - A button (QPushButton)

(1,1) - A button (QPushButton)

Cell (0,1) is more interesting as it needs to contain six different widgets:

Three labels (QLabel) to indicate growth, number of growing days and current status

Three text boxes (QLineEdit) to give the values associated with the labels