Not dead yet

I’m still here. I’m going to post the previous examples .dmg with some corrections pointed out by Bob Ippolito (4-space indents, don’t modify data directly in the Bundle). I’ve been quiet because a) I’ve been hitting some walls with Renaissance and investigating work-arounds and alternatives, and b) my coding/blogging time is pretty much between the time I get the kids to bed and the time my wife comes home from tutoring.

I’m investigating the PyGUI and Wax APIs, to see if they are worth porting to run on top of Cocoa (PyGUI runs on Carbon, Wax runs on top of wxPython). Both are attempts to make GUI creation more “Pythonic,” which is a Good Thing™. I have figured out how to get the menus initialized using pure Python (on top of PyObjC, of course), or maybe the newer pyobjc/py2app has fixed the problem, but it is possible to build applications in Python with no Nib file (or Renaissance .gsmarkup file) at all. My earlier inabillity to do that is what drove me to Renaissance in the first place.

I’ve also discovered the nibtool utility, which I did not know about. This allows you to see a textual representation of the nibs created by Interface Builder, search and replace strings (class names, etc.). This is a major discovery. Now if you could take the textual representation and put it back… I’m going to have to investigate this further.

In other news, I will be giving a presentation on Tuesday, February 1 at the Vancouver Zope and Python Users Group (VanPyZ) at 7:00 p.m. It will be a variation on the talk I gave in December to the XML users group, updated with what I’ve been exploring since then. Specifically I will show a simple (Hello World) application built three different ways, with Renaissance, with Interface Builder, and in pure Python. I’ll also show some apps written in other toolkits (wxPython, tkinter) for comparison. I hope some of my readers are close enough to make it.

I’ll also be attending the Northern Voice blogging conference here in Vancouver on Saturday, February 19th. I’m looking forward to meeting some fellow bloggers face to face, rather than RSS to RSS.

Finally, I managed to install Python 2.4 today, and so far nothing has been obviously screwed up, so I’ll be exploring some of the crunchy new features here in the near future.

More posts coming soon. Honest!

Slides and code posted

My talk at VanX last night was a success. Not many people showed (too close to Xmas), but the ones who did seemed to enjoy my presentation on Cocoa, Python, and Renaissance. Gerald was a great host, SchemaSoft provided a good (and convenient!) venue, Paul came to show support, and BlastRadius (my employer) sponsored the snacks. After we went to Mira in Yaletown for beers and tech talk, had the whole place to ourselves, and a musician playing Flamenco guitar, then I walked across the bridge to home. A great end to a great evening.

I’ve posted my slides at using Eric Meyer’s neat S5 tool to put the whole slideshow into one HTML file.

I’ve also built a new .dmg containing all the source code and built, runnable examples (seven of them now), although they’re not all fully functional yet. More example gsmarkup to view, improved setup scripts, and they all have icons now. The file is examples 2004-12-17 on SourceForge.

I’ve been working hard to put this all together, which hasn’t left much time for posting, but I will have a lot more to say real soon now.

Hello Renaissance

In my last post I promised a Hello World program for PyObjC + Renaissance. If you haven’t got those installed, or aren’t sure, please check out the prerequisites.

We’ll be creating four files, each of which will be a template for upcoming examples. The menus will be defined in MainMenu.gsmarkup, the application window will be in MainWindow.gsmarkup, the application code will be in, and the py2app build script will be in There is no reason that the menus and window have to be separated this way, but it will serve as an example for later, more complex applications, when you’ll want to load in code from multiple files.


<?xml version="1.0"?>
<!DOCTYPE gsmarkup>
        <menu type="main">
            <menu title="Hello World" type="apple">
                <menuItem title="About Hello World"
                <menu title="Services" type="services"/>
                <menuItem title="Hide Hello World" action="hide:" key="h"/>
                <menuItem title="Hide Others" action="hideOtherApplications:"/>
                <menuItem title="Show All" action="unhideAllApplications:"/>
                <menuItem title="Quit Hello World" action="terminate:" key="q"/>
            <menu title="Edit">
                <menuItem title="Cut" action="cut:" key="x"/>
                <menuItem title="Copy" action="copy:" key="c"/>
                <menuItem title="Paste" action="paste:" key="v"/>
                <menuItem title="Delete" action="delete:"/>
                <menuItem title="Select All" action="selectAll:" key="a"/>
            <menu title="Window" type="windows">
                <menuItem title="Minimize Window" action="performMiniatureize:"
                <menuItem title="Bring All to Front" action="arrangeInFront:"/>


<?xml version="1.0"?>
<!DOCTYPE gsmarkup>
        <window title="Hello World" closable="NO" >
                <label>Hello World!</label>
                <button title="Click this button to quit" action="terminate:"/>

from Foundation import *
from AppKit import *
from Renaissance import *
class MyApplicationDelegate(NSObject):

    def cut_(self, sender):

    def applicationDidFinishLaunching_(self, notification):
        NSBundle.loadGSMarkupNamed_owner_('MainWindow', self)

def main():
    app = NSApplication.sharedApplication()
    delegate = MyApplicationDelegate.alloc().init()
    NSBundle.loadGSMarkupNamed_owner_('MainMenu', delegate)
if __name__ == '__main__': main()

Minimal example, run with:
% python py2app
from distutils.core import setup
import py2app
    data_files = ['MainMenu.gsmarkup', 'MainWindow.gsmarkup'],
    app = [''],


OK, so 80 lines of code may seem excessive for a Hello World program. We could certainly do it in less, perhaps 20 total lines of Python and Renaissance. But what we have here is a complete working Cocoa application which behaves properly to standard keyboard shortcuts, supports services, etc. And that’s not bad for 80 lines of code.