Saelyth
Saelyth

Reputation: 1734

python ttk treeview issues

I will be honest here and say that I'm playing with the treeviews and ttk without really understand how it works. Nevertheless, I'm getting some issues and after Googling for it I can't find a proper way to fix it. I use treeviews as listbox, since ttk doesn't have a listbox element.

But that adds an extra column at the end so i had to add to fix it:

chat.column('#3', stretch=NO, minwidth=0, width=0)

But that would only add the message on the column0. How do i make it saves it on column1 while another var is saved on column0?

Thank you for your answers.

Edit: i was tring to do something like this: http://pdqi.com/w/Download/BLT/treeview1.gif or http://zoomq.qiniudn.com/ZQScrapBook/ZqFLOSS/data/20100928164510/multicolumn_treeview_plastiktheme.png

Upvotes: 0

Views: 1265

Answers (1)

Aleksander
Aleksander

Reputation: 35

For issue 1: I suggest you to rewrite your code:

chat = ttk.Treeview(height="26", columns=("Mensaje", "Hora"))

chat.heading('#0', text='Nick', anchor=W)
chat.heading('Mensaje', text='Mensaje', anchor=W)
chat.heading('Hora', text='Hora', anchor=W)

chat.column('#0', stretch=NO, minwidth=0, width=100)
chat.column('Mensaje', stretch=NO, minwidth=0, width=510)
chat.column('Hora', stretch=NO, minwidth=0, width=100)

For issue 2: Use

chat.insert('', 'end', 'iid_1')
chat.set('iid_1', 'Hora', 'your value')

For issue 3: There is not presently a listbox in ttk, but you can use Listboxes from the classic Tk widgets.

Upvotes: 3

Related Questions