Tao of the Machine

Programming, Python, my projects, card games, books, music, Zoids, bettas, manga, cool stuff, and whatever comes to mind.

More wxPython woes: wxImage, wxBitmap

So I thought the wxListCtrl class was hairy. Enter wxImage. What a pain. Judging from the demo, you’d think it’s relatively easy to load and display an image. Wrong; all my attempts failed. Even copying the exact demo code to my file would not work. Eventually it comes down to two problems:

  1. wxImage is not forgiving when it comes to path names.
  2. The appropriate image handler needs to be installed before an image of a certain type can be loaded.

Not very friendly, so there is another task for Wax. Here’s the code that displays an image in a frame:

from wax import *

class MainFrame(Frame):
def Body(self):
jpg = Image(‘moo.jpg’)
bitmap = jpg.ConvertToBitmap()
bmp = Bitmap(self, bitmap)
self.AddComponent(bmp)
self.Pack()

app = Application(MainFrame)
app.MainLoop()

The line jpg = Image(‘moo.jpg’) not only loads an image, but performs some trickery behind the scenes: it detects the type, and installs the JPG handler. (Autodetect and install-on-demand are the default, but can both be turned off if necessary.)

It can be done even shorter, by the way, using the BitmapFromFile function, but (currently) this only works if the appropriate handler is already installed.

Posted by Hans Nowak on 2003-05-30 22:38:22   {link}
Categories: Wax

Do you hate the wxListCtrl class too? ;-)

No? Well, bully for you. I happen to dislike the class greatly, because I never seem to be able to figure out how to get it to work. The example in the demo uses an image; what if I don’t want an image? And what’s up with having to call InsertImageStringItem, SetStringItem and SetItemData in order to insert an item?

That can, no, must be done better. So I added a class named ListView to Wax, which is going to take care of this. This is how you create it:

listview = ListView(self, size=(500,300), 
columns=[“Sender”, “Subject”, “Date”])

(Note that you can pass the column names in the constructor, but you don’t have to.)

And this is how you populate it:

listview.AppendRow(“Fred”, “foo”, “bar”)

You can now use [row,column] syntax to get or set the value of a “cell”:

listview[0,1] = “Re: Programming”
print listview[1,1]

More Leckerbissen will be added later. But, damn, I cannot release the code yet. The main reason is that it’s too unstable. Everything so far works fine, but I have only covered 20-odd wxPython controls, and some are vastly incomplete (lacking common events for example). On top of that, everything is still subject to change. Maybe tomorrow I’ll decide that the layout stuff needs rewritten, or something like that… major code breakage could be the result.

To put it another way: I don’t want to get angry mails when I release a version that’s not backwards compatible, and I don’t want to get mails pointing out that it’s not complete. I know that.

If you really, really want the development code, you can drop me a mail and I’ll send it to you, but I strongly discourage using it for anything else but testing. At this point I also cannot accept other people’s classes, because I’m still trying to figure out “the Wax philosophy”.

In the meantime, let’s ponder the idea of adding data-aware controls to Wax…

Posted by Hans Nowak on 2003-05-30 01:08:32   {link}
Categories: Wax

Links

After some more tinkering with the Firedrop2 code, it is now ready for some more web publishing. I am putting (parts of) my link collection online, mostly so I can reach important URLs from anywhere, rather than having to search through bookmarks scattered over 5 browsers. But others might find some of the links interesting as well.

This is very much a work in progress. The collection will grow over time.

Update. My resume is online as well.

Posted by Hans Nowak on 2003-05-28 02:14:57   {link}
Categories: Firedrop

Charging for software

Some people are having a discussion about whether software should be charged for.

I happen to know a bit about economics (hey, we all make mistakes when we’re young… :-) Therefore, two remarks.

1. Economy is not just about money. It’s also about, say, labor, products, and services, to name a few things. Something can have economic value other than a monetary one.

If I write software, and don’t plan to sell it, then it’s pointless to make a calculation like, I worked 100 hours on it, I’m worth $50/hour, so my costs are $5000. The cost for writing it was my time, which I voluntarily offered, because I like to hack. It’s something I do for fun. There’s no monetary cost, any more than there would be when I had spent my time watching tv, or playing cards, or sleeping. There’s also no hidden cost for anyone who downloads and uses my program.

2. Economy as we know it is in the process of changing, because of software. For the first time in history, there’s something that you can produce (write) and distribute at no cost at all. This is what many programmers regularly do; they write a program, slap it on a website, and everybody can download it for free.

This wasn’t possible in the old situation. If I produce, say, chairs, and 1000 people want one, then I have to make 1000 chairs. Same for services. But with software, I can have the costs of writing it once, then distribute it as many times as I want, without any additional cost.

Software is different, and old notions (and laws) about ownership, theft, copyright and such, are not so clear anymore. If someone steals my chair, I lose the chair itself (property), and the opportunity to sell the chair. If I’m a taxi driver and my customer doesn’t pay for his ride, my costs were not compensated by payment. That’s quite clear. But… if Johnny makes a copy of company X’s program, then there is no cost that wasn’t offset by payment. In fact, in most cases company X won’t even know about it; what’s more, they need to resort to dubious methods to find out if people use their products without a license. That’s why you cannot call this “theft” in the original sense of the word. Nothing was stolen. The company still has all their money, still has their program. One could argue that the company lost the opportunity to sell it to Johnny, but he wasn’t going to buy it anyway, so no loss there either.

Of course, whether copying commercial closed-source software is legally and morally acceptable, is a very controversial issue, and won’t go into it further at this time. I’m sure there are other websites where you can discuss this in detail. :)

Posted by Hans Nowak on 2003-05-26 19:33:31   {link}
Categories: programming

Speaking of having too much time...

Rubik’s Cube Solver in Lego.

Posted by Hans Nowak on 2003-05-26 19:28:05   {link}
Categories: general

Rude software

Problems with software are quite common, to say the least. It can be buggy, lacking quality, in beta, unstable, clumsy, unfriendly, incomplete, unfinished, not backwards compatible, out of date, etc. There are often reasons and excuses for all of these. But IMHO there’s no excuse for software that’s rude.

My definition of rude software is, that it does things behind your back, does things without asking, or generally interferes with your work… and it’s deliberately designed to do so. Let’s look at some examples.

  • Putting icons on the desktop and taskbar, in addition to the start menu. OK, this is only a tiny bit rude; after all, it’s easy to remove those icons, even for a beginner. Still, I don’t like to see AOL, ICQ or Mozilla icons all over the place after an install. If nothing else, the program could just ask.
  • Popping up windows (and putting them in front) when you’re doing something else. Yahoo Messenger is a notorious example. Very nice when you happen to be typing; all of a sudden a window with “are you there?” pops up, and takes focus. Pop-up windows in browsers fall in this category too.
  • This is more of a pet peeve of mine: Programs that insist on installing in a certain directory, especially c:\ or c:\Program Files. c:\ is bad because I don’t want a cluttered root directory. c:\Program Files is bad because it’s hard to reach from the command line (due to the space in the name).
  • Another pet peeve: programs that install themselves in directories or start menu folders, using the company name. If it’s well-known software, then maybe I know that Microsoft, Blizzard or Sierra produced it, and that I have to look in the folder with the same name. But having to look in Fooblitzky Software’s folder is not quite intuitive. The name of the company is not more important than the name of the program.
  • Splash screens! They come in at least two varieties: those that you can click away (by clicking on another window) and those that are persistent. Delphi, Netscape/Mozilla, and ICQ are bad examples. I really don’t want to take a 10+ second break just because I’m starting a program. In these days of multitasking systems, it’s pretty rude to force the user to stare to a screen and do nothing. Is it really so difficult to start a program in the background?
  • Probably the rudest of all are unauthorized registry hacks. Certain programs (cough*RealPlayer*cough) make themselves start when the computer starts, without asking. And putting something in the “Startup” folder is not enough for them; no, they use a registry setting, so the average user will not be able to remove it. And for some software, a one-time registry hack is not enough; it regularly checks if it’s still there, and restores it if it’s missing.
  • And then there are those programs that change file associations, again without asking. Some browsers do this; apparently every browser wants to be the default. But other programs do it as well, and it’s not fun if .html, .doc, .mp3, .txt and friends suddenly start with a different program.
  • Bordering on illegal is spyware. I’m not sure if “rude” is sufficient to describe it. We all know these programs… Kazaa, Gozilla, Comet Cursor, etc. Fortunately there is such a thing as AdAware.
  • Other rudeness: Starting browser without asking (some programs do this, it seems ICQ 2003 insists on starting Netscape for some reason), changing a browser’s start page without asking, and other browser-related stuff.

You may not (always) be able to avoid writing software that’s buggy, incomplete, etc… but you can make sure it isn’t rude.

Posted by Hans Nowak on 2003-05-26 04:34:59   {link}
Categories: general

The vim mug

The vim mug.

Bram Moolenaar (in newsgroup post): “Besides the Vim logo there are a dozens of Vim commands explained. We tried adding all the commands, but realized it’s difficult to drink coffee from a bath tub…”

In other merchandise news, SoBe has a new beverage, Grape Grog, and you can win a t-shirt. I want it… ˆ_ˆ

Posted by Hans ":q!" Nowak on 2003-05-25 12:34:51   {link}
Categories: general

--
Generated by Firedrop2.