« | » Main « | »

I've been building a small GUI program with wxPython, and it's mostly a straightforward experience (if you're accustomed to the way GUIs tend to be built). wxGlade helps a lot with building the visible components of the UI. But I was going nuts trying to figure out why my Windows icons didn't look right. I went to the trouble of reading a technote (Icons in Win32) to decide which sizes and depths of icon I needed to provide to get a nice looking taskbar icon and alt-tab icon. But my taskbar icon always came out smeared, clearly having been scaled down from a 32×32 image.

I was ready to start reverse-engineering Windows' algorithm for picking the icon image, when I thankfully decided to look into the wxGlade-generated code first. Here's what it gave me for setting the icon in my main frame:

_icon = wx.EmptyIcon()
_icon.CopyFromBitmap(wx.Bitmap("myapp.ico", wx.BITMAP_TYPE_ANY))

This clearly seems to be picking a single image from the icon, then setting it as the icon. That defeats the whole idea of a multi-image icon. No wonder Windows seems to be scaling a large image for the taskbar. The .ico bitmap loader probably just picks the highest quality image it finds.

Digging deeper into the wxWidgets docs, I found wxIconBundle and wxTopLevelWindow.SetIcons, and came up with this instead:

ib = wx.IconBundle()
ib.AddIconFromFile("myapp.ico", wx.BITMAP_TYPE_ANY)

This works like a charm, giving me pixel-perfect icons for the taskbar and the alt-tab image. Bliss! I couldn't find much discussion of this issue, or use of these methods in existing code, and I don't know what it does on other platforms, but it works great on Windows.

Part of my continuing effort to help facilitate clear communication among engineers: Things to say when you're losing a technical argument:

10. I had one of the interns try that approach for another project, and it scrambled the CEO's hard drive. So I think it's going to be a hard sell.

59. Look, would you just get off your Be obsession for FIVE MINUTES and talk serious design with us?

tagged: ,   /   via: Keith Devens» 4 reactions

I've been getting back into wxPython coding, and have been trying to find a clean example of the Model-View-Controller pattern, but haven't been having much luck. For example, I'd like to have menu commands where the main frame doesn't have to know to invoke a method on the current view. I'd rather that some generic event machinery found that the view could handle the event, and let it do just that.

Matthew Scott's uberwx technique, which uses the dispatch module to move events around, may just the ticket, but I have to try it out to know for sure.

tagged: » 2 reactions

Inkscape is an open source vector graphics program (Inkscape is to Adobe Illustrator as GIMP is to Photoshop). It's native format is SVG. I haven't used it much, but it looks quite full-featured.

For a more in-depth review of Inkscape's good and bad points, see Jakub "Jimmac" Steiner's review of Inkscape.

tagged: ,   /   via: del.icio.us» react

Mongoose is a Python library for handling uncaught exceptions cleanly, and providing some support for incident reporting along the way (motto: "Mongoose catches runaway Pythons"). It looks like one of those small tools for a specialized job that are such a treat in the Python world.

(Via a comment to Ian's good catch all exceptions post.)

First Raymond Chen wrote that exceptions are cleaner, more elegant, and harder to recognize:

It is extraordinarily difficult to see the difference between bad exception-based code and not-bad exception-based code. ...

My point isn't that exceptions are bad. My point is that exceptions are too hard and I'm not smart enough to handle them. (And neither, it seems, are book authors, even when they are trying to teach you how to program with exceptions!)

Max Ischenko responded, writing about exception-based code and exception-based code antipatterns:

Overall, exception seems to be a net benefit. Result is a more stable program (fails early) with less efforts (fewer places to do error handling). Yes, it's hard to write a good exception-based code, harder then write a good error-code-based code but who said it's going to be easy?

There is no such thing as a free launch, after all.

So everyone agrees that exceptions (or any other comprehensive approach to error checking) is hard.

In response to Max, Ian Bicking writes about good catch all exceptions:

The most obvious case: it's not bad at all to catch all exceptions if you re-raise them.

I've written at length about my philosophy of exceptions. As David Byrne said, "say something once, why say it again?": Exception vs. status returns and Exceptions in the rainforest.

tagged: » react

If you find yourself following URLs that have fragment identifiers (you know, the part after the "#" hash mark), and they take you to the right page, but not the right place on the page, then most likely the page you've landed on has images without width and height attributes. The browser loads the page, and finds the spot identified by the fragment id, but then the images load in, and move the page around underneath you.

The fix is to make sure all of the images on the page have width and height attributes. That way the page is laid out correctly even before the images are loaded, and the fragments will work properly.

As you may have already guessed, I updated my blog software to add width and height attributes to all my images. Using Python Imaging Library, it was a piece of cake. Links to particular blog entries on this site will now work much better.

tagged: , » 1 reaction

So far, we've survived what is being termed "Blizzard '05". We got between two and three feet of snow, including drifting:

Blizzard burying chairs

Compare it to my Snowcakes picture of two years ago.

The town of Brookline (like the city of Boston) has closed school for two days, which seems completely unwarranted. Better safe than sorry, I guess.

There are updates available for two free graphics packages I use on Windows: Picasa (a photo organizer), and The GIMP (the GNU Image Manipulation Program).

Picasa 2 is out, and it has a bunch of new features. Since being acquired by Google, it is free, so why not run it? And no, I don't know what Google plans to do with it. It has a Blogger button, but buying Picasa seems a long way for Google to go to get a little Blogger integration.

The GIMP is up to version 2.2.2 (though the Windows install kit is only up to 2.2.1). If you haven't tried GIMP since version 1, take a look: version 2 is a huge improvement.

tagged: » 1 reaction

Kubi Software (my employer) is looking for QE contractors, or possibly contract-to-hire. See the job posting at dice.com for details! Hurry! Limited time offer! Send me an email if you're interested.

tagged: » react

I finally implemented a categorization scheme for this blog. It was interesting going back over the last three years and trying to see patterns in the posts. In the end, I created 77 categories, some of which I couldn't have predicted. I didn't realize I'd made 12 posts about Lego, for example. And going through the movie posts, I almost made a separate category for The Matrix.

As of now, I haven't actually categorized everything. There are still lots of uncategorized posts, because it's hard to identify their buckets. (Also, I got tired of doing nothing but categorizing old posts). I didn't want to make one gigantic "Writing Software" category, but I don't know what to call some of the smaller buckets within it. For example, what do you call the topics about how to design classes and modules? Pattern topics would go into it, but it isn't just patterns.

tagged: » 4 reactions


Wednesday 19 January 2005

I live in the Boston area, which means that January is cold. It was 8° (Fahrenheit) here yesterday. That's not that big a deal around here, but here's the thing: Somehow during the drive home in the evening, I managed to get my right index finger frostbitten. It was pale and numb, until I soaked it in some warm water and it returned to the same cold-pink as the others. Today: gloves.

tagged: » 3 reactions

I am not a graphic designer, but I have long admired what they do. One of the things I like about the hassle of rolling my own blogging software is the chance to do a little bit of design, both cosmetic and interactional. Khoi Vinh is a graphic designer, and shows his skill with his new improved design. This is a classic example of a grid design, where a page (or screen) is conceptually divided into a grid. The grid serves as a foundation for the content fitted into it, and ensures a consistency of geometry to the page. Interestingly, though the grid is intended as a constraint on the structure of the page, a hallmark of the technique is the flexibility of deciding how to place content within the grid. See Khoi's illustration of his grid for a demonstration.

tagged: ,   /   via: mezzoblue dailies» react

Because I may need it someday: HTMLarea, a very impressive HTML editor that runs in IE and Mozilla Firefox. It was written by Mihai Bazon, who also makes some great menu software and other DHTML goodies at dynarch.com.

tagged: , » 2 reactions

My wife Susan has an op-ed in today's Washington Post: Let Me Be Brave, about the Special Olympics and the death of Rosemary Kennedy (which I wrote about here last weekend). Of course, she says it all better than I could...

tagged: , » 2 reactions

¶   NASA Details Earthquake Effects on the Earth

¶   Mario Brothers sheet music

¶   Wonkavision

The first image from the Huygens probe on Titan shows the surface of the moon of Saturn:

First image of Titan

Some remarkable factoids about the mission:

  • Although it is a moon, Titan is larger than Pluto, and has lakes of liquid methane (we seem to be seeing one in the picture).
  • It took seven years for the probe to travel from Earth to Titan.
  • Because not enough sun is available to power cells, the probe is powered by batteries, which were only designed to last a few minutes.
  • The batteries lasted a few hours anyway!
tagged: » 1 reaction

IBM is releasing 500 patents for use without payment in open source products. Here's the list of all 500 patents.

I don't know what this means from a business point of view. As an engineer, I scan down the list of patents and get the same glazed-eye look as anyone else. They all sound very similar, and all sound like either completely fundamental principles or trivial crap, like most patent titles do. Also of interest to me is that none of the three patents that I authored in the IBM portfolio are in the list:

  • 6,408,360: Cache override control in an apparatus for caching dynamic content.
  • 6,351,767: Method and system for automatically caching dynamic content based on a cacheability determination.
  • 5,691,708: Text abstraction method and apparatus.

Does this mean my patents are worthless? Or irrelevant? Or too valuable to disclaim? Maybe they just don't have much to do with the hotspots of open source. Who knows?

tagged: ,   /   via: ongoing» 5 reactions

Bjarne Stroustrup has written a very interesting paper outlining some radical ideas for operator overloading: Generalizing Overloading for C++2000. He includes the notion of overloading no operator at all, so that "x y" can mean "x*y" the way physicists and mathematicians want it to mean.

Note: I got about halfway through this before realizing it was a joke...

tagged:   /   via: Borkware Miniblog» 7 reactions

AutismLink (Pennsylvania's Statewide Resource for Autism Spectrum Disorder) is selling Autism Awareness car magnets. There are other sources for these magnets, but AutismLink helps the cause more directly.

tagged: , » react

The UK's Guardian Unlimited has a section called The Digested Read, in which books are reviewed by way of condensing them into a single page in the style of the book itself. The whole thing is then snarkily summed up in a single sentence titled "The digested read ... digested". Judging by two samples from books I had actually read (Vernon God Little and Life of Pi), for some books they do a pretty good job nailing the tone and subject of the books. For others (Harry Potter and the Order of the Phoenix, for example), they seem to settle for mere parody.

tagged:   /   via: LinkMachineGo» react

I've heard of MAME, the arcade video game emulation software. I hadn't known that there's an entire cottage industry springing up to provide arcade-style enclosures for computers running MAME: SlikStik, DreamAuthentics, MAMEroom, and Dream Arcades, to name a few businesses. You can even get MAME-branded arcade tokens!

tagged:   /   via: Coding Horror» 2 reactions

Matthew Baldwin collected a bunch of tricks of the trade from all sorts of professions (clown, butcher, nurse, photographer). He ended up getting more from all over, enough to start a whole blog about it: Tricks of the Trade. Some are edifying, some are horrifying (for example, mortician), all are fascinating.

tagged: , » 1 reaction

Rosemary Kennedy, the disabled sister of JFK, and the inspiration for the Special Olympics, died yesterday.

This is a remarkable story, for both good and bad. On the bad side, a mildly retarded girl is lobotomized, leaving her profoundly disabled. She's hidden from view to prevent scandal to an ambitious and powerful family. On the good side, she inspires that family to create the Special Olympics, one of the best things to happen for disabled people in the last century.

I don't know how much Rosemary's story is unique for that era. There certainly were not the options and understanding that there are now. I'm saddened to think of her plight as an individual, but glad to benefit from the organization and attitudes that she helped, however indirectly, to create.

Alexander Belchenko has translated another page of mine: Удаление кода.

tagged: » react

My 15-year-old autistic son drew this picture today:

Nat's drawing of Pooh characters

He's drawn four characters (Piglet, Tigger, Pooh, and Eeyore), each in their characteristic color, and labelled in the same color. He's signed his name in red. I really like this picture, partly because Nat never draws pictures.

I was considering using this picture as a jumping off point for writing about one of the many philosophical quandries facing parents of disabled children: the disparity between his chronological age and developmental age, or the difficulty of choosing appropriate educational goals, or discerning the fine line between his personality and his disability.

But I'm not going to write about any of those things. Instead, I think I'll just enjoy the picture.

Steve Friedl has written a detailed and comprehensive guide to how to crack into relational-based systems: SQL Injection Attacks by Example. Also included (for those of us on the hook for building these systems) are tips for how to prevent injection attacks.

Last Sunday's investigation into musical navigation demonstrated to me once again just what an ad-hoc hodge-podge music notation is. It's developed over centuries, with odd symbols mixed together with abbreviations of Italian words, and so on. But even with its flaws, it's so well established that no one would propose changing it, right? Wrong.

The Music Notation Modernization Association is proposing exactly that. They have a set of detailed criteria that they used to evaluate over 500 different proposals, winnowing them down to a few dozen.

These notations have merit, but let's get serious here: there's no way music notation is going to change. There's just too much music already out there, with too many people already trained on the current system. If we can't manage to change English spelling, we aren't going to be able to change music notation.

On the same topic, it had to be out there, but I had never seen it: MusicXML.

tagged: » 3 reactions

Damien tells the story of his Formula Engine Rewrite:

I was scared to death that the new engine would never really work, that there was going to be some fatal flaw in my design that made it fundamentally incompatible with the old engine, or the new engine was going to be slower and hence useless. But through all this Wai Ki seemed to have unflagging confidence in me, he calmly told me that I just need to take my time, do it right and not get so stressed. At one point I was in his office talking about the all the work and how behind I was and how everything looked bleak, and the longer I talked the higher and louder the pitch of my voice got. He told me I was "freaking out," to which I replied, "Yes! YES! ....I'M FREAKING OUT!!!" But it was his calmness and confidence in me that gave me the courage to throw away large chunks of work when I saw it was bad.

It's a good story of how a major feature got built against the odds by one determined engineer.

tagged: » 2 reactions

Picture me standing at a lectern. A spray of microphones nearly obscures my face. Camera flashes strobe the room. I am near tears, but resolve to deliver my message:

Ladies and gentlemen, due to an unfortunate coding error, my 1000th post of a few days ago was actually my 996th. I recently added draft posts to my blogging software, and the count incorrectly included drafts. That makes this my 1000th post.

I apologize sincerely to all those readers I mislead. I can assure you that we here at nedbatchelder.com are taking this very seriously, and are taking every step possible to ensure that this kind of mistake will never happen again.

I'm just glad the truth came out before any more damage was done. I hope you will forgive me. I'm going to put this behind me and get back to delivering quality blog posts as soon as possible. I want to publicly thank my wife and family for standing by me through this dark time.

Thank you.


  • Don't believe everything you read on the web.
  • Test your software.
  • Don't rely on external milestones to identify the highlights of your life.
tagged: » 2 reactions

Scoble has advice for job seekers:

Forget the resume. That won't get you a job in today's market. Your blog will, however.

I don't know whether this is true or not. I guess a blog couldn't hurt. Someday I'll need a job, and this will be a prime place to announce it. In fact, one of the things that got me to start this blog was the idea that I'd need a place someday from which to shout, "Help!" I'm glad at least one person thinks it will help.

tagged: » 9 reactions

I've long been surprised at the dearth of good tools for dealing with Windows icons. For example, considering how mainstream a format it is, I'm surprised to find that neither Photoshop nor Gimp can handle it. Perhaps it's because of .ico's inherent multiple image nature.

In particular, there haven't been any useful freeware icon editors that I've found. Well, now I've found one: @icon sushi It isn't exactly an icon editor, since it focuses on all aspects of icon other than the color of the pixels (in other words, all the things that are unique to icons). For painting pixels, use your favorite image editor, then use @icon sushi to pull the pictures together into an icon.

tagged: ,   /   via: blog.dreampro» 3 reactions

Alex Gorbatchev has another solution to the problem of syntax-coloring code snippets on blogs: ship the whole problem over to the browser, then do the coloring in JavaScript. It's a very interesting solution, and the JavaScript code itself is very cool.

What I need is syntax coloring that can handle true Unicode characters. I don't know whether JavaScript regexes can do it. I've been using SilverCity, but have been thinking about a new solution. Maybe client-side JavaScript is the way to go.

tagged: ,   /   via: Coding Horror» react

This is the 1000th post on this blog. Don't believe me? See for yourself.

I don't have anything wise to say to mark the occasion, no touching reflections on the 999 posts that have preceded it. In keeping with my aversion to marking special occasions, I'll allow myself the freedom to wax poetic about my blogging when I feel like it, rather than when the odometer happens to have a few zeros in it.

I've been blogging for close to three years, and I've enjoyed it, so I'll keep on doing it until it starts to suck. Knowing me, I'll probably keep doing it for a while even after it starts to suck. I've gotten some nice feedback from people, and that helps keep the momentum going.

Thanks for reading.

tagged: » 5 reactions

I was playing some piano music today, and saw that familiar notation "D.S. al Coda". Although it was familiar, I didn't actually know what it meant. I knew it had to do with going back and repeating some part of the music, but that detail of my piano education had withered long ago.

So I looked it up online, finding this great online music notation reference: Music Theory Online. Chapter 24 is Repeats, and told me what I needed to know. Acoustic Guitar also has a handy online lesson about notation. So: "D.S. al Coda" means go back to the percent-over-S sign, then play to the other plus-over-O sign, then play the coda (the end).

But when I looked at my sheet music with this new understanding, I saw some oddities: First, the percent-over-S sign was placed at the beginning of the piece, so why not use "D.C. al Coda", which means go back to the beginning, and so on? And when I looked at the end of the piece, it seemed clear it could have been written more compactly without changing the music: the same measures were in the coda as in the normal repeat that was skipped.

I guess music can be refactored just as code can. What I saw in the music were duplicate lines of code that could have been eliminated by rewriting the loops with different termination conditions! Fascinating.

BTW: Back in March, I asked about MIDI-to-notation converters. I really appreciate the shorthands of music notation after looking at the output of these programs. All the loops have been unrolled, all the trills, grace notes, and arpeggios have been literalized, and so on. A simple three-page song becomes a twelve-page mess of mind-numbing repetitive scribbles.

tagged: » 2 reactions

Happy New Year everyone!

I have to say this about New Year's Day though: I don't like special occasions, for two reasons:

  1. There's pressure to do something special with it.
  2. There's inertia not to do something special with other days.

For example, everyone's making resolutions today. Why today? Shouldn't we be introspective and purposeful the rest of the year? Why can't I make resolutions on February 5th or October 18th? Everyone tries to make their birthday special by doing just what they want to do. Why can't I do what I want to do every day?

And since we've just left the Christmas season, how about maintaining a little good will toward others the whole rest of the year? Hallmark shouldn't dictate our mood.

So my resolution for the new year: treat every day as special, regardless of the position of the Earth in its travels around the sun.

« | » Main « | »