Final Program Post 3
This is the complete source code for my project. I would say you could see all the stuff I had to learn in here. I really enjoy how I think it will be used in the end.
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 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 |
""" Name: Cruise Trumbley Final Program: "Clock Buddy" Explain: This program will give the oppurtunity to have a great nightstand buddy. This means that it can wake you up whenever you need it to. It will also provide you with a daily forecast so you know what to expect before you go out fo the day. """ import os import time, math from time import sleep from tkinter import * from math import cos, sin from time import gmtime, sleep def main(): clock_display() weather_display() def weather_display(): pass def clock_display(): #defining of secondary functions drawcircle(Alpha,Beta,Rayon,Couleur,can) drawPetAig(CoordA, CoordZ, Taille, Omega, can) drawGrdAig(CoordA, CoordZ, Taille, Omega, can) drawSecAig(CoordA, CoordZ, Taille, Omega, can) fondhorloge(CoordA, CoordZ, Taille, can1) def drawcircle(Alpha,Beta,Rayon,Couleur,can): # #draw a circle base on the center radius and color # x1,y1,x2,y2=Alpha-Rayon, Beta-Rayon, Alpha+Rayon, Beta+Rayon can.create_oval(x1,y1,x2,y2,fill=Couleur) def drawPetAig(CoordA, CoordZ, Taille, Omega, can): # #this makes the second hand for the clock # Pi = 3.141592 Omega = ((Omega/60)+1)*30 can.create_line(CoordA + (Taille/3) * cos(Pi*(Omega/180)), CoordZ + (Taille/3) * sin(Pi*(Omega/180)), CoordA - (Taille/8) * cos(Pi*(Omega/180)), CoordZ - (Taille/8) * sin(Pi*(Omega/180)) ) def drawGrdAig(CoordA, CoordZ, Taille, Omega, can): # #draw the minute hand, based on center. # Pi = 3.141592 Omega = (Omega-15)*6 can.create_line(CoordA + (Taille/1.5) * cos(Pi*(Omega/180)), CoordZ + (Taille/1.5) * sin(Pi*(Omega/180)), CoordA - (Taille/6) * cos(Pi*(Omega/180)), CoordZ - (Taille/6) * sin(Pi*(Omega/180))) def drawSecAig(CoordA, CoordZ, Taille, Omega, can): # #draw the hour hand # Pi = 3.141592 Omega = (Omega-15) *6 can.create_line(CoordA + (Taille/1.5) * cos(Pi*(Omega/180)), CoordZ + (Taille/1.5) * sin(Pi*(Omega/180)), CoordA - (Taille/6) * cos(Pi*(Omega/180)), CoordZ - (Taille/6) * sin(Pi*(Omega/180)), fill = "red") def fondhorloge(CoordA, CoordZ, Taille, can1): # #gives the BG for the clock # Pi = 3.141592 drawcircle(CoordA, CoordZ, Taille + (Taille/10), "grey3",can1) # #border that goes around clock # drawcircle(CoordA, CoordZ, Taille, "white",can1) # #backgroud color # drawcircle(CoordA, CoordZ, Taille/40, "grey6",can1) # #center point for the two hands # can1.create_line(CoordA + (Taille - (Taille/15)), CoordZ, CoordA + (Taille - (Taille/5)), CoordZ) # #draws hour position # can1.create_line(CoordA, CoordZ + (Taille - (Taille/15)), CoordA, CoordZ + (Taille - (Taille/5))) can1.create_line(CoordA - (Taille - (Taille/15)), CoordZ, CoordA - (Taille - (Taille/5)), CoordZ) can1.create_line(CoordA, CoordZ - (Taille - (Taille/15)), CoordA, CoordZ - (Taille - (Taille/5))) # # this section below sepereates the lines # can1.create_line(CoordA + (Taille/1.05) * cos(Pi*(30/180)), CoordZ + (Taille/1.05) * sin(Pi*(30/180)), CoordA + (Taille/1.20) * cos(Pi*(30/180)), CoordZ + (Taille/1.20) * sin(Pi*(30/180))) can1.create_line(CoordA + (Taille/1.05) * cos(Pi*(60/180)), CoordZ + (Taille/1.05) * sin(Pi*(60/180)), CoordA + (Taille/1.20) * cos(Pi*(60/180)), CoordZ + (Taille/1.20) * sin(Pi*(60/180))) can1.create_line(CoordA - (Taille/1.05) * cos(Pi*(30/180)), CoordZ - (Taille/1.05) * sin(Pi*(30/180)), CoordA - (Taille/1.20) * cos(Pi*(30/180)), CoordZ - (Taille/1.20) * sin(Pi*(30/180))) can1.create_line(CoordA - (Taille/1.05) * cos(Pi*(60/180)), CoordZ - (Taille/1.05) * sin(Pi*(60/180)), CoordA - (Taille/1.20) * cos(Pi*(60/180)), CoordZ - (Taille/1.20) * sin(Pi*(60/180))) can1.create_line(CoordA + (Taille/1.05) * cos(Pi*(30/180)), CoordZ - (Taille/1.05) * sin(Pi*(30/180)), CoordA + (Taille/1.20) * cos(Pi*(30/180)), CoordZ - (Taille/1.20) * sin(Pi*(30/180))) can1.create_line(CoordA + (Taille/1.05) * cos(Pi*(60/180)), CoordZ - (Taille/1.05) * sin(Pi*(60/180)), CoordA + (Taille/1.20) * cos(Pi*(60/180)), CoordZ - (Taille/1.20) * sin(Pi*(60/180))) can1.create_line(CoordA - (Taille/1.05) * cos(Pi*(30/180)), CoordZ + (Taille/1.05) * sin(Pi*(30/180)), CoordA - (Taille/1.20) * cos(Pi*(30/180)), CoordZ + (Taille/1.20) * sin(Pi*(30/180))) can1.create_line(CoordA - (Taille/1.05) * cos(Pi*(60/180)), CoordZ + (Taille/1.05) * sin(Pi*(60/180)), CoordA - (Taille/1.20) * cos(Pi*(60/180)), CoordZ + (Taille/1.20) * sin(Pi*(60/180))) #PRINCIPLE FUNCTION!!! def HORLOGE1(Gamma, Pi, Epsylon): # #draws the clock off of a center postion # fondhorloge(Gamma, Pi, Epsylon, can1) # #getting a time value # patate = gmtime() heure = patate[3] minute = patate[4] seconde = patate[5] drawPetAig(Gamma, Pi, Epsylon, minute, can1) drawGrdAig(Gamma, Pi, Epsylon, minute, can1) drawSecAig(Gamma, Pi, Epsylon, seconde, can1) fen1.after(1000, lambda : HORLOGE1(250, 250, 200)) # #make the magic happen # fen1 = Tk() can1 = Canvas(fen1, bg="teal", height=500, width=500) can1.pack() HORLOGE1(250, 250, 200) fen1.mainloop() fen1.destroy() main() |