Q:

Python timetable pass start and finish time that pressed button relevant to position

For my coursework i am making a booking system and i have been messing around trying to make a page which shows current week lessons and when the button is clicked it comes up with that students details on a separate page.But i don't know how to go about passing that time into my open page sub(which writes a txt file which is going to be used for SQL to get the students details). The current way i have done it just passes the max times into the sub.
from tkinter import *
import datetime

class Application(Frame):
    def __init__(self, master):
        """ Initialize the frame. """
        super(Application, self).__init__(master)  
        self.grid()
        self.timetable_button_gen_weekdays()
        self.timetable_button_gen_weekends()

    def timetable_button_gen_weekdays(self):
        c = datetime.datetime(100,1,1,16,00,00)
        self.Monday_lbl = Label(self, text = "Monday")
        self.Monday_lbl.grid(row = 1, column = 0)
        self.Tuesday_lbl = Label(self, text = "Tuesday")
        self.Tuesday_lbl.grid(row = 2, column = 0)
        self.Wednesday_lbl = Label(self, text = "Wednesday")
        self.Wednesday_lbl.grid(row = 3, column = 0)
        self.Thursday_lbl = Label(self, text = "Thursday")
        self.Thursday_lbl.grid(row = 4, column = 0)
        self.Friday_lbl = Label(self, text = "Friday")
        self.Friday_lbl.grid(row = 5, column = 0)
        for k in range(8):
            b = c + datetime.timedelta(minutes = (30 * k))
            d = b + datetime.timedelta(minutes = (30))
            self.i_time_weekdays_lbl = Label(self, text = b.time().strftime('%H:%M')+" to "+d.time().strftime('%H:%M'))
            self.i_time_weekdays_lbl.grid(row = 0, column = k + 1)
        for i in range(5):
            for a in range(8):
                b = c + datetime.timedelta(minutes = (30 * a))
                d = b + datetime.timedelta(minutes = (30))
                bttn_i_a = Button(self, text = "available",command = lambda: self.OpenPage(b.time().strftime('%H:%M'),d.time().strftime('%H:%M')))
                bttn_i_a.grid(row = i + 1, column = a + 1)
                bttn_i_a.config(height = 2, width = 10)

    def timetable_button_gen_weekends(self):
        c = datetime.datetime(100,1,1,10,00,00)
        self.Saturday_lbl = Label(self, text = "Saturday")
        self.Saturday_lbl.grid(row = 8, column = 0)
        self.Sunday_lbl = Label(self, text = "Sunday")
        self.Sunday_lbl.grid(row = 9, column = 0)
        self.weekend_lbl = Label(self, text = "Weekend")
        self.weekend_lbl.grid(row = 6, column = 1, sticky = W)
        for k in range(10):
            b = c + datetime.timedelta(minutes = (30 * k))
            d = b + datetime.timedelta(minutes = (30))
            self.i_time_weekdays_lbl = Label(self, text = b.time().strftime('%H:%M')+" to "+d.time().strftime('%H:%M'))
            self.i_time_weekdays_lbl.grid(row = 7, column = k + 1)
        for i in range(2):
            for a in range(10):
                b = c + datetime.timedelta(minutes = (30 * a))
                d = b + datetime.timedelta(minutes = (30))
                bttn_i_a = Button(self, text = "available",command = lambda: self.OpenPage(b.time().strftime('%H:%M'),d.time().strftime('%H:%M')))
                bttn_i_a.grid(row = i + 8, column = a + 1)
                bttn_i_a.config(height = 2, width = 10)

    def OpenPage(self,startime,finishtime):
        file = open("PassTimes.txt","w")
        file.write(startime)
        file.write("\n")
        file.write(finishtime)
        print(startime)
        print(finishtime)
        filepath = "PresentStudent.py"

        global_namespace = {"__file__": filepath, "__name__": "__main__"}
        with open(filepath, 'rb') as file:
            exec(compile(file.read(), filepath, 'exec'), global_namespace)

root = Tk()
root.title("test")
root.geometry("2000x2000")
app = Application(root)
root.mainloop()

A:

Welcome to SO.
General
IMHO, running the main routine of "PresentStudent.py" does not look that clean.
It works, but a main routine is built for when the script is called directly, not when it is imported and used in some other script.
Are you aware of the modules functionality in python?
I would recommend creating a function in PresentStudent.py that does what you are doing inside your main routine. Give the function parameters to pass the .txt-Filename.
e.g.
def presentStudentCall(inputFile):
and use it inside your script like:
    #!/usr/bin/python
    # -*- coding: utf-8 -*-

    # here we import PresentStudent.py, as we import it __main__ will not run
    import PresentStudent

    #[...]

    def OpenPage(self, stime, etime):
        #[...]
        # Instead of executing a file we call the function from the module
        PresentStudent.presentStudentCall(file)

If you want to display the data inside a second frame, you could also declare a class in PresentStudent.py and use it like:
def OpenPage(self, stime, etime):
    #[...]
    student=PresentStudent.Student() # assuming to name the class "Student"
    student.presentStudentCall(file)

Your question itself
using the lambda does not need to be the best way. In matters of scope and garbage collecting your code only passes the last generated "b"s and "c"s to the definition.
What you could do to make it work is calculating the sender item in OpenPage:
To achieve that, I recommend having arrays for your time spans storing starting times.
Like 
c = datetime.datetime(100,1,1,16,00,00)    
self.weektimes    = ["%s"%(c+datetime.timedelta(minutes=30*k)) for k in range(8)]
self.weekendtimes = ["%s"%((c+datetime.timedelta(minutes=30*k)) for k in range(10)]

First you need to bind the click event to the widget(in that case your button)
bttn_i_a.bind("<Button-1>", self.OnPage)
Your OpenPage could then look like this:
def OpenPage(self, event):
    import time
    # With that, we get the row and column where we clicked in
    grid_info=event.widget.grid_info()

    # week or weekend?
    if grid_info["row"] > 5: #may depend on amount of headers
        _timearray=self.weekendtimes
    else:
        _timearray=self.weektimes

    # get the column
    col=grid_info["column"]

    # get the startTime
    stime=_timearray[col]

    # end time is +30 minutes
    etime="%s"%(time.strptime("%s"%stime, "%H:%M")+time.struct_time(tm_min=30))

    # now call the handler...

