ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/ns_dev/Python/NinoCode/Active_prgs/Vacation_Days.pyw
Revision: 8
Committed: Sat May 5 04:21:19 2012 UTC (13 years, 10 months ago) by ninoborges
File size: 1889 byte(s)
Log Message:
Initial Import

File Contents

# Content
1 ## This program will track my vacation days. It will display how many days are avalible
2 ## and let me subtract from this total.
3
4 from Tkinter import *
5 from tkSimpleDialog import askfloat
6
7 def Display(Hours, Days):
8 global HourLab
9 global DayLab
10 MainWin= Tk()
11 DayLab = Label(MainWin)
12 DayLab.config(text ='You have %d Days Left of vacation '%Days)
13 HourLab = Label(MainWin)
14 HourLab.config(text= '%s Actual Hours Left '%Hours)
15 DayLab.pack(side = TOP)
16 HourLab.pack(side =TOP)
17 But =Button(MainWin, text="Add Vacation Time", command=(lambda op = '+',h = Hours: AdjustTime(h,op))).pack(side = LEFT)
18 But2=Button(MainWin, text="Use some of your Vacation", command=(lambda op = '-',h=Hours:AdjustTime(h,op))).pack(side=RIGHT)
19 MainWin.mainloop()
20
21 def AdjustTime(Hours,operand):
22 Hours = float(Hours)
23 if operand == '+':
24 NewHours = askfloat("Add Vacation Days", "Congradulations on getting more vacation hours. Enter your new hours here:")
25 Hours = Hours + NewHours
26 else:
27 NewHours = askfloat("Use Some Vacation","So you took some time off. Enter time off:")
28 Hours = Hours - NewHours
29 Hours = str(Hours)
30 o = open(r'C:\Documents and Settings\eaborges\My Documents\Python DataFiles\VacationDays\Vacation.dat','w')
31 o.write(Hours)
32 o.close()
33 DaysLeft = GetDays(Hours)
34 HourLab.config(text='%s Actual Hours Left '%Hours)
35 DayLab.config(text ='You have %d Days Left of vacation '%DaysLeft)
36
37 def GetDays(Hours):
38 DaysLeft = float(Hours) /7.5
39 return DaysLeft
40
41
42 if __name__ == "__main__":
43 f=open(r'C:\Documents and Settings\eaborges\My Documents\Python DataFiles\VacationDays\Vacation.dat','r')
44 HoursLeft = f.read()
45 DaysLeft = GetDays(HoursLeft)
46 DaysLeft = int(DaysLeft)
47 f.close()
48 Display(HoursLeft,DaysLeft)