Book Image

Python GUI Programming Cookbook

By : Burkhard Meier
Book Image

Python GUI Programming Cookbook

By: Burkhard Meier

Overview of this book

Table of Contents (18 chapters)
Python GUI Programming Cookbook
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Changing the entire GUI language all at once


In this recipe, we will change the entire GUI display names all at once by refactoring all the previously hard-coded English strings into a separate Python module and then internationalizing those strings.

This recipe shows that it is a good design principle to avoid hard-coding any strings that our GUI displays but to separate the GUI code from the text that the GUI displays.

Note

Designing our GUI in a modular way makes internationalizing it much easier.

Getting ready

We will continue to use the GUI from the previous recipe. In that recipe, we had already internationalized the title of the GUI.

How to do it...

In order to internationalize the text being displayed in all of our GUI widgets, we have to move all hard-coded strings into a separate Python module, and this is what we do next.

Previously, strings of words that our GUI displayed were scattered all over our Python code.

Here is what our GUI looked like without I18N.

Every single string of every...