Category Archives: Traits

Almost lickable: SVG button editor in Traits

I’ve been working on implementing a SVG renderer in ETS for the last 6 months, a little at a time. We (Enthought) hasn’t really made much noise about it because it is still pretty lacking. One of the goals is to replace WX’s terrible icon rendering with something much prettier. Although this is still very much a work in progress, I think we’re close enough to start showing it.

32x32_button_demo

Lets assume your users are all 18 years old and have perfect eyesight, these 32×32 icons are a waste of space, lets try 16×16

16x16 button demo

Or maybe your users are a bit, um, older

128x128 button demo

The code couldn’t be any easier, its essentially a drop in replacement for the Traits Button class. If you’re living on the trunk, you are able to run this demo from the Enable/examples/savage directory.

A note about the icons in the demo: They come from the Oxygen icon set, Creative Commons 3.0 for the licenses wonks. They should have more color, but the renderer currently only supports 2 gradient stops, and these have gradients with significantly more stops.

SciPy 2008 Swarm

During the “State of SciPy” presentation that Jarrod Millman and I gave this year at the SciPy 2008 Conference, we showed a “code swarm” video that was put together by David Martin and Chris Galvan. It’s a first-of-it’s-kind, because it combines repositories from several projects; namely NumPy, SciPy, Mayavi, Chaco, Traits, and Matplotlib.

Among other things, you can see how the number of people involved and the level of code production has really accelerated over time.

Enjoy!

Click Here for the Video

Getting Started with 3.x Enthought Technologies

For newcomers to the Enthought Tool Suite, I’ve just finished a fairly lengthy tutorial called Getting Started With Enthought Technologies. It shows you how to create your first Trait, Traits UI, Chaco plot, and Envisage application! It’s a partial update of the older 2.x version of the tutorial.

I sure wish someone had pointed this out to me when I first started with ETS.

Traits 3.0 released!

I am very pleased to announce that Traits 3.0 has just been released!

All Traits projects have been registered with PyPi (aka The Cheeseshop)
and each project’s listing on PyPi currently includes a source
tarball. In the near future, we will also upload binary eggs for
Windows and Mac OS X platforms. Installation of Traits 3.0 is now as
simple as:

easy_install Traits

The Traits projects include:

The Traits project is at the center of all Enthought Tool Suite
development and has changed the mental model used at Enthought for
programming in the already extremely efficient Python programming
language. We encourage everyone to join us in enjoying the productivity
gains from using such a powerful approach.

The Traits project allows Python programmers to use a special kind of
type definition called a trait, which gives object attributes some
additional characteristics:

  • Initialization: A trait has a default value, which is
    automatically set as the initial value of an attribute before its first
    use in a program.
  • Validation: A trait attribute’s type is explicitly declared. The
    type is evident in the code, and only values that meet a
    programmer-specified set of criteria (i.e., the trait definition) can be
    assigned to that attribute.
  • Delegation: The value of a trait attribute can be contained either
    in the defining object or in another object delegated to by the trait.
  • Notification: Setting the value of a trait attribute can notify
    other parts of the program that the value has changed.
  • Visualization: User interfaces that allow a user to interactively
    modify the value of a trait attribute can be automatically constructed
    using the trait’s definition. (This feature requires that a supported
    GUI toolkit be installed. If this feature is not used, the Traits
    project does not otherwise require GUI support.)

A class can freely mix trait-based attributes with normal Python
attributes, or can opt to allow the use of only a fixed or open set of
trait attributes within the class. Trait attributes defined by a classs
are automatically inherited by any subclass derived from the class.

My Scientific Tool Stack

Numenta is distributing some of my favorite tools with their NuPIC toolkit including Python itself (on windows), wxPython, IPython, Traits and matplotlib. They’re also building some of their prototype and example applications using Traits. Enthought’s typical tool stack for building scientific apps looks like this (with the stuff Numenta currently distributes in white letters):

Yesterday, I gave a brief talk [.pdf] about the stack of tools that Enthought uses for building scientific applications at Numenta’s HTM Workshop (a gathering of over 200 folks interested in their library which implements Jeff Hawkins’ Hierarchical Temporal Memory ideas). My talk included a very gentle introduction to Traits/TraitsGUI.

I also briefly demonstrated some of the capabilities of the Chaco library (2D visualization) by showing some of the examples, and Mayavi (3D visualization) as an example of a Traits and Envisage (plugin framework) application.

Of particular interest to me today: there was a presentation by Subutai Ahmad showing a nice TraitsGUI-based node inspector for Numenta’s HTM library. It reminded me a lot of the “GUI for free” that happened with the TConfig project.

Traits for doing Reactive Programming

I have done event-driven programming. I have done structured programming. I’ve done OOD that was exceeded only by the Platonic Ideal. I’ve done spaghetti code that would make an Italian chef proud. But I’ve never, until coming to Enthought, done Reactive Programming.

Enthought’s Traits module leads to doing a different kind of software development. I think Reactive Programming is the best way to describe Traits programming. It’s possible to do some really elegant things with it: clean, tight, transparent. And it’s possible to do some evil things too: hidden-dependencies, and obfuscated code.

I’ll see about getting some examples up soon. But not today. Not on my Friday afternoon.