ah cheers John. I changed it to courier and it aligned great. Can't
believe I spend five hours fiddling with it. just one of those days ..
Thanks.
On 6/26/05, Nikos Kouremenos <[EMAIL PROTECTED]> wrote:
> you may also want to try gtksourceview (in gnomepythonextras IIRC)
>
> On 6/25/05, John Ehresman <[EMAIL PROTECTED]> wrote:
> > I think you're using Arial, which is a variable width font. You need to
> > use a fixed width font such as Courier, tab stops, or lay things out
> > using multiple widgets to get the fields to line up.
> >
> > John
> >
> > Prash wrote:
> > > Here's a weird one Guys. I'm trying to format a string with fixed
> > > length fields and display in a textview. The format is absolutely
> > > perfect when I print it out to a terminal with all the fields neatly
> > > aligned. When I write the same thing to a textview, they look really
> > > out of place with fields not aligned at all. What am I missing?
> > > Interestingly when I copy everything (ctrl + c) from textview and
> > > paste it to gedit. They are neatly aligned ???
> > >
> > > Any ideas?
> > >
> > > Here's my code.
> > >
> > > writeTextView(textview, "a", "debug", fmtrecord("field1,field2,field3")
> > > + "\n")
> > >
> > >
> > > def fmtrecord(rowstr):
> > > srstr = rowstr.split(",")
> > > fmtstr = string.rjust(srstr[0].strip(), 15) +
> > > string.rjust(srstr[1].strip(), 15) + string.rjust(srstr[2].strip(),
> > > 15)
> > > return fmtstr
> > >
> > > def writeTextView(tview, mode, type, wstr):
> > > tbuf = tview.get_buffer()
> > > ttable = tbuf.get_tag_table()
> > > if mode == 'w':
> > > tbuf.set_text("")
> > > sob, eob = tbuf.get_bounds()
> > > tagexists = ttable.lookup(type)
> > > if (tagexists == None):
> > > tag = gtk.TextTag(type)
> > > if type == 'error':
> > > tag.set_property("font", "Arial")
> > > tag.set_property("foreground", "red")
> > > tag.set_property("size-points", 12)
> > > tag.set_property("weight", 400)
> > > elif type == 'warn':
> > > tag.set_property("font", "Arial")
> > > tag.set_property("foreground", "orange")
> > > tag.set_property("size-points", 12)
> > > tag.set_property("weight", 400)
> > > else:
> > > tag.set_property("font", "Arial")
> > > tag.set_property("foreground", "blue")
> > > tag.set_property("size-points", 10)
> > > tag.set_property("weight", 400)
> > > ttable.add(tag)
> > > else:
> > > tag = tagexists
> > >
> > > tbuf.insert_with_tags_by_name(eob, wstr, type)
> > > _______________________________________________
> > > pygtk mailing list [email protected]
> > > http://www.daa.com.au/mailman/listinfo/pygtk
> > > Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/
> >
> > _______________________________________________
> > pygtk mailing list [email protected]
> > http://www.daa.com.au/mailman/listinfo/pygtk
> > Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/
> >
>
>
> --
> Nikos Kouremenos | Jabber ID: [EMAIL PROTECTED] |
> http://members.hellug.gr/nkour
>
_______________________________________________
pygtk mailing list [email protected]
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/