Advertisement
Guest User

python death date

a guest
Jun 17th, 2019
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.84 KB | None | 0 0
  1. from tkinter import *
  2. import tkinter as tk
  3. import time
  4. import random
  5. import sys
  6. import os
  7.  
  8. def menu():
  9.  
  10.     wTitle = "Death Date - KyrosDesign"
  11.    
  12.     windowMain = tk.Tk()
  13.     windowMain.geometry("400x200")
  14.     windowMain.title(wTitle)
  15.     windowMain.resizable(False, False)
  16.  
  17.     global dayBirth
  18.     global monthBirth
  19.     global yearBirth
  20.  
  21.     dayBirth = IntVar()
  22.     monthBirth = IntVar()
  23.     yearBirth = IntVar()
  24.  
  25.     global dayEntry
  26.     global monthEntry
  27.     global yearEntry
  28.  
  29.     Label(windowMain, text="Welcome in Death Date", font=("Sans-Serif",12), bg="#191919", fg="#ddd",width="50",height="2").pack()
  30.     dayLabel = Label(windowMain, text="Day: ", font=("Sans-Serif",12), fg="#191919").place(y=58,x=65)
  31.     dayEntry = Entry(windowMain, textvariable=dayBirth, fg="#191919",width="5",font=("Sans-Serif", 13))
  32.     dayEntry.place(y=58,x=120)
  33.     monthLabel = Label(windowMain, text="Month: ", font=("Sans-Serif",12), fg="#191919").place(y=98,x=65)
  34.     monthEntry = Entry(windowMain, textvariable=monthBirth, fg="#191919",width="5",font=("Sans-Serif", 13))
  35.     monthEntry.place(y=98,x=120)
  36.     yearLabel = Label(windowMain, text="Year: ", font=("Sans-Serif",12), fg="#191919").place(y=138,x=65)
  37.     yearEntry = Entry(windowMain, text="Day: ", textvariable=yearBirth, fg="#191919",width="5",font=("Sans-Serif", 13))
  38.     yearEntry.place(y=138,x=120)
  39.     Button(windowMain, text="Get Death Date", font=("Sans-Serif",9), bg="#191919", fg="#ddd",width="13",height="6", command = process).place(y=58,x=220)
  40.  
  41.     if __name__ == '__main__':
  42.         windowMain.mainloop()
  43.  
  44. def process():
  45.  
  46.     if int(dayBirth) == 0:
  47.         windowError = tk.Tk()
  48.         windowError.geometry("400x200")
  49.         windowError.title(wTitle)
  50.         windowError.resizable(False, False)
  51.        
  52.         Label(windowError, text="Invalid Date", font=("Sans-Serif",12), bg="#191919", fg="#ddd",width="50",height="10").pack()
  53.     else:
  54.         dayB = dayEntry.get()
  55.         monthB = monthEntry.get()
  56.         yearB = yearEntry.get()
  57.  
  58.         wTitle = "Death Date - KyrosDesign"
  59.    
  60.         windowGame = tk.Tk()
  61.         windowGame.geometry("400x200")
  62.         windowGame.title(wTitle)
  63.         windowGame.resizable(False, False)
  64.  
  65.         months = ['January','February','March','April','May','June','July','August','September','October','November ','December']
  66.         days = random.randint(1,31)
  67.         months = random.choice(months)    
  68.         years = random.randint(2019, 2119)
  69.         age = years - int(yearB)
  70.         result = '\nYou will die on {} {}, {}. At age {}.\n'.format(days, months, years, age)
  71.  
  72.         Label(windowGame, text="Result", font=("Sans-Serif",12), bg="#191919", fg="#ddd",width="50",height="2").pack()
  73.         Label(windowGame, text=result, font=("Sans-Serif",12), bg="#191919", fg="#ddd",width="50",height="10").pack()
  74.  
  75.    
  76. menu()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement