Snippets

I discovered that I have written quite a lot of bits of useful code. If it was useful to me, maybe it will be useful to you too.

Most of the things here are either Python or wxPython related, as those are the primary tools I’ve been using lately. Some other things may creep in as well. All the code here is in the public domain and you can do anything and everything you like with it. If you do find it useful, I’d love to hear about it.

Name Category Description
Skin UI wxPython

The skinui.py module contains two classes: SkinButton and SkinPanel. SkinButton is a fancy bitmap based buttons that uses a different bitmap to every one of the four button states (normal, hot, selected, disabled) and even supports transparent bitmaps. SkinPanel is a standard panel that uses an image to draw its background, including tiling a small image to fill up the panel’s surface. When you put a SkinButton on a SkinPanel, the transparency works as expected, showing parts of the background through the transparent parts of the button. The zip file includes an example.

FlowPanel wxPython

This class is a window that arranges items in rows, as many items as it can fit in a single row in a way similar to the Java’s FlowLayout class. Due to the way sizers work in wxPython it is impossible to implement this behavior efficiently enough to be useful with sizers. This class has a custom Layout function instead.

CSV to Google Calender Python I one of those people who can barely rememeber their own birthday let alone the important dates of other people. I wrote this script to put the birthdays of all my friends and family on Google Calendar so I won’t forget again. Just create a simple CSV file with the names and dates and run the script with your email and password.
Simple Lexer Python This is a very simple implementation of a lexer in Python with an example of syntax coloring Python code.
Copy Paste Detector Python, C# This code runs through the source files of a large C# project looking for duplicate blocks of code. It’s not as efficient as CPD, but it is small and can be adjusted and edited and so is better suited for my needs.
Line Counter Python, C# Yet another line code counter for C#.