Hi Gian,
thanks for your help.
I find the problem:
tv1.set_attribute(c, text=0)
I used:
tv1.set_attribute(c, markup=0)
So, with every '&' the System went wrong. Is there an easy way to mask '&'
instead of replacing it with '&'?
Here comes my code:
<code>
# -*- coding: utf-8 -*-
import pygtk
pygtk.require("2.0")
import gtk
def on_selection_changed(selection):
"""Just to show the values of the model"""
model, iters = selection.get_selected()
list = model.get(iters,0,1,2,3,4,5)
print ','.join(list)
w = gtk.Window()
w.connect("destroy", gtk.main_quit)
l = gtk.ListStore(str, str, str, str, str, str)
t = gtk.TreeView(l)
c = gtk.CellRendererText()
col = ['Number','Repr.','Name','Street','ZIP','City']
for i in range(6):
tv = gtk.TreeViewColumn(col[i])
tv.pack_start(c)
tv.set_attributes(c, markup=i)
t.append_column(tv)
sel = t.get_selection()
sel.connect('changed', on_selection_changed)
r = [('137100', 'MO', 'Figura Bauunternehmen\rInh. Dirk Figura', 'Daimlerring
55', '31135', 'Hildesheim'),
('101300', 'BE', 'Wilfried Afemann GmbH\rBauschlosserei', 'Postfach 12
16', '30882', 'Barsinghausen'),
('102200', 'MO', 'Albrecht Bau GmbH', 'Hauptstraße 29', '31079',
'Westfeld'),
('105100', 'BE', 'ATLAS HANNOVER Baumaschinen GmbH & Co.', 'Bremer Straße
4-6', '30880', 'Laatzen'),
('108450', 'HÄ', 'B & D Bau GbR', 'Geldkulenfeld 1', '31177',
'Harsum'), # This line works
('107000', 'HÄ', 'Peter Barthel\rBauunternehmen', 'Schlesierring 36',
'31177', 'Harsum'),
('108400', 'MO', 'bau Tec\rBaugesellschaft mbH', 'Langer Kamp 14',
'31139', 'Hildesheim'),
('107300', 'HÄ', 'Bau- und Hobby Markt\rSehnde GmbH', 'Peinerstr. 71',
'31319', 'Sehnde'),
('107600', 'HÄ', 'Wilhelm Bauer GmbH & Co. KG\r', 'Hägenstraße 15',
'30559', 'Hannover'),
('107800', 'GL', 'Bauking Nienburg GmbH & Co. KG\r', 'Celler Straße 24',
'31582', 'Nienburg')]
[l.append(v) for i,v in enumerate(r)]
w.add(t)
w.show_all()
gtk.main()
</code>
It's just a little bit longer.
Bye,
Volker
-------- Original-Nachricht --------
Datum: Thu, 26 Apr 2007 13:47:34 +0200
Von: "Gian Mario Tagliaretti" <[EMAIL PROTECTED]>
An: "Volker Helm" <[EMAIL PROTECTED]>
CC: [email protected]
Betreff: Re: [pygtk] Problems with \'&\' in treeview
> 2007/4/26, Volker Helm <[EMAIL PROTECTED]>:
>
> Hi,
>
> > I've got problems with the character '&' inside of a treeview.
>
> I just tried here and I have no problem with "&" char, do you have a
> working snippet? I guess the problem is somewhere else.
>
> Below an (ugly) example that maybe can be useful:
>
>
> import gtk
>
> w = gtk.Window()
> w.connect("destroy", gtk.main_quit)
>
> l = gtk.ListStore(str, str)
>
> t = gtk.TreeView(l)
>
> tv1 = gtk.TreeViewColumn("Column1")
> tv2 = gtk.TreeViewColumn("Column2")
>
> c = gtk.CellRendererText()
>
> tv1.pack_start(c)
> tv2.pack_start(c)
>
> tv1.set_attributes(c, text=0)
> tv2.set_attributes(c, text=1)
>
> t.append_column(tv1)
> t.append_column(tv2)
>
> l.append (['Test1','This and that'])
> l.append (['Test2','C & A'])
>
> w.add(t)
> w.show_all()
>
> gtk.main()
>
> cheers
> --
> Gian Mario Tagliaretti
> _______________________________________________
> pygtk mailing list [email protected]
> http://www.daa.com.au/mailman/listinfo/pygtk
> Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/
--
"Feel free" - 10 GB Mailbox, 100 FreeSMS/Monat ...
Jetzt GMX TopMail testen: http://www.gmx.net/de/go/topmail
_______________________________________________
pygtk mailing list [email protected]
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/