How to do it...

In the first chapter of this book, we created our first Python GUI. We improved our GUI by incrementing the different code module names via sequential numbers.

The following screenshots are from the First Edition of this book.

It looked like this:

While this is a typical way to code, it does not provide much meaning. When we write our Python code during development, it is very easy to increment numbers.

Later, coming back to this code, we don't have much of an idea which Python module provides which functionality and, sometimes, our last incremented modules are not as good as the earlier versions.

A clear naming convention does help.

We can compare the module names from Chapter 1, Creating the GUI Form and adding Widgets, to the names from Chapter 8, Internationalization and Testing, which are much more meaningful:

While not perfect, the names chosen for the different Python modules indicate what each module's responsibility is. When we want to add more unit tests, it is clear in which module they reside.

The following code naming convention is another example of how to use a code naming convention to create a GUI in Python:

Replace the word PRODUCT with the product you are currently working on.

The entire application is a GUI. All parts are connected. The DEBUG.py module is only used for debugging our code. The main function to invoke the GUI has its name reversed when compared with all the other modules. It starts with Gui and ends with a .pyw extension.

It is the only Python module that has this extension name.

From this naming convention, if you are familiar enough with Python, it will be obvious that, in order to run this GUI, you have to double-click the Gui_PRODUCT.pyw module.

All other Python modules contain functionality to supply to the GUI as well as execute the underlying business logic to fulfill the purpose this GUI addresses.

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

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