예제 #1
0
    def make_title(self):
        """
        Add page title to interface.

        @return {void}
        """
        ui.margin_y(self.root, px=20, row=0)
        self.title
        ui.margin_y(self.root, px=2, row=2)
예제 #2
0
    def build(self):

        # Quick and dirty dashboard.
        # Needs work once all views are
        # in place.
        #

        row = 0

        # Interface

        ui.title(self.root, text='Dashboard', row=row)
        row += 1
        ui.margin_y(self.root, px=10, row=row)
        row += 1

        tk.Label(self.root, text="User: " + self.user_id).grid(row=row)
        row += 1
        ui.margin_y(self.root, px=10, row=row)
        row += 1

        # If a lecturer is logged in
        # show them the lecturer specific actions
        if self.login_status == 1:
            tk.Button(self.root, text='Create Lesson', command=lesson_create_view.main, width=30).grid(row=row)
            row += 1
            tk.Button(self.root, text='Create Test', command=test_create_view.main, width=30).grid(row=row)
            row += 1
            tk.Button(self.root, text='Create Student', command=add_user_view.main, width=30).grid(row=row)
            row += 1
            tk.Button(self.root, text='Publish Lessons', command=lesson_publish_view.main, width=30).grid(row=row)
            row += 1

            ui.margin_y(self.root, px=5, row=row)
            row += 1
            tk.Button(self.root, text='View Results', command=result_list_view.main, width=30).grid(row=row)
            row += 1

        tk.Button(self.root, text='View Lessons', command=lesson_list_view.main, width=30).grid(row=row)
        row += 1

        view_test_list = lambda user_id = self.user_id : test_list_view.main(user_id)
        tk.Button(self.root, text='View Tests', command=view_test_list, width=30).grid(row=row)
        row += 1

        ui.margin_y(self.root, px=5, row=row)
        row += 1
        tk.Button(self.root, text='Logout', command=self.logout, width=30).grid(row=row)
        row += 1
        ui.margin_y(self.root, px=20, row=row)
        row += 1
예제 #3
0
    def build(self):
        row = 0
        user = User()

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

        ui.title(self.root, text='Login', row=row)
        row += 1
        ui.margin_y(self.root, px=10, row=row)
        row += 1

        tk.Label(self.root, text='Username').grid(row=row)
        row += 1
        self.username = tk.Entry(self.root)
        self.username.grid(row=row)
        row += 1

        tk.Label(self.root, text='Password').grid(row=row)
        row += 1
        self.password = tk.Entry(self.root, show="*")
        self.password.grid(row=row)
        row += 1

        ui.margin_y(self.root, px=20, row=row)
        command = lambda : self.login()
        tk.Button(self.root, text='Login', command=command).grid(row=row)

        row += 1
        ui.margin_y(self.root, px=20, row=row)
        row += 1
예제 #4
0
    def build(self):
        row = 0
        user = User()

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

        ui.title(self.root, text='Add User', row=row)
        row += 1
        ui.margin_y(self.root, px=10, row=row)
        row += 1

        tk.Label(self.root, text='Username').grid(row=row)
        row += 1
        self.userID = tk.Entry(self.root)
        self.userID.grid(row=row)
        row += 1

        tk.Label(self.root, text='Password').grid(row=row)
        row += 1
        self.password = tk.Entry(self.root)
        self.password.grid(row=row)
        row += 1

        ui.margin_y(self.root, px=20, row=row)
        command = lambda : self.add()
        tk.Button(self.root, text='Add', command=command).grid(row=row)

        row += 1
        ui.margin_y(self.root, px=20, row=row)
        row += 1
예제 #5
0
	def make_nav(self):

	   	padx = 20

	   	if self.current_question > 0:
	   		self.previous_button.grid(sticky=tk.W, row=11, padx=padx)
	   	else:
	   		self.previous_button.grid_forget()

	   	self.next_button.grid(sticky=tk.E, row=11, padx=padx)

	   	if self.current_question == (len(self.test.questions) - 1):
	   		self.next_button.grid_forget()
	   		self.complete_button.grid(sticky=tk.E, row=11, padx=padx)
	   	else:
	   		self.complete_button.grid_forget()
	   		self.next_button.grid(sticky=tk.E, row=11, padx=padx)

	   	ui.margin_y(self.root, px=0, row=12)
예제 #6
0
	def detail(self):
		Test = tk.Frame(self.root)

		ui.margin_y(Test, px=20, row=0)
		ui.title(Test, text="Take Test", row=1)
		ui.margin_y(Test, px=2, row=2)

		previous_command = lambda test = Test : self.previous(test)
		next_command = lambda test = Test : self.next(test)
		complete_command = lambda test = Test : self.complete(self.root)

		self.previous_button = tk.Button(Test, text="Previous Question", command=previous_command)
		self.next_button = tk.Button(Test, text="Next Question", command=next_command)
		self.complete_button = tk.Button(Test, text="Submit Test", command=self.complete)

		padx = 20

		question = self.test.questions[self.current_question]
		self.body = tk.Label(Test, text=question[0]).grid(row=3)

		ui.margin_y(self.root, px=20, row=4)

		self.body = tk.Label(Test, text="1. " + question[1][0]).grid(row=5)
		self.body = tk.Label(Test, text="2. " + question[1][1]).grid(row=6)
		self.body = tk.Label(Test, text="3. " + question[1][2]).grid(row=7)
		self.body = tk.Label(Test, text="4. " + question[1][3]).grid(row=8)

		self.entry = tk.Entry(Test)
		self.entry.grid(row=9)
		self.entry.insert(0, self.answer[self.current_question])

		"""
		if self.current_question > 0:
			self.previous_button.grid(sticky=tk.W, row=9, padx=padx)

		if self.current_question == len(self.test.questions) -1:
			self.next_button.grid(sticky=tk.E, row=10, padx=padx)
			self.complete_button.grid_forget()
		else:
			self.complete_button.grid(sticky=tk.W, row=11, padx=padx)
			self.next_button.grid_forget()
		"""

		ui.margin_y(self.root, px=0, row=9)

		Test.grid()
예제 #7
0
    def make_nav(self):
        """
        Create a lesson navigation bar in
        the view lesson window. The navigation
        bar contains a previous, next and finish
        lesson button.

        @return {void}
        """
        padx = 20
        ui.margin_y(self.root, px=20, row=4)

        # If the user is not on the first slide
        # show the previous slide button.
        #
        if self.current_slide_index > 0:
            self.previous_button.grid(sticky=tk.W, row=5, padx=padx)
        else:
            self.previous_button.grid_forget()

        # Next slide button
        #
        self.next_button.grid(sticky=tk.E, row=5, padx=padx)

        # If the user is on the last slide
        # forget the next button and replace
        # with the finish lesson button.
        #
        if self.current_slide_index == (len(self.lesson.slides) - 1):
            self.next_button.grid_forget()
            self.complete_button.grid(sticky=tk.E, row=5, padx=padx)
        else:
            self.complete_button.grid_forget()
            self.next_button.grid(sticky=tk.E, row=5, padx=padx)

        ui.margin_y(self.root, px=0, row=8)
예제 #8
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()
예제 #9
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()
예제 #10
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()