Martijn Brouwer wrote:

I have problems creating a read-only tag in gtk.TextBuffer.

I have the following information:

1) from the API documentation of gtk.TextView:

gtk.TextView.set_editable
def set_editable(setting)
setting : whether it's editable

Sets the default editability of the gtk.TextView. You can override this default setting with tags in the buffer, using the "editable" attribute of tags.

So I have to change the editable atribute of my tag.

2) from the API documentation of gtk.TextTag:
Constructor
def __init__(name)
name : tag name, or NULL
Returns : a new gtk.TextTag

Creates a gtk.TextTag. Configure the tag using object arguments, i.e. using g_object_set().
3) From the API documentation of gtk.TextBuffer:
gtk.TextBuffer.create_tag
def create_tag(tag_name, first_property_name)
tag_name : name of the new tag, or NULL
first_property_name : name of first property to set, or NULL
Returns : a new tag

Creates a tag and adds it to the tag table for buffer. Equivalent to calling gtk.TextTag() and then adding the tag to the buffer's tag table. The returned tag is owned by the buffer's tag table, so the ref count will be equal to one.
If tag_name is NULL, the tag is anonymous.
If tag_name is non-NULL, a tag called tag_name must not already exist in the tag table for this buffer.
The first_property_name argument and subsequent arguments are a list of properties to set on the tag, as with g_object_set()

If I understand this well 3) contradicts 2) and is incorrect. It says that you can give more than a single parameter to the constructor, which is not true.

This is changed in the CVS version so that you can specify properties with create_tag() using keyword value pairs.

I think that the PyGTK docs are generated from the GTK+ docs and are sometimes incorrect or incomplete wrt PyGTK interfaces.

I can create a tag using
       self.Buffer.ReadOnly=self.Buffer.create_tag('ReadOnly')

But when I check whether it is editable using:
       self.Buffer.ReadOnly.get_property('readonly')

The property you want is 'editable'. You also need to check the 'editable-set' property to see whether the tag's 'editable' property is active in the tag; if not, the value of 'editable' is meaningless.

python complains:
TypeError: the object does not support the given parameter

What am I doing wrong? And where can I find a list of tag properties that I can change?

The GTK+ documentation contains a list of the TextTag properties. Try:
http://developer.gnome.org/doc/API/2.0/gtk/GtkTextTag.html

John


_______________________________________________
pygtk mailing list   [EMAIL PROTECTED]
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/

Reply via email to