Please help..

neville nevwill at altavista.net
Wed Sep 4 19:27:35 EDT 2002


Hi,
I'm new to programming and python and I'm having trouble defining
functions.I have worked through 2 books and many tutorials and still
don't understand it.As this appears to be fundamental to python could
some-one please offer some suggestion.I have included a small program
that works, but how do I write it correctly.
from Tkinter import *
from time import *
t1=localtime()
n=asctime(t1)
t2=(2002,6,13,0,0,0,3,163,0)#13/6/2002
t3=(2002,6,14,0,0,0,4,164,0)#14/6/2002
ts=mktime(t1)-mktime(t2) #non smoking 
tr=mktime(t1)-mktime(t3) #for rent
d1=int(tr/((60*60)*24)) #convert to days
dr=d1%14 #rent due fortnigtly
if dr<7:
    c="The rent is due this Friday !"
elif dr==7:
    c="The rent is due today !!"
elif dr>7:
    c="The rent is due next week !"

d=int(ts/((60*60)*24))
a="Non-smoking for... %d" %d
m=(d/2)*50 #$50 saved every 2 days
b="Cash is... $%d" %m
root=Tk()
frame=Frame(root,bg="white")
frame.pack()
n=Label(frame,bg="white",fg="deeppink",text=n)
w=Label(frame,bg="white",fg="blue",text=a)
s=Label(frame,bg="white",fg="blue",text=c)
t=Label(frame,bg="white",fg="blue",text=b)
n.pack(padx=50,pady=10)
s.pack()
w.pack()
t.pack()
root.title("No Smoking!!!!")
root.mainloop()
I hope you can understand this and help me,
thanks, Neville



More information about the Python-list mailing list