import draw from tkColorChooser import askcolor from Tkinter import te

 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
import draw
from tkColorChooser import askcolor
from Tkinter import *
texts=[('Begin','01.01.2000'),('End','01.01.2009')]
def fetch(v):
print col
znach=[]
for z in v:
en=z.get()
en=str(en)
en=en.replace('.','/')
znach.append(en)
print znach
draw.grafik(draw.kurs(znach),col)
paint()
def color():
global col
print 'Askkolor'
col=askcolor()[0]
def exp(root,texts):
entries=[]
form=Frame(root)
left=Frame(form)
right=Frame(form)
form.pack(fill=X)
left.pack(side=LEFT)
right.pack(side=RIGHT,expand=YES,fill=X)
for text in texts:
lab=Label(left,width=5,text=text[0])
lab.pack(side=TOP)
ent=Entry(right)
ent.insert(0,text[1])
ent.pack(side=TOP,fill=X)
entries.append(ent)
return entries
def paint():
win = Toplevel()
img = PhotoImage(file='graf.gif')
can = Canvas(win)
can.pack(fill=BOTH)
can.configure(width=img.width(), height=img.height())
can.create_image(2, 2, image=img, anchor=NW) # x, y coordinates
win.mainloop()
root = Tk()
vars = exp(root, texts)
col=(0,0,0)
root.bind('<Return>', (lambda event, e=vars: fetch(e)))
Button(root, text='Fetch', command=(lambda v=vars: fetch(v))).pack(side=LEFT)
Button(root,text='Color line',command=color).pack(side=RIGHT)
root.mainloop()