#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2013
    Posts
    24
    Rep Power
    0

    Help using ttk.Treeview


    I am trying to build a Treeview listbox from ttk, but I don't know how to insert values into different columns in the tree. All of my data goes into the first column. I've been reading the documentation for almost 30 minutes but I still haven't found how to insert data into other columns. My code:

    Code:
    def create_outer_padding(f, h, w):
      top_padding    = Frame(f, height=h).pack(side=TOP, fill=X)
      bottom_padding = Frame(f, height=h).pack(side=BOTTOM, fill=X)
      left_padding   = Frame(f, width=w).pack(side=LEFT, fill=Y)
      right_padding  = Frame(f, width=w).pack(side=RIGHT, fill=Y)
    
    root = Tk()
    root.title("Log Organizer")
    root.geometry("1400x800")
    root.resizable(0,0)
    create_outer_padding(root, 40, 50)
    
    tree = Treeview(root, columns=['Host', 'Event', 'Date', 'Time', 'Text'], show='headings')
    tree.column('Host', width=100, anchor='center')
    tree.column('Event', width=100, anchor='center')
    tree.column('Date', width=100, anchor='center')
    tree.column('Time', width=100, anchor='center')
    tree.column('Text', width=100, anchor='center')
    tree.heading('Host', text='Host')
    tree.heading('Event', text='Event')
    tree.heading('Date', text='Date')
    tree.heading('Time', text='Time')
    tree.heading('Text', text='Text')
    tree.pack(side=RIGHT, fill=Y)
    
    tree.insert('', 'end', values=('N/A'))
    So, basically I want to insert values into columns other than the 'Host' column. How do I do that?
  2. #2
  3. Contributing User
    Devshed Demi-God (4500 - 4999 posts)

    Join Date
    Aug 2011
    Posts
    4,996
    Rep Power
    481
    Try this tutorial. http://www.tkdocs.com/tutorial/tree.html
    Presented in 4 languages, python is the fourth.
    [code]Code tags[/code] are essential for python code and Makefiles!
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2013
    Posts
    24
    Rep Power
    0
    Originally Posted by b49P23TIvg
    Try this tutorial. http://www.tkdocs.com/tutorial/tree.html
    Presented in 4 languages, python is the fourth.
    That's one of the tutorials I've been looking at. It helped me build the tree, but for some reason I can't get data to go in any other column besides the first column (the 'Host' column).
  6. #4
  7. No Profile Picture
    Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    May 2009
    Posts
    530
    Rep Power
    34
    values is a tuple, so try values=("one", "two", "three")

IMN logo majestic logo threadwatch logo seochat tools logo