Book Image

Python GUI Programming Cookbook, Second Edition - Second Edition

By : Burkhard Meier
Book Image

Python GUI Programming Cookbook, Second Edition - Second Edition

By: Burkhard Meier

Overview of this book

Python 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.
Table of Contents (18 chapters)
Title Page
About the Author
About the Reviewer
Customer Feedback

Our GUI in 3D!

In this recipe, we will create our own GUI using wxPython. We will reuse some code from the wxPython demo examples, which we have reduced to the minimum code required to display OpenGL in 3D.


OpenGL is a very large library. We will not go into detailed explanations of this library. There are a lot of books and online documentation available if you want to study OpenGL further. It has its own shading language.


Getting ready

Reading the previous recipe is probably a good preparation for this recipe.

How to do it…

As the entire Python code is a little bit long here, we will show just a little bit of the code.

The entire code is available online and this Python module is called

import wx                   
from wx import glcanvas 
from OpenGL.GL import * 
from OpenGL.GLUT import * 

class CanvasBase(glcanvas.GLCanvas): 
    def __init__(self, parent): 
        glcanvas.GLCanvas.__init__(self, parent, ...