Python


February 11, 2007: 12:53 am: kpdwxPython

I just noticed that my wxPython application looks different after creation of an exe with Py2Exe. The image on the left is the application running under the normal python interpreter. The one on the right is the same application after creation of an exe with Py2exe.

Notice:
1. The dark gray below the Music label instead of white.
2. The area around Music is inset in the exe version.
3. The splash handle separator is different, it looks more 3D in the Py2EXE version.

This is with wxPython 2.8.1.1.

I’d guess there is a simple solution, but I’m not finding it. Any ideas?

Edit:
Solution is at: http://wiki.wxpython.org/index.cgi/DistributingYourApplication

February 7, 2007: 9:29 pm: kpdPython

A discussion over on the Business of Software about embedded firmware testers brought this software back to mind. I created this around 1998 to exercise the firmware (and hardware) of a steer-by-wire system for power boats I was working on. It was written using Tkinter for the GUI. It sent a simple command protocol over an RS-232 link to the system. It was amazing when I brought the system over from Windows NT to the Linux development box and did not have to change a line of code. Go Python!

The original page (which is long gone, thanks way-back machine) describing it said:

his is a screenshot of an application written in Python using the TK interpreter and the Python MegaWidgets Toolkit. It communicates with an embedded module via the RS-232 serial port. We use it to exercise new circuit boards and to debug hardware problems.

Most of the windows are generic, although they do have symbolic names for important microprocessor ports such as data I/O direction. One can also enter a numeric address to work with any memory location. The Motor Drive window presents high-level functionality specific to the product being tested.

I developed the application under Windows NT. The application ran with zero source-code changes when I later moved our development platform to Linux (the serial-port classes contained support for both Linux and NT).

Tkinter Firmware/Hardware Tester

January 22, 2007: 6:21 am: kpdPython, programming

The slides from my Code Mash presentation on Test Driven Development in Python are now online at: http://powertwenty.com/kpd/downloads/TestDrivenDevelopmentInPython.pdf

It is an introduction to TDD, some tools that work well when doing TDD in python, and the results of a case study in TDD game development using pygame.

January 19, 2007: 7:31 pm: kpdPython, programming

Wow, CodeMash turned out to be a fabulous conference. The atmosphere was one of learning from others in a friendly way – people checked their religious wars at the door. It was a fun conference. Feeling a little under the weather, I didn’t have a chance to check out the water slide park, but the movie shown at the closing ‘can geeks surf in Ohio?’ leads me to believe that might not be a bad thing.

I enjoyed the Neal Ford and Bruce Eckel’s keynotes the best. Neal spoke of mini-domain languages. Bruce tied in some great shots of Burning Man with a thought-provoking talk on using your imagination and thinking outside normal limits.

Between Kevin Dangoor’s talk on TurboGears, David Stanek’s talks on Enterprise Python Architecture and Web Services in Python, Mark Ramm’s talk on SQLAlchemy ( which made me vow to look into this library), and my talk on TDD Python, the language was well represented.

I am happy with how my talk on Test-Driven Python went. I hope to post the slides some time soon. Running through the presentation at this month’s Cleveland Python Users’ Group pointed out some areas that need refining, especially around the live demos. Fortunately I had the time to make the changes before Code Mash.

Oh, and the winning program in the coding contest was by Matt from CLEPY and coded in Python. There was some debate about the grand prize in the contest because the winner did not code the solution but instead solved it manually due to a loophole in the requirements.

The conference organizers did a fabulous job pulling things together. As an attendee and speaker there were no hitches, and in fact they even had a speaker’s room and gift bags for each speaker. That was a nice consideration. The only hitch in the conference overall that I am aware of was some issues with audio recording of the earlier sessions, and that was really the fault of the resort and its confusion between male and female audio jacks.

In the end, there is nothing I’d have changed for this conference, other than hitting the water park next time and perhaps fairing a little better in the XBox 360 and WII drawings.

January 18, 2007: 11:29 am: kpdPython, programming

Just finished listening to Kevin Dangoor’s talk on TurboGears at Code Mash.

His talk was a general overview of TurboGears features. While I’m in the middle of prototyping a TG application, there were a few things I wasn’t aware of:

o the ease of which AJAX widgets can be incorporated into an application
o multiple templates based on accept parameter
o lots of good things to say about SQLAlchemy

I’ve taken away from this that TG evolution is going strong and that SQL Alchemy is well worth looking at. Good timing on the latter as there is a presentation later today on it.

January 11, 2007: 7:46 am: kpdPython

Code Mash is a multi-language conference being held in Northern Ohio next week. I was happy to find out that my paper on Test Driven Python was accepted. The talk covers the basics of TDD, qualities of Python as a language that facilitate TDD, Python tools, and a case-study. I ran through the talk at last Monday’s CLEPYmeeting. I had some trouble with fonts and laptop to projector resolution, but nothing that can’t be resolved.

Python is also represented at Code Mash by fellow CLEPY member David Stanek, who is going to talk on Enterprise Python and Python web-services.

CodeMash – I'll be there!

December 5, 2006: 3:38 pm: kpdPython

I took a break from ErgMate today to look around a bit at PyGame. Eventually found this game – Escape from Anathema Mines. Phil Hassey created it for the 2005 Ludum Dare contest. It’s a lot of fun, but I’m impressed that in a quick game (48 hours) with pygame he was able to add shading – note how the boulder blocks the miner’s light.

There are many higher-level libraries that wrap pygame. It’s hard to tell which one to use, or perhaps it’s better to just stay with pygame itself. Any ideas?

Note – Christmas comes early this year as there is a new release of pygame coming out in a week or two!

November 27, 2006: 10:18 pm: kpdMicro-isv, Python, Radio Control Model Aircraft

I’ve been playing around with Tabblo to show some of my planes. Tabblo is a relatively new photo-sharing site. I found it from reading Ned Batchelder’s blog. He’s one of the minds behind Tabblo. This site is differentiated by the powerful layout mechanism. I also like the fact that you can print posters, books, cards, etc. I’ve not seen such a thorough use of Ajax in a site before. And it’s python powered (Django) to boot!

November 16, 2006: 5:29 am: kpdPython, wxPython

wxGlade has the ability to integrate custom or 3rd party widgets into its pallette. This feature is not documented very well. By using some sample code from Alberto Griggio and digging through the core-widgets source code, I was able to create bridge code that adds Andrea Gavana’s FloatSpin control to the pallette. For those that follow, I suggest starting with the a similar class from the core pallette and the code for html_window. The only real gotcha for this integration was that the widget container was not seeing KILL FOCUS events from the FloatSpin controls and therefore changed data was not saved. This was fixed by trapping EV_FLOATSPIN events and calling the update.

wxGlade Pallette with Float Spin

The FloatSpin bridge code is installed by untarring from within your .wxglade directory. The included README contains more details.

Edits:
11/16/2006 – uploaded version 1.1. Adds event handlers and support for digits=0.

November 15, 2006: 6:07 am: kpdPython, wxPython

I try to create reusable windows as subclases of wx.Panel and then insert them into frames as needed. This morning I had a panel that needed to perform some cleanup. The problem was that the close event happens on the frame, not the panel. Overriding the obvious methods, Destroy, Close, etc did not work as expected. I found the answer from Robin Dunn deep in the wxPython mailing list:


<pre>
     # __init__ method of wx.Panel subclass
     self.Bind(wx.EVT_WINDOW_DESTROY, self.OnDestroy)

    def OnDestroy(self, event):
        ## clean up resources as needed here
        event.Skip()
</pre>

Seems obvious now. Another step forward in learning the wxPython/wxWidgets philosophy.

« Previous PageNext Page »