General
resource handling module for Python.
It is developed with
wxPython GUI resources in mind, but unlike the XRC
resource system, this is an universal solution, applicable to anything
you can
call a resource and much more flexible.
Current
release: 1.1
Current version: 1.1.0
The
idea behind a pyprc resource is that the creation of program resources
like a wxPython gui object is a task involving several calls to several
different functions with some specific parameters.
If
this calls are grouped - packs of parameters for every call to a function
and packs of such parameter packs for every different function, we get
a
description of the resource creation process. This is exactly what the
pyprc
script is doing and a function in the pyprc module is capable of understanding
this description and actually executing the functions with the given parameters
and returning the resource at the end. This way the resource creation
is fully
separated from the main program and still universaly free - one could
do just
anything.
The
pyprc resources may use parameters passed to the function which creates
them and execute unlimited calls and statements, using their results in
the
next calls.
The example resource is a wxPython about box with working OK button.
PyPRC
resource format 1.1.0 Short Description:
The first line of the script sets pyprc resource
format like this:
pyprc_format
= '1.1.0'
If
the first line doesn't set pyprc_format,
the script is assumed to be in the old format, version 1.0.0. Currently
it doesn't matter to what value pyprc_format is set, but it will in future
if new format versions are created.
Pyprc
resource format 1.1.0 is based on keywords which define executable sections
and sections contain python code.
For more details see documentation in example.pyprc
which is provided with release.
The
pyprc script may do anything like a normal script -
for example to do some kind of initialization. Everything which is not
recognized as a pyprc-specific, gets executed via exec statement.
The
lines in the pyprc script are executed in the environment of the pyprc
module and may do direct modifications to this environment (like importing
another module)
In
the best case the pyprc script contains as little python code as
possible outside the resource declarations.
|