Book Image

wxPython Application Development Cookbook

By : Cody Precord
Book Image

wxPython Application Development Cookbook

By: Cody Precord

Overview of this book

wxPython is a GUI toolkit for the Python programming language built on top of the cross-platform wxWidgets GUI libraries. wxPython provides a powerful set of tools that allow you to quickly and efficiently building applications that can run on a variety of different platforms. Since wxWidgets provides a wrapper around each platform’s native GUI toolkit, the applications built with wxPython will have a native look and feel wherever they are deployed. This book will provide you with the skills to build highly functional and native looking user interfaces for Python applications on multiple operating system environments. By working through the recipes, you will gain insights into and exposure to creating applications using wxPython. With a wide range of topics covered in the book, there are recipes to get the most basic of beginners started in GUI programming as well as tips to help experienced users get more out of their applications. The recipes will take you from the most basic application constructs all the way through to the deployment of complete applications.
Table of Contents (17 chapters)
wxPython Application Development Cookbook
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Building a system tray application


If you want to build a simple menu-based application that does not require a full GUI, the TaskBarIcon class provides a way to build a TaskBar application that integrates with the operating system's window manager, such as TaskBar (Windows/Linux), Dock, or status area on OS X. This recipe will show you how to build a simple weather checker application using the TaskBarIcon class in wxPython.

Getting started

This recipe uses the OpenWeatherMap API to get weather information. From October 2015, they require that you have an API key to use this service. Obtaining a key is free and simply requires signing up on their site. So, before starting this recipe, visit http://openweathermap.org/appid#get to learn how to get an API key.

How to do it…

Perform the following steps:

  1. Firstly for this recipe, we will need a couple of extra imports from the Python standard library to help us out and define some menu IDs for later use. We can use the following code for this:

    import...