Saturday, December 31, 2022

TwentyTwentyThree

It is a well known fact: Turtle is something of a Party Animal who would

enjoy ringing in the New Year at various Hot Spots around the world. So where 

should Turtle be at any given time during the day!

                                                                


 https://www.timeanddate.com/time/map/

Starting things off at 7 AM this morning in Montreal, 2023 is entering the scene in 

the Time Zone on the far right. How to calculate this: Adding 5 hours to mytime gives

UTC time, 12 noon in London. Adding 12 hours to that, it is midnight on the

other side of the world.


So keeping track during the, let us say at 8 AM mytime, it is then 1 in the afternoon

in London; (12 -1) hours away to the right, it is the New Year.


Have a good one, Turtle.

                                                      *     *     *

For a bit of background on the calendar module. The current one dates from

2017. It is straightforward.

                                                       


It is when we pair it with tkinter that things get intereting. That's

because it is the purpose of tkinter to provide GUIs ie user interfaces:

Our monthly numbers now show up in a text area.


Below, a full example with both an input and display area:

                                                 

from tkinter import *
import calendar

root = Tk()
# root.geometry("400x300")

root.title("Calendar")

# Function
def text():
month_int = int(month.get())
year_int = int(year.get())
cal = calendar.month(year_int, month_int)
textfield.delete(0.0, END)
textfield.insert(INSERT, cal)

# Creating Labels
label1 = Label(root, text="Month:")
label1.grid(row=0, column=0)

label2 = Label(root, text="Year:")
label2.grid(row=0, column=1)

# Creating spinbox
month = Spinbox(root, from_=1, to=12, width=8)
month.grid(row=1, column=0, padx=5)

year = Spinbox(root, from_=2000, to=2100, width=10)
year.grid(row=1, column=1, padx=10)

# Creating Button
button = Button(root, text="Go", command=text)
button.grid(row=1, column=2, padx=10)

# Creating Textfield
textfield = Text(root, width=25, height=10, fg="red")
textfield.grid(row=2, columnspan=2)

root.mainloop()

                                                                          


https://github.com/geekcomputers/Python/blob/master/Calendar%20(GUI)

No comments: