Re: [pygtk] Gobject properties to PyObject attributes mapping

2003-08-14 Thread Jan Weil
Jan Weil schrieb: I don't like this idea either. Especially because it's quite easy to emulate this behaviour in Python (see example attached). That's obviously not an option if you had to wrap every gtk widget by hand. This one wouldn't let me sleep. But it's really fun (see example attached). G

Re: [pygtk] Gobject properties to PyObject attributes mapping

2003-08-14 Thread Jan Weil
Iñaki García Etxebarria schrieb: But IMO the main question is whether it is really advantageously to map the properties to attributes. I think so, it produces readable code, and many times is very natural. And, to me at least, the design of the properties api in gobject is thought with this kind o

Re: [pygtk] Gobject properties to PyObject attributes mapping

2003-08-14 Thread Jon Willeke
This may not be a democracy, but I would vote against this change. Merging namespaces like this is asking for trouble. If it is done at all, it should only be at the explicit request of the programmer (e.g., import gtk.__propertyHack__ as gtk). On Fri, 2003-08-08 at 15:20, Iñaki García Etxebarri

Re: [pygtk] Gobject properties to PyObject attributes mapping

2003-08-14 Thread Jan Weil
Christian Reis kiko at async.com.br wrote: Ah; Note that this is wrong here. You should not return None from getattr, or all lookups on the object for non-existent attributes will return None. This should be: try: return self.__dict__[key] except KeyError: raise AttributeErr

Re: [pygtk] Gobject properties to PyObject attributes mapping

2003-08-14 Thread Christian Reis
On Mon, Aug 11, 2003 at 01:11:01AM +0200, Jan Weil wrote: > I am by no means an expert of OOP but what I read is that public data > members in the long run tend to be unflexible. > Thus you typically provide a pair of accessors like set_value, get_value > (set_property/get_property). Well, it co

Re: [pygtk] Gobject properties to PyObject attributes mapping

2003-08-14 Thread Christian Reis
On Sun, Aug 10, 2003 at 11:36:05AM +0200, Jan Weil wrote: > Did you try this code? Are you suggesting I don't test my code submissions? :o) No; I don't have PyGTK2 available on my network. > The problem is that if you assign to __properties in __init__, > __setattr__ is called which calls __get

Re: [pygtk] Gobject properties to PyObject attributes mapping

2003-08-14 Thread Iñaki García Etxebarria
El vie, 08-08-2003 a las 15:07, Gustavo J. A. M. Carneiro escribió: > > label = gtk.Label() > > label.label = 'Hello World' # Changes the label in the gui > > print label.label # prints 'Hello World' > > Perhaps it is wiser to add a small prefix to the python attribute, to > avoid possible confl

Re: [pygtk] Gobject properties to PyObject attributes mapping

2003-08-12 Thread Iñaki García Etxebarria
> But IMO the main question is whether it is really advantageously to map > the properties to attributes. I think so, it produces readable code, and many times is very natural. And, to me at least, the design of the properties api in gobject is thought with this kind of purposes in mind. > What a

Re: [pygtk] Gobject properties to PyObject attributes mapping

2003-08-11 Thread Christian Reis
On Sun, Aug 10, 2003 at 03:55:56AM +0200, Jan Weil wrote: > Good night, > > class MyObject: > def __init__(self): > if issubclass(self.__class__, gobject.GObject): > self.properties = [] > for param in gobject.list_properties(self): > self.proper

Re: [pygtk] Gobject properties to PyObject attributes mapping

2003-08-11 Thread Jan Weil
I don't like this idea either. Especially because it's quite easy to emulate this behaviour in Python (see example attached). Jan Jon Willeke schrieb: This may not be a democracy, but I would vote against this change. Merging namespaces like this is asking for trouble. If it is done at all, it

Re: [pygtk] Gobject properties to PyObject attributes mapping

2003-08-11 Thread Iñaki García Etxebarria
Hi, El dom, 10-08-2003 a las 01:04, Jan Weil escribió: > I don't like this idea either. > Especially because it's quite easy to emulate this behaviour in Python > (see example attached). Well, as long as I can write the Python code as I want, I don't care much about the underlying implementation

[pygtk] Gobject properties to PyObject attributes mapping

2003-08-11 Thread Jan Weil
Did you try this code? I get (and this is what I expected): [...] File "./mygtk.py", line 21, in __getattr__ if self.__properties and key in self.__properties: File "./mygtk.py", line 21, in __getattr__ if self.__properties and key in self.__properties: File "./mygtk.py", line 21, i

Re: [pygtk] Gobject properties to PyObject attributes mapping

2003-08-09 Thread Gustavo J. A. M. Carneiro
A Qui, 2003-08-07 às 19:22, Iñaki García Etxebarria escreveu: > Howdy everyone, > > Attached goes a patch against pygtk 1.99.17 that lets you do things like > --- > label = gtk.Label() > label.label = 'Hello World' # Changes the label in the gui > print label.label # prints 'Hello World' Perhap

[pygtk] Gobject properties to PyObject attributes mapping

2003-08-08 Thread Iñaki García Etxebarria
Howdy everyone, Attached goes a patch against pygtk 1.99.17 that lets you do things like --- label = gtk.Label() label.label = 'Hello World' # Changes the label in the gui print label.label # prints 'Hello World' --- for any gobject. I.e., setting gobject properties as if they were regular attribu

Re: [pygtk] Gobject properties to PyObject attributes mapping

2003-08-07 Thread Christian Reis
On Thu, Aug 07, 2003 at 08:22:06PM +0200, Iñaki García Etxebarria wrote: > Howdy everyone, > > Attached goes a patch against pygtk 1.99.17 that lets you do things like > --- > label = gtk.Label() > label.label = 'Hello World' # Changes the label in the gui > print label.label # prints 'Hello World