Python Forum

Full Version: Tkinter timetabl using treeview
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi I am trying to create a drag and drop timetable using tkinter and I was wondering if there was a way to create an element in a treeview that expands more than one row,
def changeTime(td):
	hour = td.seconds//3600
	minutes = (td.seconds//60)%60
	if len(str(minutes)) == 1:
		minutes = str(minutes)
		minutes = '0' + minutes
	else:
		minutes = str(minutes)
	return "%d:%s" % (hour,minutes)

table = ttk.Treeview(sistema)
table['show'] = 'headings'
table['columns'] = ('E', 'H', 'Mo', 'Tue', 'We', 'Thu', 'F')
table.heading('E', text="Events")
table.heading('H', text="Hours")
table.heading('Mo', text="Monday")
table.heading('Tue', text="Tuesday")
table.heading('We', text="Wednesday")
table.heading('Thu', text="Thursday")
table.heading('F', text="Friday")

time = datetime.timedelta(hours = 7)
half = datetime.timedelta(minutes = 30)

for i in range(20):
	table.insert("", i, values=('', changeTime(time)))
	time = time + half

table.pack(side=LEFT, expand=YES, fill=BOTH)
Currently that is my table but what I need to do is create an element in events that lasts 1:30 hours, is this possible using treeview or am I wasting my time with this?, if so can you recommend another way to approachj this?
Please include enough code to run.
Treeview can be expanded. Here's an example i wrote a while back, with multiple columns
https://github.com/Larz60p/CaliforniaPublicSalaries
the scraping part of this may need updating as web sites change over time, but the GUI code
is still good.
Hi Thanks for answering but I need it to be multiple rows not columns
Quote:Hi Thanks for answering but I need it to be multiple rows not columns
Since a 'tree' is by default multiple rows, or course a 'treeview' can hold multiple rows!