2017-09-05 14 views
1

私はttkのツリービューウィジェットを使ってTkinterにテーブルを作成しています。しかし、私は列を挿入した後、テキストなしでそれを表示します。ここで結果python 3 - tkinter - ttk treeview:列テキストを参照

w=Tk() 
f=Frame(w) 
f.pack() 
t=Treeview(f,columns=("Titolo","Data","Allegati?")) 
t.pack(padx=10,pady=10) 
t.insert("",1,text="Sample") 

Treeview Result Image

私はどのように解決することができます。ここ は、コードのですか?

ありがとうございました

+0

おそらく関連しています:https://stackoverflow.com/questions/36120426/tkinter-treeview-widget-inserting-data – Lafexlos

答えて

0

各列にヘッダーを定義する必要があります。ヘッダーに同じ列名を使用するかどうかはわかりませんが、それが私の例になるでしょう。あなたはあなたが望むものにテキストを変更することができます。あなたの最終的なコードは次のようになります。これらの変更によって

t.heading("Titolo", text="Titolo") 
t.heading("Data", text="Data") 
t.heading("Allegati?", text="Allegati?") 

:あなたはこのようなheader()を使用する必要がありますヘッダーを定義するに

from tkinter import * 
from tkinter.ttk import * 


w=Tk() 

f = Frame(w) 
f.pack() 
t = Treeview(f, columns=("Titolo", "Data", "Allegati?")) 

t.heading("Titolo", text="Titolo") 
t.heading("Data", text="Data") 
t.heading("Allegati?", text="Allegati?") 

t.pack(padx=10, pady=10) 
t.insert("", 1, text="Sample") 

w.mainloop() 

結果:

enter image description here

レッツあなたは何か質問があるなら私は知っている。

+0

ありがとう、データを列に追加したいのですがどうすればいいですか? –

+0

@MaicolBattiおそらく、 'insert()'を使うのは、必要となるたくさんのtreeviewメソッドの[doc page](http://www.tkdocs.com/tutorial/tree.html)です。 –

関連する問題