Coding the interface

As we will be using Kivy, you can go to https://kivy.org/ and review the installation instructions.Depending on your OS, and whether you're using a virtual Python environment, Łand other factors, there are different ways to install the software.

By default, Kivy applications are designed to scale according to the device or the user's desires. If we were to allow this, we would have to hand-draw the schematic drawing within Kivy, or otherwise create the HMI from scratch. If we used the schematic drawing as a background image and placed widgets on top, the widgets would not maintain the same position relative to the schematic drawing when scaled.

Having a scalable image is the most desirable option, but for the purpose of this book, we will use the schematic drawing as a background image and block scaling. Therefore, any widgets that we place on top of the schematic drawing won't have to worry about the drawing moving underneath them.

As this is not a Kivy-specific book, we will only cover the fundamental Kivy processes necessary to code the fuel farm GUI. We will talk about two specific files in this chapter: hmi.kv and hmilayout.py. They define the widget layout and program functionality, respectively, and allow the programmer to separate logic from presentation. Frequently, the two files are coded side by side, with logic leading to widget layout and vice versa. To make it easier for the reader, we will talk about the logic file first, and then we'll cover the layout.

To give the reader an idea of what the expected outcome is, the schematic portion of the HMI is shown in the following diagram:

Kivy HMI (part 1)

The parameter data table is shown in following table:

Kivy HMI (part 2)

As Kivy is designed to be used with mobile devices, the two screens can be viewed by grabbing the side bar (dark gray in the first image) and swiping back and forth. On a computer, this is done using the mouse to swipe.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset