Python GUI Programming Cookbook - Second Edition
Burkhard A. Meier
- 422 pages
- English
- ePUB (mobile friendly)
- Available on iOS & Android
Python GUI Programming Cookbook - Second Edition
Burkhard A. Meier
About This Book
Master over 80 object-oriented recipes to create amazing GUIs in Python and revolutionize your applications todayAbout This Book⢠Use object-oriented programming to develop amazing GUIs in Python⢠Create a working GUI project as a central resource for developing your Python GUIs⢠Easy-to-follow recipes to help you develop code using the latest released version of PythonWho This Book Is ForThis book is for intermediate Python programmers who wish to enhance their Python skills by writing powerful GUIs in Python. As Python is such a great and easy to learn language, this book is also ideal for any developer with experience of other languages and enthusiasm to expand their horizon.What You Will Learn⢠Create the GUI Form and add widgets⢠Arrange the widgets using layout managers⢠Use object-oriented programming to create GUIs⢠Create Matplotlib charts⢠Use threads and talking to networks⢠Talk to a MySQL database via the GUI⢠Perform unit-testing and internationalizing the GUI⢠Extend the GUI with third-party graphical libraries⢠Get to know the best practices to create GUIsIn DetailPython is a multi-domain, interpreted programming language. It is a widely used general-purpose, high-level programming language. It is often used as a scripting language because of its forgiving syntax and compatibility with a wide variety of different eco-systems. Python GUI Programming Cookbook follows a task-based approach to help you create beautiful and very effective GUIs with the least amount of code necessary.This book will guide you through the very basics of creating a fully functional GUI in Python with only a few lines of code. Each and every recipe adds more widgets to the GUIs we are creating. While the cookbook recipes all stand on their own, there is a common theme running through all of them. As our GUIs keep expanding, using more and more widgets, we start to talk to networks, databases, and graphical libraries that greatly enhance our GUI's functionality. This book is what you need to expand your knowledge on the subject of GUIs, and make sure you're not missing out in the long run.Style and approachThis programming cookbook consists of standalone recipes, and this approach makes it unique.. While each recipe explains a certain concept, throughout the book you'll build a more and more advanced GUI, recipe after recipe. In some of the advanced topics, we simply create a new GUI in order to explore these topics in depth.
Frequently asked questions
Information
Internationalization and Testing
- Displaying widget text in different languages
- Changing the entire GUI language all at once
- Localizing the GUI
- Preparing the GUI for internationalization
- How to design a GUI in an agile fashion
- Do we need to test the GUI code?
- Setting debug watches
- Configuring different debug output levels
- Creating self-testing code using Python's __main__ section
- Creating robust GUIs using unit tests
- How to write unit tests using the Eclipse PyDev IDE
Introduction
Displaying widget text in different languages
Getting ready
How to do it...
self.win.title("Python GUI")
self.win.title("Python Graphical User Interface")
class I18N():
'''Internationalization'''
def __init__(self, language):
if language == 'en': self.resourceLanguageEnglish()
elif language == 'de': self.resourceLanguageGerman()
else: raise NotImplementedError('Unsupported language.')
def resourceLanguageEnglish(self):
self.title = "Python Graphical User Interface"
def resourceLanguageGerman(self):
self.title = 'Python Grafische Benutzeroberflaeche'
from Ch08_Code.LanguageResources import I18N
class OOP():
def __init__(self):
self.win = tk.Tk() # Create instance
self.i18n = I18N('de') # Select language
self.win.title(self.i18n.title) # Add a title