diff --git a/WinsoftAssignment(T1-F1-F2).py b/WinsoftAssignment(T1-F1-F2).py new file mode 100644 index 0000000..716299f --- /dev/null +++ b/WinsoftAssignment(T1-F1-F2).py @@ -0,0 +1,143 @@ +''' +Your Full Name-Avantika Padhye, College Name-Fergusson College, PhoneNumber- 9730851702& email id:avantika.20jan@gmail.com +''' +#tkinter trial + +from tkinter import * +import json + +def sortDay(inrList): + return int(inrList[0][2]) + +def checkered(canvas, line_distance,canvas_width,canvas_height): + # vertical lines at an interval of "line_distance" pixel + for x in range(line_distance,canvas_width,line_distance): + canvas.create_line(x, 0, x, canvas_height, fill="#86d0db") + # horizontal lines at an interval of "line_distance" pixel + for y in range(line_distance,canvas_height,line_distance): + canvas.create_line(0, y, canvas_width, y, fill="#86d0db") + + +def main(): + with open('data.json') as json_file: + data = json.load(json_file) + + master = Tk() + master.geometry("1400x800") + Label(master,text="Exchange Rate with respect to EUR").place(x=50,y=50) + + + start_date=[] + end_date=[] + + #Dynamic Date Selection + + print("Enter the range of data dynamically") + print("Enter the start_date:") + + day=input("Enter Day:") + month=input("Enter Month:") + year=input("Enter Year:") + + start_date.append(year) + start_date.append(month) + start_date.append(day) + + print("Enter the range of data dynamically") + print("Enter the start_date:") + + day=input("Enter Day:") + month=input("Enter Month:") + year=input("Enter Year:") + + end_date.append(year) + end_date.append(month) + end_date.append(day) + + #Currency + + currency_list=[] + for i in data['rates']['2019-01-30']: + currency_list.append(i) + print(currency_list) + cur=input("Enter currency from the above list:") + cur.upper() + + + #Creating Canvas to plot graphs + + canvas_width = 1000 + canvas_height = 400 + w = Canvas(master, width=canvas_width, height=canvas_height) + interval=30 + w.place(x=100,y=100) + + #drawing grid + + checkered(w,interval,canvas_width,canvas_height) + + #drawing X-axis and Y-axis + + w.create_line(60,0,60,390) + w.create_line(30, 360, 1000, 360) + w.create_line(60,337,70,340) + w.create_line(70,340,50,345) + w.create_line(50,345,65,350) + w.create_line(65,350,60,355) + + #plotting X-Axis + + i=150 + j=470 + + for a in range(32): + Label(master,text=a).place(x=i,y=j) + i=i+30 + + #plotting Y-Axis + + a=78 + while a<=82: + Label(master,text=a).place(x=130,y=j-50) + j=j-30 + a=a+0.5 + + cur_list = [] + tmp_date = [] + d = [] + + for i in data['rates']: + d = (i.split('-')) + if d[1]==start_date[1]: + if d[2]>=start_date[2] or d[2]<=end_date[2]: + tmp_date.append(d) + tmp_date.append(data['rates'][i][cur]) + cur_list.append(tmp_date) + tmp_date = [] + + print(cur_list) + + cur_list.sort(key = sortDay) + + x1 = 58 + y1 = 328 + x2 = 62 + y2 = 332 + + w.create_rectangle(x1, y1, x2, y2,outline="#f11", fill="#1f1", width=1) + + + x = int(cur_list[0][0][2]) + y = cur_list[0][1] + prev = [(x1-2),(y2-2)] + for i in cur_list: + y = i[1] + x = (int(i[0][2])) + curr = [60+(30*x),(330-(60*(y-78)))] + w.create_rectangle((x1+(30*x)),(y1-(60*(y-78))),(x2+(30*x)),(y2-(60*(y-78))),outline="#f11", fill="#1f1", width=1) + w.create_line(prev[0],prev[1],curr[0],curr[1]) + prev[0] = curr[0] + prev[1] = curr[1] + +if __name__=="__main__": + main() diff --git a/WinsoftAssignment(T2).py b/WinsoftAssignment(T2).py new file mode 100644 index 0000000..e4585cf --- /dev/null +++ b/WinsoftAssignment(T2).py @@ -0,0 +1,124 @@ + + +#importing files + +from tkinter import * +import json + + +def checkered(canvas, line_distance,canvas_width,canvas_height): + # vertical lines at an interval of "line_distance" pixel + for x in range(line_distance,canvas_width,line_distance): + canvas.create_line(x, 0, x, canvas_height, fill="#86d0db") + # horizontal lines at an interval of "line_distance" pixel + for y in range(line_distance,canvas_height,line_distance): + canvas.create_line(0, y, canvas_width, y, fill="#86d0db") + +def sortDay(inrList): + return int(inrList[0][2]) + +def main(): + + # Opening JSON file + + with open('data.json') as json_file: + data = json.load(json_file) + + gbpList = [] + inrList = [] + tmp = [] + d = [] + + for i in data['rates']: + d = (i.split('-')) + if d[1] == '01': + tmp.append(d) + tmp.append(data['rates'][i]['INR']) + inrList.append(tmp) + tmp = [] + tmp.append(d) + tmp.append(data['rates'][i]['GBP']) + gbpList.append(tmp) + tmp = [] + + #sorting the inr and gbp lists based on dates in january month + + inrList.sort(key = sortDay) + gbpList.sort(key = sortDay) + + master = Tk() + master.geometry("1400x800") + canvas_width = 1100 + canvas_height = 1000 + interval=30 + w = Canvas(master, width=canvas_width, height=canvas_height) + w.place(x=50,y=50) + + checkered(w,30,canvas_width,canvas_height) + + w.create_line(60,0,60,750) + w.create_line(30, 690, 1000, 690) + + i=100 + j=420 + + for a in range(32): + Label(master,text=a).place(x=i,y=750) + i=i+30 + + #labeling y axis for inr + a=78 + while a<=82: + Label(master,text=a).place(x=70,y=j-50) + j=j-30 + a=a+0.5 + + #labeling y axis for gbp + a = 0.86 + j = 750 + while a <= 0.90: + Label(master,text=a).place(x=40,y=j-50) + j = j - 30 + a = a + 0.005 + + + w.create_rectangle(58, 328, 62, 332,outline="#f11", fill="#1f1", width=1) + x1 = 58 + y1 = 328 + x2 = 62 + y2 = 332 + + x = int(inrList[0][0][2]) + y = inrList[0][1] + prev = [(60),(330)] + for i in inrList: + y = i[1] + x = (int(i[0][2])) + curr = [60+(30*x),(330-(60*(y-78)))] + w.create_rectangle((x1+(30*x)),(y1-(60*(y-78))),(x2+(30*x)),(y2-(60*(y-78))),outline="#f11", fill="#1f1", width=1) + w.create_line(prev[0],prev[1],curr[0],curr[1]) + prev[0] = curr[0] + prev[1] = curr[1] + + w.create_rectangle(58, 658, 62, 662,outline="#f11", fill="#1f1", width=1) + x1 = 58 + y1 = 658 + x2 = 62 + y2 = 662 + + prev = [60,650] + for i in gbpList: + y = i[1] + x = (int(i[0][2])) + curr = [60+(30*x),(660-(6000*(y-0.86)))] + w.create_rectangle((x1+(30*x)),(y1-(6000*(y-0.86))),(x2+(30*x)),(y2-(6000*(y-0.86))),outline="#f11", fill="#1f1", width=1) + w.create_line(prev[0],prev[1],curr[0],curr[1]) + prev[0] = curr[0] + prev[1] = curr[1] + Label(master,text="Graph for INR").place(x=950,y=100) + Label(master,text="Graph for GBP").place(x=950,y=450) + Label(master,text="Exchange Rate with respect to EUR").place(x=50,y=50) + + print(inrList) +if __name__=="__main__": + main() diff --git a/WinsoftAssignment(T3).py b/WinsoftAssignment(T3).py new file mode 100644 index 0000000..69f95a3 --- /dev/null +++ b/WinsoftAssignment(T3).py @@ -0,0 +1,157 @@ +#This is the solution for t3 of assignment + +#tkinter trial +from tkinter import * +import json + +def checkered(canvas, line_distance,canvas_width,canvas_height): + # vertical lines at an interval of "line_distance" pixel + for x in range(line_distance,canvas_width,line_distance): + canvas.create_line(x, 0, x, canvas_height, fill="#86d0db") + # horizontal lines at an interval of "line_distance" pixel + for y in range(line_distance,canvas_height,line_distance): + canvas.create_line(0, y, canvas_width, y, fill="#86d0db") + +def sortDay(inrList): + return int(inrList[0][2]) + +def main(): + # Opening JSON file + with open('data.json') as json_file: + data = json.load(json_file) + + with open('latest-rates.json') as json_file: + latest_data = json.load(json_file) + + gbpList = [] + inrList = [] + tmp = [] + d = [] + for i in data['rates']: + d = (i.split('-')) + if d[1] == '01': + tmp.append(d) + tmp.append(data['rates'][i]['INR']) + inrList.append(tmp) + tmp = [] + tmp.append(d) + tmp.append(data['rates'][i]['GBP']) + gbpList.append(tmp) + tmp = [] + + #sorting the inr and gbp lists based on dates in january month + inrList.sort(key = sortDay) + gbpList.sort(key = sortDay) + + master = Tk() + master.geometry("1400x800") + canvas_width = 1100 + canvas_height = 1500 + w = Canvas(master, width=canvas_width, height=canvas_height) + w.place(x=20,y=20) + + checkered(w,30,canvas_width,canvas_height) + + w.create_line(60,0,60,750) + w.create_line(30, 720, 1000, 720) + + i=70 + j=300 + + for a in range(32): + Label(master,text=a).place(x=i,y=750) + i=i+30 + + #labeling y axis for inr + a=75 + while a<=82: + Label(master,text=a).place(x=40,y=j-50) + j=j-30 + a=a+1 + + #labeling y axis for gbp + a = 0.79 + j = 750 + while a <= 0.91: + Label(master,text=round(a,2)).place(x=40,y=j-50) + j = j - 30 + a = a + 0.01 + + + + latest_inr = latest_data['rates']['INR'] + latest_gbp = latest_data['rates']['GBP'] + + + #w.create_rectangle(58, 238, 62, 242,outline="#f11", fill="#1f1", width=1) + x1 = 58 + y1 = 238 + x2 = 62 + y2 = 242 + + print("Printing gbp list: ") + print(gbpList) + print("Printing inr list: ") + print(inrList) + #print("printing all i's:") + x = int(inrList[0][0][2]) + y = inrList[0][1] + prev = [(60),(240)] + for i in inrList: + #print(i) + y = i[1] + x = (int(i[0][2])) + curr = [60+(30*x),(240-(30*(y-75)))] + w.create_rectangle((x1+(30*x)),(y1-(30*(y-75))),(x2+(30*x)),(y2-(30*(y-75))),outline="#f11", fill="#f11", width=1) + w.create_line(prev[0],prev[1],curr[0],curr[1], fill = "green", width = 2) + prev[0] = curr[0] + prev[1] = curr[1] + + w.create_rectangle(58, 688, 62, 692,outline="#f11", fill="#1f1", width=1) + x1 = 58 + y1 = 688 + x2 = 62 + y2 = 692 + + prev = [60,690] + for i in gbpList: + print(i) + y = i[1] + x = (int(i[0][2])) + curr = [60+(30*x),(690-(3000*(y-0.79)))] + w.create_rectangle((x1+(30*x)),(y1-(3000*(y-0.79))),(x2+(30*x)),(y2-(3000*(y-0.79))),outline="#f11", fill="#f11", width=1) + w.create_line(prev[0],prev[1],curr[0],curr[1], fill = "green", width = 2) + prev[0] = curr[0] + prev[1] = curr[1] + + #plotting the line for latest values of inr + x1 = 58 + y1 = 238 + x2 = 62 + y2 = 242 + x = 60 + y = latest_inr + print(y) + w.create_rectangle(58, 238-(30*(y-75)), 62, 242-(30*(y-75)),outline="#f11", fill="#1f1", width=1) + w.create_line(60,240-(30*(y-75)),60*31,240-(30*(y-75)),fill = "#f11", width = 2) + + #plotting the line for latest values of gbp + x1 = 58 + y1 = 658 + x2 = 62 + y2 = 662 + x = 60 + y = latest_gbp + print(y) + w.create_rectangle(58, 688-(3000*(y-0.79)), 62, 692-(3000*(y-0.79)),outline="#f11", fill="#1f1", width=1) + w.create_line(60,690-(3000*(y-0.79)),60*31,690-(3000*(y-0.79)),fill = "#f11", width = 2) + + Label(master,text="Graph for INR").place(x=900,y=30) + Label(master,text="Graph for GBP").place(x=900,y=520) + Label(master,text="Current Rate for INR").place(x=150,y=230) + Label(master,text="Current rate for GBP").place(x=150,y=660) + + + +if __name__=="__main__": + main() diff --git a/WinsoftAssignment.py b/WinsoftAssignment.py new file mode 100644 index 0000000..e69de29