|
| 1 | +{ |
| 2 | + "cells": [ |
| 3 | + { |
| 4 | + "cell_type": "code", |
| 5 | + "execution_count": 1, |
| 6 | + "metadata": {}, |
| 7 | + "outputs": [], |
| 8 | + "source": [ |
| 9 | + "#Importing tkinter module\n", |
| 10 | + "from tkinter import *\n", |
| 11 | + "#importing calendar module\n", |
| 12 | + "import calendar" |
| 13 | + ] |
| 14 | + }, |
| 15 | + { |
| 16 | + "cell_type": "code", |
| 17 | + "execution_count": 2, |
| 18 | + "metadata": {}, |
| 19 | + "outputs": [], |
| 20 | + "source": [ |
| 21 | + "#function to show calendar of the given year\n", |
| 22 | + "def showCalender():\n", |
| 23 | + " gui = Tk()\n", |
| 24 | + " gui.config(background='grey')\n", |
| 25 | + " gui.title(\"Calender GUI\")\n", |
| 26 | + " gui.geometry(\"550x600\")\n", |
| 27 | + " year = int(year_field.get())\n", |
| 28 | + " gui_content= calendar.calendar(year)\n", |
| 29 | + " calYear = Label(gui, text= gui_content, font= \"Consolas 10 bold\")\n", |
| 30 | + " calYear.grid(row=5, column=1,padx=20)\n", |
| 31 | + " gui.mainloop()" |
| 32 | + ] |
| 33 | + }, |
| 34 | + { |
| 35 | + "cell_type": "code", |
| 36 | + "execution_count": null, |
| 37 | + "metadata": {}, |
| 38 | + "outputs": [], |
| 39 | + "source": [ |
| 40 | + "#Driver code\n", |
| 41 | + "if __name__=='__main__':\n", |
| 42 | + " new = Tk()\n", |
| 43 | + " new.config(background='grey')\n", |
| 44 | + " new.title(\"Calender\")\n", |
| 45 | + " new.geometry(\"250x140\")\n", |
| 46 | + " cal = Label(new, text=\"Calender\",bg='grey',font=(\"times\", 28, \"bold\"))\n", |
| 47 | + " year = Label(new, text=\"Enter year\", bg='dark grey')\n", |
| 48 | + " year_field=Entry(new)\n", |
| 49 | + " button = Button(new, text='Show Calender',\n", |
| 50 | + "fg='Black',bg='Blue',command=showCalender)\n", |
| 51 | + "\n", |
| 52 | + " #putting widgets in position\n", |
| 53 | + " cal.grid(row=1, column=1)\n", |
| 54 | + " year.grid(row=2, column=1)\n", |
| 55 | + " year_field.grid(row=3, column=1)\n", |
| 56 | + " button.grid(row=4, column=1)\n", |
| 57 | + " # Exit.grid(row=6, column=1)\n", |
| 58 | + " new.mainloop()" |
| 59 | + ] |
| 60 | + } |
| 61 | + ], |
| 62 | + "metadata": { |
| 63 | + "kernelspec": { |
| 64 | + "display_name": "Python 3", |
| 65 | + "language": "python", |
| 66 | + "name": "python3" |
| 67 | + }, |
| 68 | + "language_info": { |
| 69 | + "codemirror_mode": { |
| 70 | + "name": "ipython", |
| 71 | + "version": 3 |
| 72 | + }, |
| 73 | + "file_extension": ".py", |
| 74 | + "mimetype": "text/x-python", |
| 75 | + "name": "python", |
| 76 | + "nbconvert_exporter": "python", |
| 77 | + "pygments_lexer": "ipython3", |
| 78 | + "version": "3.11.3" |
| 79 | + }, |
| 80 | + "orig_nbformat": 4 |
| 81 | + }, |
| 82 | + "nbformat": 4, |
| 83 | + "nbformat_minor": 2 |
| 84 | +} |
0 commit comments