About Me
- Name: Dethe Elza
- Location: Vancouver, British Columbia, Canada
My long-term project is to write a book called "Programming for the Fun of It" to help people take control of their computers and enjoy doing it.
Links
Archives
A program is a process, not a thing. This also applies to life, the universe, and everything.
2004-11-03
A New Renaissance
Yesterday I laid out the issues I have with using Interface Builder to create Cocoa applications (whether in Objective-C or Python), and my requirements for a replacement. To sum up, here are the requirements again
As I hinted at previously, I think I've found the tool I was looking forin GNUstep Renaissance, and as an added bonus, it can be used to create applications for Linux, unix, and Windows using the GNUstep framework. So although I'm interested mainly in building applications for OS X, there is still a chance for cross-platform compatibility.
So what does Renaissance look like? It's and XML format, similar to HTML and Mozilla XUL (but simpler than XUL). Today I will cover how to install Renaissance and set it up to use from PyObjC.
Prerequisites (this is my setup, others may work, but I haven't tested them).
Once you have the prerequisites installed, you need to make Renaissance available from Python. In your site-packages directory (on my machine this is /System/Library/Frameworks/Python.framework/Versions/2.3/lib/python2.3/site-packages) add a Renaissance directory containing the following file:
__init__.py
Well, that was easy enough. Next up, a Hello World application.
- Declarative
- Simple *and* powerful
- Able to replace NIB files and Interface Builder
- Text-based, not binary
- Agile for rapid development, adapts to rapidly changing code
- Able to specify simple apps completely, in code, without resorting to pictures or talking the user through mouse gestures
As I hinted at previously, I think I've found the tool I was looking forin GNUstep Renaissance, and as an added bonus, it can be used to create applications for Linux, unix, and Windows using the GNUstep framework. So although I'm interested mainly in building applications for OS X, there is still a chance for cross-platform compatibility.
So what does Renaissance look like? It's and XML format, similar to HTML and Mozilla XUL (but simpler than XUL). Today I will cover how to install Renaissance and set it up to use from PyObjC.
Prerequisites (this is my setup, others may work, but I haven't tested them).
- A Mac
- OS X (10.3)
- PyObjC (1.1), available from http://pyobjc.sourceforge.net/
- py2app (0.1.4), available from http://pythonmac.org/wiki/py2app (we'll use this to build our double-clickable applications)
- Renaissance framework (0.8), available from http://www.gnustep.it/Renaissance/Download.html (this is the secret sauce)
Once you have the prerequisites installed, you need to make Renaissance available from Python. In your site-packages directory (on my machine this is /System/Library/Frameworks/Python.framework/Versions/2.3/lib/python2.3/site-packages) add a Renaissance directory containing the following file:
__init__.py
import objc, AppKit, Foundation
objc.loadBundle('Renaissance', globals(),
bundle_path='/Library/Frameworks/Renaissance.framework')
del objc, AppKit, Foundation
Well, that was easy enough. Next up, a Hello World application.
Comments:
<< Home
One of the things about Cocoa, and thus PyObjC, is that it expects applications to be run inside of a bundle (a specific set of folders). Building hello.py as an application creates those folders. So when you try to run, for instance:
pythonw hello.py
It will complain that it can't find MainMenu.gsmarkup or MainWindow.gsmarkup, because it is looking for them in a bundle, and the bundle it's finding is the pythonw bundle, not the hello.py bundle.
You could make it load by changing the paths for the gsmarkup files to be explicit, but I'm not sure if that would work, and it would almost certainly break things down the road, which would be harder to figure out.
If you're developing an application, it can be annoying to have to keep building it each time you touch a file (that loses a lot of the benefit of Python, after all). So what you can do is build it with
python setup.py py2app --alias
which will not copy the files, but just make aliases to them. It's very fast and you only have to do it again during development if you add new files to your project. Then you can work on your files (both Python and Renaissance) at will without having to rebuild. Of course, before you distribute your app you should rebuild it without the alias flag.
I hope this helps.
Post a Comment
pythonw hello.py
It will complain that it can't find MainMenu.gsmarkup or MainWindow.gsmarkup, because it is looking for them in a bundle, and the bundle it's finding is the pythonw bundle, not the hello.py bundle.
You could make it load by changing the paths for the gsmarkup files to be explicit, but I'm not sure if that would work, and it would almost certainly break things down the road, which would be harder to figure out.
If you're developing an application, it can be annoying to have to keep building it each time you touch a file (that loses a lot of the benefit of Python, after all). So what you can do is build it with
python setup.py py2app --alias
which will not copy the files, but just make aliases to them. It's very fast and you only have to do it again during development if you add new files to your project. Then you can work on your files (both Python and Renaissance) at will without having to rebuild. Of course, before you distribute your app you should rebuild it without the alias flag.
I hope this helps.
<< Home