I am close to releasing the new version of gnome-python and pygtk.
Here is a list of what has changed:
* gtkmodule.c: added optional support for not catching exceptions
in
callbacks. This way it should be a lot easier to debug a pygtk
program with pdb.
* gtkmodule.c, gtk.py: a few fixes for problems sent in by
Chi-Deok Hwang. This includes a fix to GtkWidget.event(),
assignments to GtkStyle attributes throwing exceptions,
font loading getting reference counting correct and throwing
exceptions for bad font names and allowing None to be passed
as a colour to GnomeCanvasItem.set() (the fix is in pygtk).
* generate/gtklists.defs (gtk_ctree_new): I had missed this
function in previous releases.
* pygnome/gnome/affine.py: new file that should help people
compose
affine transformations relatively easily. It allows you to
quickly
create rotations, scalings, translations and allows you to compose
any number of affine transformations or invert them.
* pygnome/gnome/ui.py: added GnomeCanvasItem.affine_relative and
GnomeCanvasItem.affine_absolute.
* pygnome/gnomeuimodule.c: added the PYGTK_FATAL_EXCEPTIONS
handling
code to this module as well.
Added gnome_canvas_item_affine_{relative,absolute}.
* */Makefile.am: changes so that you can build gnome-python with
build directory != source directory.
People were wondering about if I could add an affine transformation helper
module to gnome-python so I have. I have included it at the end of the
message for people who are interested (if it looks like there are some
bugs in it, please send in the reports)
James.
--
Email: [EMAIL PROTECTED]
WWW: http://www.daa.com.au/~james/
----- affine.py -----
"""A module that should help create the affine transformations you would use
for transforming GnomeCanvas items.
As a little background, an affine transformation is a linear transformation
and a translation. The linear transformationcan be represented by a matrix
and the translation by a vector. So a general affine transformation looks
like this:
[ x ] -> [ a b ][ x ] + [ e ]
[ y ] [ c d ][ y ] [ f ]
As you can see, the affine transformation is defined by the six numbers in
the matrix and column vector. For the GnomeCanvas item functions, affine
transformations are represented by a flat sequence of the form
(a, c, b, d, e, f)
This module attempts to make it easy to create complex affine transformations
from simpler ones like rotation, scaling and translation.
"""
import math
# These functions create base affine transformations that can be used to build
# more complex ones.
def identity():
"""The identity affine transformation"""
return (1, 0, 0, 1, 0, 0)
def scale(sx=1, sy=1):
"""Scale by a factor of sx in the X direction and sy in Y direction"""
return (sx, 0, 0, sy, 0, 0)
def rotate(radians=None, degrees=0):
"""Rotate in either degrees or radians"""
if not radians: radians = degrees * math.pi / 180.0
s = math.sin(radians)
c = math.cos(radians)
return (c, s, -s, c, 0, 0)
def translate(tx=0, ty=0):
"""Translate by (tx,ty)"""
return (1, 0, 0, 1, tx, ty)
# These functions can be used to combine or manipulate other affine
# tranformations
def compose(a1, *affines):
"""Compose a number of affine transformations together
If the affines a1,a2,a3 are passed as arguments, then the
resulting
affine A will give A(x) == a1(a2(a3(x)))"""
if affines == (): return a1
a2 = apply(compose, affines)
return (a1[0]*a2[0] + a1[2]*a2[1],
a1[1]*a2[0] + a1[3]*a2[1],
a1[0]*a2[2] + a1[2]*a2[3],
a1[1]*a2[2] + a1[3]*a2[3],
a1[0]*a2[4] + a1[2]*a2[5] + a1[4],
a1[1]*a2[4] + a1[3]*a2[5] + a1[5])
def invert(aff):
det_inv = 1 / (aff[0]*aff[3] - aff[1]*aff[2])
return (aff[3] * det_inv,
-aff[1] * det_inv,
-aff[2] * det_inv,
aff[0] * det_inv,
(aff[2]*aff[5] - aff[3]*aff[4]) * det_inv,
(aff[1]*aff[4] - aff[0]*aff[5]) * det_inv)
To unsubscribe: echo "unsubscribe" | mail [EMAIL PROTECTED]