Free Coding Ebook 👉 Get Now
Create a GUI Calendar Using Python
Hello coders, welcome to the codewithrandom blog. It’s time to code in Python. In this article, we create a Calendar using Tkinter in python Programming with Complete Source Code. Creating a calendar using Python and the Tkinter library is a great way to display dates and events in a graphical user interface.
Building the GUI Calendar using Tkinter in python
The following steps outline how to create a basic calendar using Python and Tkinter:
Prerequisites
step 1: open any python code Editor.
ADVERTISEMENT
step 2: Importing the Required Modules.
from tkinter import * import calendar
step 3: Copy the code for the GUI Calendar in Python, which I provided Below in this article, and save it in a file named “main.py” (or any other name you prefer).
- Run this python file main.py to start the Calendar.
complete code👇👇👇
from tkinter import * import calendar def showCal(): box = Tk() box.title("Calendar For The Year") box.geometry("550x600") find_year = int(year_field.get()) first_label = Label(box, text='CALENDAR', bg='dark grey', font=("times", 28, 'bold')) first_label.grid(row=1, column=1) box.config(background="white") cal_data = calendar.calendar(find_year) cal_year = Label(box, text=cal_data, font="consolas 10 bold", justify=LEFT) cal_year.grid(row=2, column=1, padx=20,) box.mainloop() if __name__ == "__main__": gui = Tk() gui.config(background="misty rose") gui.title("CALENDAR") gui.geometry("250x250") cal = Label(gui, text="CALENDAR", bg="lavender", font=("Helvetica", 28, 'bold', 'underline')) year = Label(gui, text="Enter Year", bg="peach puff", padx=10, pady=10) year_field = Entry(gui) Show = Button(gui, text="Show Calendar", fg="Black", bg="lavender", command=showCal) Exit = Button(gui, text="CLOSE", bg="peach puff", command=exit) cal.grid(row=1, column=1) year.grid(row=3, column=1) year_field.grid(row=4, column=1) Show.grid(row=5, column=1) Exit.grid(row=7, column=1) gui.mainloop()
output👇👇
Conclusion
In this article , we learned how to create a GUI Calendar using Python. A GUI calendar is a valuable asset for anyone looking to boost their productivity and streamline their workflow. By using a GUI calendar, you can stay organized, focused, and on top of your game, no matter what your goals or responsibilities may be. Hope you enjoyed building with us! Visit our homepage and you get lot’s of projects💝.