Re: [pygtk] gobject properties in pygtk 2.8

2005-09-13 Thread Gustavo J. A. M. Carneiro
On Tue, 2005-09-13 at 00:08 -0400, Chris Hoefler wrote: > Hi, > > I have a bit of gtk experience, but I am still fairly new to > python/pygtk and I don't quite understand how GObject properties work. > I've been digging through all of the documentation/examples I can find. > As far as I can tel

[pygtk] gobject properties in pygtk 2.8

2005-09-12 Thread Chris Hoefler
Hi, I have a bit of gtk experience, but I am still fairly new to python/pygtk and I don't quite understand how GObject properties work. I've been digging through all of the documentation/examples I can find. As far as I can tell there have been some changes to how custom properties of subclas

Re: [pygtk] GObject properties

2003-09-05 Thread Jan Weil
Lorenzo Gil Sanchez schrieb: Sorry, but I can't find the o.get_name and o.set_name methods in the gtklabel.c file (or any other file). Could you please put an example or give me some more detailed pointer? These methods were meant as an abstract example for a property called 'name' (take GtkWidget

Re: [pygtk] GObject properties

2003-09-05 Thread Lorenzo Gil Sanchez
El mar, 05-08-2003 a las 03:34, Jan Weil escribió: > To actually set or get a property a Python GObject calls the class methods > 'do_set_property' and 'do_get_property'. These methods are virtual which > means you'll have to implement them. > Typically most of the properties can also be controll

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

2003-08-14 Thread Jan Weil
Jan Weil schrieb: But could someone please enlighten me, why am I supposed to implement 'do_set_property' and 'do_get_property'? Once again the source was with me. I collected my experiences as a newbie to Glib's type and object system approaching it from the Python site. For me there were some p

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

Re: [pygtk] GObject properties

2003-08-06 Thread Christian Reis
On Tue, Aug 05, 2003 at 03:34:55AM +0200, Jan Weil wrote: > > Once again the source was with me. > I collected my experiences as a newbie to Glib's type and object system > approaching it from the Python site. > For me there were some pitfalls and therefore I want to share this with > the list.

Re: [pygtk] GObject properties

2003-08-02 Thread Jan Weil
Jan Weil schrieb: If I create a subclass of gobject.GObject in Python, can I somehow install my own set of properties? Sorry for constantly decreasing the SNR of this list. The source is with me and I eventually found the example for gobject properties. I'm even learning how to search a mailing l

[pygtk] GObject properties

2003-08-01 Thread Jan Weil
If I understand this correctly, every GObject (class) has a set of properties and whenever one of these properties is changed a 'notify' signal is emitted. So that in terms of MVC a view can connect to its model's 'notify' signal. Is that right so far? If I create a subclass of gobject.GObject i