up with PyGUI!

Nicolas Fleury nid_oizo at yahoo.com_remove_the_
Thu Sep 23 10:41:47 EDT 2004


Hans Nowak wrote:
> I'm not sure what you mean.  One known issue is, that there is some 
> redundancy when creating a control and adding it to its parent:
> 
>   b = Button(parent, ...)
>   parent.AddComponent(b, ...)

What I'm suggesting is to avoid the redundacy and do:
parent.Add(Button(...))

I've done it for some GUI framework where I work encapsulating wxPython. 
  The drawback is that you need to delay the creation of widgets, which 
means some attributes might be stored twice.  But it's definitely easier 
to use.

Another thing I'm suggesting is a mechanism to not destroy a widget 
until it's corresponding python object is destroyed.  It's more complex, 
but Python has already ownership with refcount, garbage collection, etc. 
and I think a truly pythonic GUI framework should use the same ownership 
mechanism.

> I am thinking of ways to make this simpler.  One possible solution would 
> be to accept a 'layout' parameter:
> 
>   b = Button(parent, ..., layout={'expand': 'both', 'border': 2})
> 
> ...but I'm not sure that actually makes things simpler or more readable.

I personally prefer Java-Swing-Layout and wxPython-sizers approach.  I 
think it's better to add widgets in the layout.

> It's also possible to do something like this:
> 
>   parent.Add(some_control, parameters_for_control, parameters_for_layout)

Again, I think layouts/sizers are very nice, since the way to add can be 
very different dependending on the layout/sizer.  For example, 
specifying col and row when adding to a GridBagLayout.

>> It could also be a good idea to take the occasion to respect PEP8.  
> 
> Which recommendations of the style guide does the Wax code violate?

IIRC, method names beginning with lowercase, as all the Python API.

>> Note also that "import wax" would be better than "from wax import *".
> 
> I'm considering it.  This way, it would also be possible to import 
> things on demand.  On the other hand, I don't like to write 'wax.' 
> before everything.

It's just that when you work multiple modules, autocompletion for a 
module doing a "from wx import *" is a nightmare (and is also slowing 
debuggers, since so many symbols are in each module namespace).  If wax 
becomes big, it would also be a pain.  You can do "import wax as w" ;)

Regards,
Nicolas



More information about the Python-list mailing list