13.07.2015 Views

The wxPython tutorial

The wxPython tutorial

The wxPython tutorial

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

<strong>The</strong> Graphics Device Interfacehttp://www.zetcode.com/wxpython/gdi/Because of the simplicity of the script, there are some magicnumbers. In reality, we would have to calculate them. In theprevious code example, we draw the years alongside the xaxis. We subtract 13 px from the x value. This is done tocenter the years over the vertical lines. It works on my linuxbox. I might not work correctly on other platforms. It mightnot work even on linux boxes with different themes. You justplay a bit with this example. Adjusting it to fit under thedifferent circumstances is no rocket science. Normally, weneed to calculate the width of the chart, the width of the textand center the text manually.Figure: A line chartNoteNote is a small script that shows several interesting featuresof the GDI. We will see, how we can create a custom shapedwindow. <strong>The</strong>re are small applications that are used to takevisible notes. <strong>The</strong>y work as reminders for people, that workwith computers a lot. (e.g. us).#!/usr/bin/python# note.pyimport wx39 de 44 27/04/2008 1:08

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!