Re: Language attribute of text tag nog applying



Op Do, 2010-05-20 om 01:08 -0400 skryf Behdad Esfahbod:
> On 05/19/2010 08:03 AM, F Wolff wrote:
> > My attached program is setting a text tag to apply for a whole buffer
> 
> Forgot to attach the program?
> 
> I'm guessing that you are not calling (the Python equivalent of):
> 
>   setlocale (LC_ALL, "")
> 
> Also, try with LANG=mk instead of LANGUAGE=mk.  Again, without seeing your
> code I can't really help.


Terribly sorry about the attachment. I believe it is attached now.

I also added a call to setlocale now, but it doesn't seem to affect the
program in any way. The LANG environment variable also seems to have no
effect.

Thank you for looking into it.

Friedel


#!/usr/bin/env python
# -*- coding: utf-8 -*-

import pygtk
pygtk.require('2.0')
import gtk
import pango
import locale

class Languages:

    def destroy(self, widget, data=None):
        gtk.main_quit()

    def __init__(self):
        self.window = gtk.Window(gtk.WINDOW_TOPLEVEL)
        self.window.connect("destroy", self.destroy)
        vbox = gtk.VBox(True, 0)
        self.window.add(vbox)

        ru = gtk.TextView()
        ru.modify_font(pango.FontDescription("DejaVu Serif Italic 24"))
        ru_buffer = ru.get_buffer()
        ru_buffer.set_text(u"Russian: \u0442")
        tag = ru_buffer.create_tag("lang-tag", language='ru', foreground='blue')
        ru_buffer.apply_tag_by_name("lang-tag", ru_buffer.get_start_iter(), ru_buffer.get_end_iter())

        mk = gtk.TextView()
        mk.modify_font(pango.FontDescription("DejaVu Serif Italic 24"))
        mk_buffer = mk.get_buffer()
        mk_buffer.set_text(u"Macedonian: \u0442")
        tag = mk_buffer.create_tag("lang-tag", language='mk', foreground='red')
        mk_buffer.apply_tag_by_name("lang-tag", mk_buffer.get_start_iter(), mk_buffer.get_end_iter())

        vbox.add(ru)
        vbox.add(mk)
        self.window.show_all()

    def main(self):
        gtk.main()

if __name__ == "__main__":
    locale.setlocale(locale.LC_ALL, "")
    hello = Languages()
    hello.main()


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]