[PEAK] Connecting the Trellis to non-trellis systems

Sergey Schetinin maluke at gmail.com
Tue Mar 11 11:52:03 EDT 2008

I have a (proprietary) library that does a lot of things mentioned 
except for Trellis integration. I looked into it, but can't work on that 
until I finish a few milestones for my current contract. I don't mind 
open-sourcing the library if there's enough people interested in working 
on it (as compared to just using it). One note though: why are you using 
camel-case in method and function names? It's ugly, but even if that's a 
personal preference, it also breaks the python code style (there's even 
a PEP on that IIRC).

So far the only Trellis integration I've got is editing the properties 
of the windows, so the older-style code looks like this:

ok = add(panel, Button("OK")

setborder(ok, 4)
align(ok, RIGHT)

New-style is:

props(ok).border = 4
props(ok).align = RIGHT


props(ok).set(border=4, align=RIGHT)

Event binding:

onevent(ok, CLICK, lambda: ....)


@on(ok, CLICK)
def ...

The event handlers can decide to accept additional info from event 
dispatcher (sometimes some info is only present in the event object 
while the event is being processed). There also needs to be a way to 
stop event propagation, so this works as expected:

@on(frame, CLOSE)
def onclose(stop):
     if not may_close():

This library is being used for all new development of S3 Backup 
(s3bk.com) and the old code is being migrated to it as well (the old one 
used a declarative approach).

Also a word of advice for people just starting with GUI development -- 
never use visual GUI editors, XRC or whatever it's simply not worth it 
-- you loose a lot of control and don't gain anything except for more 
complexity -- there are no time benefits at all.

- Sergey

Phillip J. Eby wrote:
> At 09:50 AM 3/11/2008 +0200, Peter Damoc wrote:
>> Hi Phillip,
>> Are there any GUI examples? wxPython examples would be ideal. :)
> Not yet, but there will be at some point.  Gotta finish, test, and 
> document the code first!
> However, I envision having something like an "EventConnector(wxobject, 
> wxevent, defaultobject)" cell, whose subscribe/unsubscribe methods will 
> simply call down to bind/unbind.  And then those connectors will be 
> wrapped in APIs like 'getMousePosition(wxobject)' that you'll be able to 
> use in rules, to have the rule get recalculated when the mouse position 
> changes.  Or like 'mouseDown(wxobject)', that goes true when a mouse 
> down event occurs, etc.
> My general idea is to make these either generic functions, or methods of 
> a context.Service, so that you can write rules that are in fact not 
> specific to the GUI backend in use.  That way, you could write code 
> that's not only cross-platform, but would also work with Qt, wx, Tk, or 
> any other unpronounceable pair of consonants that stands for a GUI 
> framework.  ;-)
> I'm pretty excited, though, about the part where we won't have to use 
> those %$$&%%($ "bind" calls any more, or figure out how to reverse-map 
> the GUI's events into our application's state machines.  Instead, we'll 
> get to treat the GUI like a *library* instead of a framework.
> Looks like the Trellis is going to be able to "untwist" more than just 
> Twisted, in other words.
> _______________________________________________
> PEAK mailing list
> PEAK at eby-sarna.com
> http://www.eby-sarna.com/mailman/listinfo/peak

More information about the PEAK mailing list