scandalous
scandalous

Reputation: 912

Creating a table like structure in python

I am making a download manager in python.. I want to create a table like structure with multiple columns and rows to show:

Download name, download status (paused/downloading), download size and other information interactively.

Can anyone give me ideas on how to create a table-like structure where I can easily add the data mentioned above?

Upvotes: 1

Views: 3588

Answers (2)

Bryan Oakley
Bryan Oakley

Reputation: 386010

The ttk treeview widget allows you to have multiple columns. For example:

import Tkinter as tk # python 2.7
import ttk
...
root = tk.Tk()
...
tree = ttk.Treeview(root, ...)  
tree.configure(columns=('size', 'modified', 'owner'))
...
tree.insert('', 'end', text='item 1', values=('20k','yesterday', 'kilgore trout'))

For more information see http://www.tkdocs.com/tutorial/tree.html

Upvotes: 3

bruno desthuilliers
bruno desthuilliers

Reputation: 77912

Your question is a bit confusing - you're talking about data structure and persistence then about list box (GUI stuff...)

wrt/ the data structure and persistence part a "table like" structure with "rows and columns" is easily modeled as a list of ducts or list of tuples. For the perstitance part you can serialize your list as json and write it to a file or write it as CSV ( using the stdlib CVS package) or use a SQL db.

Upvotes: 0

Related Questions