[pygtk] using pango style on edited text
Stephen George
steve_geo at optusnet.com.au
Thu Jan 31 09:42:20 WST 2008
Hi,
I have a text buffer, that I wanted to display in bold, slightly larger =
font and with some margins, for entire buffer, no need to change styles. =
(like setting a default font)
All I want is to set the entire buffer/view to a predefined font/margin =
style, user will not have options to change it
It seems the only way was to use pango, .. am I missing something?
I implemented that in my text buffer, .. however if use the textview to =
enter new text at the end of the text buffer, .. it's not in pango =
style, ... no margins, no bold.
If I enter new text in middle of my buffer, it takes on existing style.
I don't know how to make that new text at end of buffer insert in pango =
style.
My application, . looks up a message for a selected item in a list box, =
and displays that in the textview.
When a new item is selected, I clear the textview, and use the function =
addToBuffer() to add the new text. A user could then edit the text to =
add additional info, .. but as can be seen in picture, that text is not =
in 'style'.
addToBuffer() is only used for the initial insertion, ..If then someone =
enters into the textView and adds text (as editable), .. I don't know =
how it knows what style to insert in. Am I meant to be adding some =
support code to get it to add in 'style'
def createBufTags(self, textbuf):
import pango
table =3D textbuf.get_tag_table()
tag =3D gtk.TextTag('marketspeak')
tag.set_property( 'weight', pango.WEIGHT_BOLD)
tag.set_property( 'foreground', "black")
tag.set_property( 'left_margin', 10)
tag.set_property( 'right_margin', 10)
table.add(tag)
def addToBuffer(self, buf, speak ):
iter =3D buf.get_end_iter()
buf.insert_with_tags_by_name(iter, speak , "marketspeak")
Thanks
Steve
-------------- next part --------------
A non-text attachment was scrubbed...
Name: textview.jpg
Type: image/jpeg
Size: 10830 bytes
Desc: not available
Url : http://www.daa.com.au/pipermail/pygtk/attachments/20080131/dcd6ef97/t=
extview-0001.jpg
More information about the pygtk
mailing list