Working with the basic building blocks

This chapter covers

Using a device context to draw to the screen

Adding window decorations to a frame

Working with standard file dialogs and

color pickers

Laying out widgets and creating a sizer

Building about boxes and splash screens

Even a simple wxPython program needs to use standard elements such as menus and dialogs. These are the basic building blocks of any GUI application. Using these building blocks, along with fancier widgets like a splash screen, status bar, or about box, provides a more user-friendly environment, and gives your application a professional look and feel. To conclude the first part of the book, we'll guide you through the creation of a program using all of these components. We'll build a simple draw program, then add these building block elements and explain some of the issues in using them. We'll reinforce the fundamental concepts covered in the previous chapters, and at the end you'll have a simple but professional application. This chapter is a middle ground between the basic concepts discussed in the previous chapters and the more detailed discussion of wxPython functionality in parts 2 and 3.

The application we'll build in this chapter is loosely based on the Doodle and Super Doodle samples that are distributed with wxPython in the wxPython/samples directory. It's a very simple draw program that tracks the mouse pointer when the left mouse button is down, and draws a line. Figure 6.1 displays a simple initial sketch window.

Figure 6.1 A simple sketch window, with no further decorations

We chose a sketch sample because it's a fairly simple program that illustrates many of the issues involved in creating more complex applications. Within this chapter, we'll show you how to draw lines on the screen, and add a status bar, a toolbar, and menubar. You'll see how to use common dialogs, such as a file chooser and a color picker. We'll use sizers to lay out complicated widget sets, and we'll add an about box and a splash screen. At the end of the chapter, you'll have created a nice looking sketch program.

Was this article helpful?

0 0

Post a comment