Beispiel #1
0
def main(user_id, login_status):
    window = tk.Tk()
    window.title('Studybook | Dashboard')
    centered_frame = tk.Frame(window)

    app = Dashboard(centered_frame, window, user_id, login_status)

    centered_frame.place(relx=0.5, rely=0.5, anchor=tk.CENTER)
    window.geometry(ui.center(window))
    window.mainloop()
Beispiel #2
0
def main():
    window = tk.Tk()
    window.title('Studybook | Login')
    centered_frame = tk.Frame(window)

    app = Login(centered_frame, window)

    centered_frame.place(relx=0.5, rely=0.5, anchor=tk.CENTER)
    window.geometry(ui.center(window))
    window.mainloop()
Beispiel #3
0
def main():
    """
    Display the take lesson view.
    This view displays a list of
    published lessons.

    @return {void}
    """

    row = 0
    window = tk.Tk()
    window.title("Studybook | Unpublished Lesson List")
    centered_frame = tk.Frame(window)

    # Storage

    store = shelve.open('lesson/store')
    # Store a list of published lesson (id, name)
    # attributes in a tuple in the order above.
    #
    lessons = [(lesson._id, lesson.name) for lesson in store.values() if not lesson.published]
    store.close()

    # Interface

    ui.margin_y(centered_frame, px=20, row=row)
    row += 1

    ui.title(centered_frame, text="Unpublished Lesson List", row=row)
    row += 1

    ui.margin_y(centered_frame, px=2, row=row)
    row += 1

    for lesson in lessons:
        # Loop through all lesson _ids and names
        # generating the appropriate label and button
        # pair to display.
        #
        _id     = lesson[0]
        name    = lesson[1]
        command = lambda _id = _id : publish(_id)

        ui.pair(centered_frame, label_text=name, button_text="Publish Lesson", command=command, row=row)
        row += 1

    ui.pair(centered_frame, label_text='', button_text="Close", command=window.destroy, row=row)
    row += 1
    ui.margin_y(centered_frame, px=30, row=row)

    centered_frame.place(relx=0.5, rely=0.5, anchor=tk.CENTER)
    window.geometry(ui.center(window))
    window.mainloop()
Beispiel #4
0
def main(_id, user_id):

	store = shelve.open('lesson/store')
	lesson = store[_id]
	store.close()

	store = shelve.open('test/store')
	test = store[_id]
	store.close()

	window = tk.Tk()
	window.title("Studybook | Test Viewer")
	centered_frame = tk.Frame(window)

	app = TestView(window, centered_frame, test, lesson, user_id)

	centered_frame.place(relx=0.5, rely=0.5, anchor=tk.CENTER)
	window.geometry(ui.center(window))
	window.mainloop()
Beispiel #5
0
def main(user_id):

    row = 0
    window = tk.Tk()
    window.title("Studybook | Test List")
    centered_frame = tk.Frame(window)

    store = shelve.open('lesson/store')
    lessons = [(lesson._id, lesson.name) for lesson in store.values() if lesson.published]
    store.close()

    ui.margin_y(centered_frame, px=20, row=row)
    row += 1

    ui.title(centered_frame, text="Test List", row=row)
    row += 1

    ui.margin_y(centered_frame, px=2, row=row)
    row += 1

    for lesson in lessons:

        store = shelve.open('test/store')
        test = store[lesson[0]]
        store.close()

        _id     = lesson[0]
        name    = lesson[1]
        command = lambda _id = _id : test_view.main(_id, user_id)

        if user_id not in test.results.keys():
            ui.pair(centered_frame, label_text=name, button_text="Take Test", command=command, row=row)
            row += 1

    ui.pair(centered_frame, label_text='', button_text="Close", command=window.destroy, row=row)
    row += 1
    ui.margin_y(centered_frame, px=30, row=row)

    centered_frame.place(relx=0.5, rely=0.5, anchor=tk.CENTER)
    window.geometry(ui.center(window))
    window.mainloop()
Beispiel #6
0
    def __init__(self, title, data):
        """
        A class to generate a simple table made up
        of cells. The number of cells depends on the
        list passed in as the data param. The table will
        be generated in a new window.

        The data param should be a list of lists.
        Such that each list is considered a row
        and each subsequent item within that list
        is considered a field.

        _____________________________________________

        i.e.

        [['A', 'B', 'C'], ['A', 'B', 'C'], ['A', 'B', 'C']]

        Would be interpreted as:

        A       B       C
        A       B       C
        A       B       C

        _____________________________________________

        The title param will set the window title
        and generate a page title with the specified
        value.

        _____________________________________________

        Example usage

        data = [['A', 'B', 'C'], ['A', 'B', 'C'], ['A', 'B', 'C']]
        Table('Student Results', data)
        _____________________________________________


        @param {string} title
        @param {list of lists} data
        @return {void}
        """

        self.data = data
        self.title = title

        window = tk.Tk()
        window.title(self.title)
        centered_frame = tk.Frame(window)
        row = 0

        ui.margin_y(window, px=20, row=row)
        row += 1
        ui.title(window, text=self.title, row=row)
        row += 1
        ui.margin_y(window, px=10, row=row)
        row += 1

        for y, row_ in enumerate(self.data):
            for x, cell in enumerate(row_):
                field = tk.Entry(centered_frame)
                field.insert(0, cell)
                field.configure(state='readonly')
                field.grid(row=row + y, column=x)

        centered_frame.place(relx=0.5, rely=0.5, anchor=tk.CENTER)
        window.geometry(ui.center(window))
        window.mainloop()