-1

I've written come code that selects certain data from a sqlite3 database and outputs them as follows:

2017-06-05 test 09:00:00 11:00:00
2017-06-12 test 09:00:00 11:00:00
2017-06-19 test 09:00:00 11:00:00
2017-06-26 test 09:00:00 11:00:00

I want to get the dates, and change them so they are a heading for the other data. How would I go about selecting the dates and making them headers?

Example of what I want;

2017-06-05 (in larger font)
name of timeslot: test 
start time: 09:00:00 
end time: 11:00:00

code that handle the search function:

def searched():
    Main_Screen.configure(state = 'normal')
    Main_Screen.delete('1.0', END)
    searched_for = search.get()
    timeslot = cursor.execute('''SELECT * FROM dates WHERE Name = (?)''',(searched_for,))
    list1 = list(cursor.fetchall())
    cursor.execute('''SELECT COUNT(*) FROM dates WHERE Name = (?) ''',(searched_for,))
    result = cursor.fetchone()
    output_text = '\n'.join([' '.join(row) for row in list1])
    Main_Screen.insert(tkinter.END, output_text)
coder188642
  • 145
  • 2
  • 5
  • 15

1 Answers1

0

You could get it line by line and do the following:

print line.split()[0]
print "name of time:", line.split()[1]
print "start time:", line.split()[2]
print "end time:", line.split()[3]
JohnSkandi
  • 34
  • 4
  • I'm using Main_Screen.insert as the way to output to the textbox. I'm stuck as I'm using a search function to get any records with a searched name. So for 'test' there is four results. Can I use line.split for that aswell, even if I don't know how many results I will get? – coder188642 Mar 08 '17 at 17:40
  • 1
    this might help in modifying font sizes: http://stackoverflow.com/questions/30685308/how-do-i-change-the-text-size-in-a-label-widget-python-tkinter – The4thIceman Mar 08 '17 at 17:48
  • @The4thIceman thanks for the suggestion. Ive edited the question to show the code that outputs the query onto the page, to see if that helps answer the other part of the question about selecting just the date. – coder188642 Mar 08 '17 at 17:55