What is Peggy?¶
Peggy helps you to create GTK applications that run out-of-the-egg.
It offers functions to load ressources (like .glade files, images, locales) from a (zipped or unzipped) egg.
Peggy is a thin layer on top of setuptools and PyGtk. It’s not doing much fancy stuff but can save you from reading some docs ;-)
Let’s say we have the following module:
mymodule |-- __init__.py `-- data |-- logo.png |-- main.glade `-- data.dat
and want to distribute it as an EGG. Peggy helps us to use the files in the data subdirectory, even if the module is installed as a zipped egg.:
>>> import peggy
First we create an instance of peggy.Peggy to handle our module:
>>> p = peggy.Peggy('mymodule')
Now we can load the glade file to get a gtk.glade.XML instance and use it to get our widgets:
>>> gladefile = p.get_glade('data/test.glade') >>> gladefile <gtk.glade.XML object at 0x9e22dc4 (GladeXML at 0x9b8de98)> >>> gladefile.get_widget('window1') <gtk.Window object at 0x9e22d4c (GtkWindow at 0xa08a0e0)>
Next we load the logo into a gtk.gdk.Pixbuf:
>>> logo = p.get_pixbuf('data/logo.png') >>> logo <gtk.gdk.Pixbuf object at 0x9ca252c (GdkPixbuf at 0xa0b1ae0)>
Finally we get the contents of data.dat into a string:
>>> s = p.get_string('data/test.txt') >>> s 'Just some data\n'
Peggy is alpha software and should be expected to have some serious bugs. Use it at your own risk.
Peggy is still under development and the API may change in the future.
Any feedback, suggestions or bugreports are welcome.
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
Get it using easy_install
> easy_install peggy
or download it here:
|peggy-0.02.tar.gz||9.7 KByte||2009-03-30 04:32||9975e6281061356cead175d32ebdc751|
|peggy-0.02-doc.tar.gz||16.7 KByte||2009-03-30 04:32||ab5d9e915ca01f82c723276de115169e|
Zdravko Nikolov has created packages for Fedora 12.