-
Notifications
You must be signed in to change notification settings - Fork 0
/
ListEditor.py
124 lines (106 loc) · 5.03 KB
/
ListEditor.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
#!/usr/bin/env python
from Tkinter import Tk, Frame, Label, SUNKEN, W, LEFT, Button
from ListView import ListView
from CreateView import CreateView
from functools import partial
import tkFont
class ListEditor(Frame):
def __init__(self, parent):
Frame.__init__(self, parent)
self.parent = parent
border_width = 1
border_style = SUNKEN
background_colour = "#FFFFFF"
default_height=600
nav_frame = Frame(self, height=default_height,
width=200,
bd=border_width,
relief=border_style,
bg=background_colour)
content_frame = Frame(self, height=default_height,
width=804,
bd=border_width,
relief=border_style)
content_frame.parent = parent
nav_frame.grid(column=0, row=0)
content_frame.grid(column=1, row=0)
nav_frame.grid_propagate(0)
content_frame.pack_propagate(0)
#Create fonts for navLabels
fontMouseOver = tkFont.Font(family="Helvetica", size=14, underline=True)
fontMouseOut = tkFont.Font(family="Helvetica", size=14, underline=False)
#Creating Navigation Labels
self.lNavStudentRecords = Label(nav_frame,
text="Student Records",
bg="white",
font=fontMouseOut,
bd=border_width,
relief=border_style,
width=20)
self.lNavViewLists = Label(nav_frame,
text="View Word Lists",
bg="white",
font=fontMouseOut,
bd=border_width,
relief=border_style,
width=20)
self.lNavCreateLists = Label(nav_frame,
text="Create Word Lists",
bg="white",
font=fontMouseOut,
bd=border_width,
relief=border_style,
width=20)
buttonBack=Button(nav_frame, text="Back", command=self.parent.new_list)
#Binding Mouse events to the Labels
#Mouse Clicks
self.lNavViewLists.bind("<Button-1>", partial(self.switch_frame, 2))
self.lNavCreateLists.bind("<Button-1>", partial(self.switch_frame, 1))
self.lNavStudentRecords.bind("<Button-1>", partial(self.switch_frame, 3))
#Mouse Movements
self.lNavViewLists.bind("<Enter>", lambda(event):
self.lNavViewLists.configure(font=fontMouseOver))
self.lNavCreateLists.bind("<Enter>", lambda(event):
self.lNavCreateLists.configure(font=fontMouseOver))
self.lNavViewLists.bind("<Leave>", lambda(event):
self.lNavViewLists.configure(font=fontMouseOut))
self.lNavCreateLists.bind("<Leave>", lambda(event):
self.lNavCreateLists.configure(font=fontMouseOut))
self.lNavStudentRecords.bind("<Enter>", lambda(event):
self.lNavStudentRecords.configure(font=fontMouseOver))
self.lNavStudentRecords.bind("<Leave>", lambda(event):
self.lNavStudentRecords.configure(font=fontMouseOut))
#Gridding the labels
#self.lNavStudentRecords.grid(column=0, row=0)
self.lNavViewLists.grid(column=0,row=1)
self.lNavCreateLists.grid(column=0, row=2)
buttonBack.grid(column=0, row=3)
#Creating the two views we have so far
self.viewcreate = CreateView(content_frame, default_height, 800,
border_style, border_width, background_colour)
self.viewlists = ListView(content_frame, default_height, 800,
border_style, border_width, background_colour)
self.viewlists.pack()
def switch_frame(self, frameNumber, event):
if frameNumber == 1:
self.viewlists.pack_forget()
self.viewcreate.pack()
self.lNavViewLists.configure(bg="white", fg="black")
self.lNavCreateLists.configure(bg="#DDDDDD", fg="#8800AA")
self.lNavStudentRecords.configure(bg="white", fg="black")
self.viewcreate.update_category()
elif frameNumber == 2:
self.viewcreate.pack_forget()
self.viewlists.pack()
self.lNavCreateLists.configure(bg="white", fg="black")
self.lNavViewLists.configure(bg="#DDDDDD", fg="#8800AA")
self.lNavStudentRecords.configure(bg="white", fg="black")
self.viewlists.update()
else:
self.viewcreate.pack_forget()
self.viewlists.pack_forget()
self.lNavCreateLists.configure(bg="white", fg="black")
self.lNavViewLists.configure(bg="white", fg="black")
self.lNavStudentRecords.configure(bg="#DDDDDD", fg="#8800AA")
if __name__=='__main__':
main()