up with PyGUI!

Donnal Walter donnal at donnal.net
Fri Oct 15 09:03:56 EDT 2004


Carlos Ribeiro wrote:
> On Fri, 24 Sep 2004 22:12:46 -0700 (Pacific Standard Time), Brendan
> Barnwell <brenbarn at brenbarn.net> wrote:
> 
>>        My implementation essentially does this as well.  However, I
>>have devised a metaclass (called ClassObj) that does not actually
>>replace the class with an instance.  Instead, each class keeps a reference
>>to singleton instance.  All attributes are stored on the class object, but
>>methods are forwarded to the instance (since Python won't allow you
>>to call methods on a class).  The advantage of this is that the classes
>>can even be subclassed.  This metaclass largely eliminates the
>>distinction between classes and objects; a ClassObj can effectively
>>function as either.
> 
> 
> Well, it took me sometime to figure out if I should leave inner
> classes as classes or instantiate them. It's funny because my approach
> ends up being similar to yours -- the class is instantiated by the
> metaclass, and in the process the original class declaration is lost,
> which means that it turns into a singleton for all practical purposes.
> 
> The reasons why I decided to instantiate inner classes were:
> 
> 1) It's easier to process the resultin class declaration, because all
> attributes are instances. Before doing it I had to put some "isclass"
> checks to take different actions depending on the type of the
> attribute. It's not needed anymore (not to the same extent, at least).
> 
> 2) The original class is not needed really for subclassing. It's not
> convenient anyway, because you'ld need dot notation to find the inner
> class declaration. My suggestion is that all classes that are supposed
> to be subclassed can be safely declared at the top level, as in:

Pardon me for jumping in late here and without reading the entire thread 
carefully. Nevertheless, you might be interested in the declarative 
syntax developed for Mindwrapper (version 0.3 of which, unfortunately, 
has not yet been released or published). Attached is a screen shot of a 
wxPython panel created with the attached Mindwrapper notation. First of 
all, every mw.Panel or mw.Subpanel has a *buit-in sizer* (that can be 
turned off with cols=0, rows=0). The type of sizer is controlled with 
what appear to be class attributes, but a metaclass takes these 
attributes and uses them to set up the appropriate sizer. Every compound 
presenter is defined using the "assemble/add" syntax that allows one to 
declare proportion = 1, grow = True, for example. Also, the data model 
behind each widget is declared using "args = ref.tPeak" for example.

If you are interested in the implementation I am planning to make it 
available soon, but I am still adding presenters and working on 
documentation.

Donnal Walter
Arkansas Children's Hospital
-------------- next part --------------
A non-text attachment was scrubbed...
Name: pk.png
Type: image/png
Size: 13257 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/python-list/attachments/20041015/1d934cad/attachment.png>
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: pub_pharmacokinetics.py
URL: <http://mail.python.org/pipermail/python-list/attachments/20041015/1d934cad/attachment.ksh>


More information about the Python-list mailing list