4
class Gui(Tkinter.Frame):
5
def __init__(self,poems):
9
RWidth = root.winfo_screenwidth()/2.7
10
RHeight = root.winfo_screenheight()/1.7
11
root.geometry(("%dx%d")%(RWidth,RHeight))
12
Tkinter.Frame.__init__(self,root)
16
self.parent.title("poems")
17
self.pack(fill=Tkinter.BOTH, expand=1)
18
titles=self.poems.keys()
19
self.selected = Tkinter.StringVar(self)
20
self.selected.set('Please select an option')
21
w = apply(Tkinter.OptionMenu, (self, self.selected) + tuple(titles))
22
self.selected.trace("w",self.display)
24
# text=Tkinter.Text(self)
25
self.display_text=Tkinter.StringVar()
26
# self.display_text.set(self.anthology['Please select an option'])
27
self.display_text.set("Bonjour")
28
Tkinter.Label(self,textvariable=self.display_text).pack()
29
self.button = Tkinter.Button(self, text="Save", command=self.save,state=Tkinter.DISABLED)
33
def display(self,*args):
34
choice= self.selected.get()
35
self.display_text.set(self.poems[choice.lower()])
36
state = ["normal","disabled"][choice=='Please select an option']
37
self.button.configure(state=state)
41
filename = tkFileDialog.asksaveasfilename(initialfile=self.selected.get()+'.txt')
44
f.write(self.display_text.get())