{"id":1495,"date":"2020-07-11T20:05:15","date_gmt":"2020-07-11T14:35:15","guid":{"rendered":"https:\/\/copyassignment.com\/?p=1495"},"modified":"2022-10-17T12:09:58","modified_gmt":"2022-10-17T06:39:58","slug":"gui-calendar-using-python","status":"publish","type":"post","link":"https:\/\/copyassignment.com\/gui-calendar-using-python\/","title":{"rendered":"Calendar using Python"},"content":{"rendered":"\n<p>In this post, we will see how to create a <strong>calendar using Python<\/strong>. We will learn 4 different methods to create calendar using Python. For all 4 programs, we will be using a famous module named <strong>calendar<\/strong>(inbuilt with Python). This module mimics the <a href=\"https:\/\/en.wikipedia.org\/wiki\/Gregorian_calendar\">Georgian calendar<\/a>. Two methods will be used to create <strong>text-based calendars<\/strong> and the last two methods will be <strong>GUI based<\/strong>. We will understand the programs using comments. Let&#8217;s start.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" style=\"font-size:25px\">Creating text-based calendar of a year using Python<\/h2>\n\n\n\n<div style=\"height: 250px; position:relative; margin-bottom: 50px;\" class=\"wp-block-simple-code-block-ace\"><div style=\"position:absolute;top:-20px;right:0px;cursor:pointer\" class=\"copy-simple-code-block\"><span class=\"dashicon dashicons dashicons-admin-page\"><\/span><\/div><pre class=\"wp-block-simple-code-block-ace\" style=\"position:absolute;top:0;right:0;bottom:0;left:0\" data-mode=\"python\" data-theme=\"xcode\" data-fontsize=\"14\" data-lines=\"Infinity\" data-showlines=\"true\" data-copy=\"true\"># importing calendar module\nimport calendar\n# year of calendar, you can also take input from user=> int(input())\nyear = 2022\n# printing calendar\nprint(calendar.calendar(year))<\/pre><\/div>\n\n\n\n<h3 class=\"has-medium-font-size wp-block-heading\">Output:<\/h3>\n\n\n\n<figure class=\"wp-block-image size-full is-resized\"><img decoding=\"async\" data-src=\"https:\/\/copyassignment.com\/wp-content\/uploads\/2020\/07\/Creating-text-based-calendar-of-a-year-using-Python.jpg\" alt=\"Output for Creating a text-based calendar of a year using Python\" class=\"wp-image-19711 lazyload\" width=\"522\" height=\"550\" data-srcset=\"https:\/\/copyassignment.com\/wp-content\/uploads\/2020\/07\/Creating-text-based-calendar-of-a-year-using-Python.jpg 692w, https:\/\/copyassignment.com\/wp-content\/uploads\/2020\/07\/Creating-text-based-calendar-of-a-year-using-Python-285x300.jpg 285w, https:\/\/copyassignment.com\/wp-content\/uploads\/2020\/07\/Creating-text-based-calendar-of-a-year-using-Python-675x711.jpg 675w\" data-sizes=\"(max-width: 522px) 100vw, 522px\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" style=\"--smush-placeholder-width: 522px; --smush-placeholder-aspect-ratio: 522\/550;\" \/><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\" style=\"font-size:25px\">Creating text-based calendar of a month using Python<\/h2>\n\n\n\n<div style=\"height: 250px; position:relative; margin-bottom: 50px;\" class=\"wp-block-simple-code-block-ace\"><div style=\"position:absolute;top:-20px;right:0px;cursor:pointer\" class=\"copy-simple-code-block\"><span class=\"dashicon dashicons dashicons-admin-page\"><\/span><\/div><pre class=\"wp-block-simple-code-block-ace\" style=\"position:absolute;top:0;right:0;bottom:0;left:0\" data-mode=\"python\" data-theme=\"xcode\" data-fontsize=\"14\" data-lines=\"Infinity\" data-showlines=\"true\" data-copy=\"true\"># importing calendar module\nimport calendar\n# year of calendar\nyear = 2022\n# month of calendar\nmonth = 10\n# printing calendar\nprint(calendar.month(year, month))<\/pre><\/div>\n\n\n\n<h3 class=\"wp-block-heading\">Output:<\/h3>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" width=\"231\" height=\"174\" data-src=\"https:\/\/copyassignment.com\/wp-content\/uploads\/2020\/07\/Creating-text-based-calendar-of-a-month-using-Python.jpg\" alt=\"Output for Creating a text-based calendar of a month using Python\" class=\"wp-image-19708 lazyload\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" style=\"--smush-placeholder-width: 231px; --smush-placeholder-aspect-ratio: 231\/174;\" \/><\/figure>\n\n\n\n<p><strong>Now, to create GUI-based calendars, we will be using the Tkinter module.<\/strong><\/p>\n\n\n\n<h2 class=\"wp-block-heading\" style=\"font-size:25px\">Creating GUI-based calendar of a year using Python<\/h2>\n\n\n\n<div style=\"height: 250px; position:relative; margin-bottom: 50px;\" class=\"wp-block-simple-code-block-ace\"><div style=\"position:absolute;top:-20px;right:0px;cursor:pointer\" class=\"copy-simple-code-block\"><span class=\"dashicon dashicons dashicons-admin-page\"><\/span><\/div><pre class=\"wp-block-simple-code-block-ace\" style=\"position:absolute;top:0;right:0;bottom:0;left:0\" data-mode=\"python\" data-theme=\"xcode\" data-fontsize=\"14\" data-lines=\"Infinity\" data-showlines=\"true\" data-copy=\"true\"># importing tkinter\nfrom tkinter import *\n# importing calendar module\nimport calendar\n# initializing tkinter\nroot = Tk()\n# setting title of our Gui\nroot.title(\"My Own Gui Calendar\")\n# year for which we want the calendar to be shown on our Gui\nyear = 2022\n# storing 2022 year calendar data inside myCal\nmyCal = calendar.calendar(year)\n# showing calendar data using label widget\ncal_year = Label(root, text=myCal, font=\"Consolas 10 bold\")\n# packing the Label widget\ncal_year.pack()\n# running the program in ready state\nroot.mainloop()<\/pre><\/div>\n\n\n\n<h3 class=\"wp-block-heading\">Output:<\/h3>\n\n\n\n<figure class=\"wp-block-image size-full is-resized\"><img decoding=\"async\" data-src=\"https:\/\/copyassignment.com\/wp-content\/uploads\/2020\/07\/Creating-GUI-based-calendar-of-a-year-using-Python.jpg\" alt=\"Output for Creating a GUI-based calendar of a year using Python\" class=\"wp-image-19710 lazyload\" width=\"528\" height=\"541\" data-srcset=\"https:\/\/copyassignment.com\/wp-content\/uploads\/2020\/07\/Creating-GUI-based-calendar-of-a-year-using-Python.jpg 768w, https:\/\/copyassignment.com\/wp-content\/uploads\/2020\/07\/Creating-GUI-based-calendar-of-a-year-using-Python-292x300.jpg 292w, https:\/\/copyassignment.com\/wp-content\/uploads\/2020\/07\/Creating-GUI-based-calendar-of-a-year-using-Python-675x693.jpg 675w\" data-sizes=\"(max-width: 528px) 100vw, 528px\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" style=\"--smush-placeholder-width: 528px; --smush-placeholder-aspect-ratio: 528\/541;\" \/><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\" style=\"font-size:25px\">Creating GUI-based calendar of a month using Python<\/h2>\n\n\n\n<div style=\"height: 250px; position:relative; margin-bottom: 50px;\" class=\"wp-block-simple-code-block-ace\"><div style=\"position:absolute;top:-20px;right:0px;cursor:pointer\" class=\"copy-simple-code-block\"><span class=\"dashicon dashicons dashicons-admin-page\"><\/span><\/div><pre class=\"wp-block-simple-code-block-ace\" style=\"position:absolute;top:0;right:0;bottom:0;left:0\" data-mode=\"python\" data-theme=\"xcode\" data-fontsize=\"14\" data-lines=\"Infinity\" data-showlines=\"true\" data-copy=\"true\"># importing tkinter\nfrom tkinter import *\n# importing calendar module\nimport calendar\n# initializing tkinter\nroot = Tk()\n# setting title of our Gui\nroot.title(\"My Own Gui Calendar\")\n# year for which we want the calendar to be shown on our Gui\nyear = 2022\n# month of year\nmonth = 10\n# storing 2022 year and 10th month calendar data inside myCal\nmyCal = calendar.month(year, month)\n# showing calendar data using label widget\ncal_year = Label(root, text=myCal, font=\"Consolas 10 bold\")\n# packing the Label widget\ncal_year.pack()\n# running the program in ready state\nroot.mainloop()<\/pre><\/div>\n\n\n\n<h3 class=\"wp-block-heading\">Output:<\/h3>\n\n\n\n<figure class=\"wp-block-image size-full is-resized\"><img decoding=\"async\" data-src=\"https:\/\/copyassignment.com\/wp-content\/uploads\/2020\/07\/Creating-GUI-based-calendar-of-a-month-using-Python.jpg\" alt=\"Output for Creating a GUI-based calendar of a month using Python\" class=\"wp-image-19709 lazyload\" width=\"291\" height=\"218\" data-srcset=\"https:\/\/copyassignment.com\/wp-content\/uploads\/2020\/07\/Creating-GUI-based-calendar-of-a-month-using-Python.jpg 400w, https:\/\/copyassignment.com\/wp-content\/uploads\/2020\/07\/Creating-GUI-based-calendar-of-a-month-using-Python-300x225.jpg 300w\" data-sizes=\"(max-width: 291px) 100vw, 291px\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" style=\"--smush-placeholder-width: 291px; --smush-placeholder-aspect-ratio: 291\/218;\" \/><\/figure>\n\n\n\n<div style=\"text-align:center\" class=\"wp-block-atomic-blocks-ab-button ab-block-button\"><a href=\"https:\/\/copyassignment.com\/top-100-python-projects-with-source-code\/\" class=\"ab-button ab-button-shape-rounded ab-button-size-medium\" style=\"color:#ffffff;background-color:#3373dc\">Best 100+ Python Projects with source code<\/a><\/div>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<p><strong>Also Read:<\/strong><\/p>\n\n\n<ul class=\"wp-block-latest-posts__list is-grid columns-3 wp-block-latest-posts\"><li><a class=\"wp-block-latest-posts__post-title\" href=\"https:\/\/copyassignment.com\/python-check-armstrong-number-using-for-loop\/\">Python | Check Armstrong Number using for loop<\/a><\/li>\n<li><a class=\"wp-block-latest-posts__post-title\" href=\"https:\/\/copyassignment.com\/python-factorial-of-a-number-using-for-loop\/\">Python | Factorial of a number using for loop<\/a><\/li>\n<li><a class=\"wp-block-latest-posts__post-title\" href=\"https:\/\/copyassignment.com\/python-asking-the-user-for-input-until-they-give-a-valid-response\/\">Python | Asking the user for input until they give a valid response<\/a><\/li>\n<li><a class=\"wp-block-latest-posts__post-title\" href=\"https:\/\/copyassignment.com\/python-how-to-iterate-through-two-lists-in-parallel\/\">Python | How to iterate through two lists in parallel?<\/a><\/li>\n<li><a class=\"wp-block-latest-posts__post-title\" href=\"https:\/\/copyassignment.com\/python-how-to-sort-a-dictionary-by-value\/\">Python | How to sort a dictionary by value?<\/a><\/li>\n<li><a class=\"wp-block-latest-posts__post-title\" href=\"https:\/\/copyassignment.com\/python-remove-items-from-a-list-while-iterating\/\">Python | Remove items from a list while iterating<\/a><\/li>\n<li><a class=\"wp-block-latest-posts__post-title\" href=\"https:\/\/copyassignment.com\/python-how-to-get-dictionary-keys-as-a-list\/\">Python | How to get dictionary keys as a list<\/a><\/li>\n<li><a class=\"wp-block-latest-posts__post-title\" href=\"https:\/\/copyassignment.com\/how-to-represent-enum-in-python\/\">How to represent Enum in Python?<\/a><\/li>\n<li><a class=\"wp-block-latest-posts__post-title\" href=\"https:\/\/copyassignment.com\/5-methods-flatten-a-list-of-lists-convert-nested-list-into-a-single-list-in-python\/\">5 methods | Flatten a list of lists | Convert nested list into a single list in Python<\/a><\/li>\n<li><a class=\"wp-block-latest-posts__post-title\" href=\"https:\/\/copyassignment.com\/what-does-if-__name__-__main__-do-in-python\/\">What does if __name__ == __main__ do in Python?<\/a><\/li>\n<li><a class=\"wp-block-latest-posts__post-title\" href=\"https:\/\/copyassignment.com\/python-crud-operations-in-mongodb\/\">Python | CRUD operations in MongoDB<\/a><\/li>\n<li><a class=\"wp-block-latest-posts__post-title\" href=\"https:\/\/copyassignment.com\/create-your-own-chatgpt-with-python\/\">Create your own ChatGPT with\u00a0Python<\/a><\/li>\n<li><a class=\"wp-block-latest-posts__post-title\" href=\"https:\/\/copyassignment.com\/filter-list-in-python-10-methods\/\">Filter List in Python | 10 methods<\/a><\/li>\n<li><a class=\"wp-block-latest-posts__post-title\" href=\"https:\/\/copyassignment.com\/radha-krishna-using-python-turtle\/\">Radha Krishna using Python Turtle<\/a><\/li>\n<li><a class=\"wp-block-latest-posts__post-title\" href=\"https:\/\/copyassignment.com\/yield-keyword-in-python\/\">Yield Keyword in Python<\/a><\/li>\n<li><a class=\"wp-block-latest-posts__post-title\" href=\"https:\/\/copyassignment.com\/python-programming-examples-fundamental-programs-in-python\/\">Python Programming Examples | Fundamental Programs in Python<\/a><\/li>\n<li><a class=\"wp-block-latest-posts__post-title\" href=\"https:\/\/copyassignment.com\/python-delete-object-of-a-class\/\">Python | Delete object of a class<\/a><\/li>\n<li><a class=\"wp-block-latest-posts__post-title\" href=\"https:\/\/copyassignment.com\/python-modify-properties-of-objects\/\">Python | Modify properties of objects\u00a0<\/a><\/li>\n<li><a class=\"wp-block-latest-posts__post-title\" href=\"https:\/\/copyassignment.com\/python-classmethod\/\">Python classmethod<\/a><\/li>\n<li><a class=\"wp-block-latest-posts__post-title\" href=\"https:\/\/copyassignment.com\/python-create-a-class-that-takes-2-parameters-print-both-parameters\/\">Python | Create a class that takes 2 parameters, print both parameters<\/a><\/li>\n<li><a class=\"wp-block-latest-posts__post-title\" href=\"https:\/\/copyassignment.com\/python-create-a-class-create-an-object-of-the-class-access-and-print-property-value\/\">Python | Create a class, create an object of the class, access, and print property value<\/a><\/li>\n<li><a class=\"wp-block-latest-posts__post-title\" href=\"https:\/\/copyassignment.com\/python-find-the-maximum-element-in-a-list-using-lambda-and-reduce\/\">Python | Find the maximum element in a list using lambda and reduce()<\/a><\/li>\n<li><a class=\"wp-block-latest-posts__post-title\" href=\"https:\/\/copyassignment.com\/python-filter-numbers-that-are-not-divisible-by-3-and-4-from-a-list-using-lambda-and-filter\/\">Python | filter numbers(that are not divisible by 3 and 4) from a list using lambda and filter()<\/a><\/li>\n<li><a class=\"wp-block-latest-posts__post-title\" href=\"https:\/\/copyassignment.com\/python-lambda-function-that-returns-the-maximum-of-2-numbers\/\">Python | lambda function that returns the maximum of 2 numbers<\/a><\/li>\n<li><a class=\"wp-block-latest-posts__post-title\" href=\"https:\/\/copyassignment.com\/python-convert-all-strings-of-a-list-to-uppercase-using-lambda\/\">Python | Convert all strings of a list to uppercase using lambda<\/a><\/li>\n<li><a class=\"wp-block-latest-posts__post-title\" href=\"https:\/\/copyassignment.com\/python-square-numbers-of-a-list-using-lambda\/\">Python | Square numbers of a list using lambda<\/a><\/li>\n<li><a class=\"wp-block-latest-posts__post-title\" href=\"https:\/\/copyassignment.com\/python-reverse-and-convert-a-string-to-uppercase-using-lambda\/\">Python | Reverse and convert a string to uppercase using lambda<\/a><\/li>\n<li><a class=\"wp-block-latest-posts__post-title\" href=\"https:\/\/copyassignment.com\/python-convert-string-to-uppercase-using-lambda\/\">Python | Convert String to uppercase using lambda<\/a><\/li>\n<li><a class=\"wp-block-latest-posts__post-title\" href=\"https:\/\/copyassignment.com\/python-reverse-a-list-using-lambda\/\">Python | Reverse a list using lambda<\/a><\/li>\n<li><a class=\"wp-block-latest-posts__post-title\" href=\"https:\/\/copyassignment.com\/python-calculator-using-lambda\/\">Python | Calculator using lambda<\/a><\/li>\n<\/ul>\n\n\n<p><strong>Post Tags:<\/strong><br>calendar in python<br>calendar program in python<br>calendar module in python<br>python calendar<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In this post, we will see how to create a calendar using Python. We will learn 4 different methods to create calendar using Python. For&#8230;<\/p>\n","protected":false},"author":1,"featured_media":19787,"comment_status":"closed","ping_status":"closed","sticky":true,"template":"template-s1-c-post.php","format":"standard","meta":{"footnotes":""},"categories":[22,1061,1403],"tags":[1502,1621,1620,1444],"class_list":["post-1495","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-allcategorites","category-gui-python-projects","category-python-projects","tag-gui","tag-gui-calendar-using-python","tag-python-calendar-gui-example","tag-tkinter","wpcat-22-id","wpcat-1061-id","wpcat-1403-id"],"_links":{"self":[{"href":"https:\/\/copyassignment.com\/wp-json\/wp\/v2\/posts\/1495","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/copyassignment.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/copyassignment.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/copyassignment.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/copyassignment.com\/wp-json\/wp\/v2\/comments?post=1495"}],"version-history":[{"count":0,"href":"https:\/\/copyassignment.com\/wp-json\/wp\/v2\/posts\/1495\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/copyassignment.com\/wp-json\/wp\/v2\/media\/19787"}],"wp:attachment":[{"href":"https:\/\/copyassignment.com\/wp-json\/wp\/v2\/media?parent=1495"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/copyassignment.com\/wp-json\/wp\/v2\/categories?post=1495"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/copyassignment.com\/wp-json\/wp\/v2\/tags?post=1495"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}