×

GUI Calendar using PyQt5 in Python

GUI:

One of the most significant factors that increased the usability of computer and digital technologies for common, less tech-savvy users is likely the development and widespread adoption of GUIs. GUIs are intuitive enough that even relatively unskilled employees without programming experience can use them. Because they are always designed with the user in mind rather than being primarily machine-centered, they have become the standard in software application programming.

The user is provided with information using manipulable visual widgets that don't require command-line input. These interface components respond to the user's interactions per the pre-programmed script, assisting each user's action. Since many GUIs represent text and graphical elements in standard formats, it is possible for programs using the same GUI software to share data. As it is patched and developed, the same software application or OS version may present distinct or marginally distinct GUIs. The appearance of an application may change depending on user needs or to enhance the user experience, even if the application's core functionality and functions remain unchanged, as was the case with the various Windows versions over time.

PyQt5:

PyQt5 is one of several solutions that Python offers for creating GUI applications. Cross-platform GUI toolkit PyQt5 is a collection of Python interfaces for Qt version 5. With the capabilities and convenience of use that this library offers, one can create an interactive computer program very quickly.  Front-end and Back-end make up a GUI application. In order to speed up development & allow more time to be spent on back-end tasks, PyQt5 has developed a tool called "QtDesigner" that allows one to drag and drop elements to create the front-end. Riverbank Computing is the company in charge of developing and maintaining PyQt. A most recent stable version is PyQt6. The PyQt main version's release cycle matches Qt's, as per the release history. The PyQt codebase is a complex system with both C++ and Python code at its core. It is therefore more difficult to create and download it from the sources than other Python libraries. A month-by-month calendar widget with a date selection option is provided by the QWidgets class's QCalendarWidget. We use calendars to set aside certain days for cultural, religious, commercial, or administrative purposes. The way this is done is by naming attention to discrete time periods, most frequently days, days, months, and years. An individual day is designated by a date in such a system.

Installation:

pip install pyqt5
pip install pyqt5-tools

utilising a QT designer tool to create a signup form. To developed this skill, buttons, text boxes, etc., no coding is necessary! It is a drag-and-drop kind of setting. Therefore, using PyQt is easier than Tkinter.

About Code;

Python programmers can develop a calendar GUI with the PyQt5 component widget QCalendar. The GUI widget toolkit from Riverbank Computing's most recent release is PyQt5. A Python interface is available for Qt, one of the best and most widely used cross-platform GUI libraries. PyQt5 combines the Py computing languages and the Qt library. With the help of this simple lesson, you can utilise PyQt to create graphical applications. Quality and date selection options are what make the QCalendar widgets more practical. It presents a month-based viewpoint. The user can select the date that use the keyboard or mouse with today's date set as the default. A solar calendar date range can also be specified.

CODE:

from PyQt5.QtWidgets import *  
from PyQt5 import QtCore, QtGui  
from PyQt5.QtGui import *  
from PyQt5.QtCore import *  
import sys    
class Window(QMainWindow):    
    def __init__(self):  
        super().__init__()    
        self.setWindowTitle("Python ")    
        self.setGeometry(100, 100, 600, 400)    
        self.UiComp()    
        self.show()    
    def UiComp (self):    
        # creating a new  Qcalanderwidget using PyQt5 
        clndr = QCalendarWidget(self)    
        # setting the gemoetry of this calender
        clndr.setGeometry(10, 10, 580, 380)      
# creating a application of PyQt5  
         Base = QApplication(sys.argv)    
# creating an window made instance
window = Window()    
# Now we start the application  
sys.exit(Base.exec())  

CODE EXPLANATION:     

Importing all the modules which are to be required that are PyQt5, QtWidgets, Qtcore, QtGui, sys. Initially we set the window title to the calendar then we get the geometry dimensions which are 100,100,600 and 400. Then after we create a UiComp function to create a calendar using the dimensions and QCalenderWidget to start the program.

OUTPUT:

GUI Calendar using PyQt5 in Python

Related Topics

Get index of element in array in python

Index : Index is a number where the element is located in the given list. In other words it is the position of the element in the list. Index can also...

4 minutes read.

GUI to extract lyrics from a song Using Tkinter in Python

GUI: A graphical interface (GUI) is a user interface that lets users interact with electronic devices like computers and smartphones by using menus, icons, and other visual cues (graphics). In contrast...

4 minutes read.

Python while loop

Loops are essential in Python or any other programming language, as they help to execute a block of code repetitively. Sometimes, situations arise where you would need to use a piece of code...

2 minutes read.

Python max() function

Python max() function The max() function in Python returns the largest item in an iterable or the largest of two or more arguments. Syntax max(iterable, *[, key, default])               or max(arg1, arg2, *args[, key])   Parameter arg1, arg2, *args: This...

1 minute read.

os.rename() method in Python

In Python, the os module provides the capacity to interact with the operating system. The operating system comes under the Python module. In this module, Python provides a specific feature...

3 minutes read.

Python tuple() function

Python tuple() function The tuple() function in Python creates a tuple object. Syntax tuple([iterable]) Parameter Iterable: This parameter represents a sequence, collection or an iterator object. Return This function returns a tuple object. Example 1 # Python Program explaining #...

1 minute read.

Python hash() function

Python hash() function The hash() function in Python returns the hash value of the object (if it has one).  Syntax hash(object) Parameter obj : This parameter represents the object which we need to convert into hash. Return This...

1 minute read.

Difference between Expression and Statement in Python

What is an expression in Python? Expression is a combination of operands and operators. Expression helps us to produce some other values. In the python programming language,  expressions produce some other value...

6 minutes read.

Conditional Expressions in Python

In Python conditional expression are sometimes referred to operator called as ternary operator. Not only Python supports ternary operator but many other programming languages supports it. Ternary operator are the...

2 minutes read.

Flutter with tensor flow in python

Python : Python is an object oriented programming language which is highly interpreted and is highly interactive. Python was created by Guido van Rossum in the year 1985 – 1990 .The...

3 minutes read.

Python Dictionary fromkeys() method

Python Dictionary fromkeys() method The dictionary.fromkeys() method in Python creates a new dictionary from the given sequence of elements and returns a dictionary with the specified keys and values. Syntax dictionary.fromkeys(sequence[, value]) Parameter sequence- This...

1 minute read.

Math Module in Python

In this article, you are going to learn everything in detail about the “ math “ module in Python. We can normally work with general operations using python without importing or...

16 minutes read.

Python Set issubset() method

Python Set issubset() method The set.issubset() method in Python returns True if all items in the set exists in the specified set, otherwise it returns False. Syntax set.issubset(set1) Parameter set- This parameter represents the set to check whether...

2 minutes read.

Python reversed() Function

Python reversed() Function The reversed() in Python returns a reverse iterator. Syntax reversed(seq) Parameter seq: This parameter represents any iterable object. Return This function returns a reversed iterator object. Example 1 # Python Program describing # the reversed() function ...

1 minute read.

How to handle exceptions in python

Prerequisite: Exceptions and errors in Python What are Exceptions? Exceptions are run-time errors that unexpectedly occur and crash a program. When occurred, it alters the flow of the program. These errors are...

9 minutes read.

Python variance() function

Variance The variance is the average of the square deviations from the mean. The variance will measure the spread of the dataset from its mean or median value. The greater the...

4 minutes read.

How to import pandas in python

How to Install Pandas in Python Python is a vast ocean of libraries, modules, and different functions. It has a solution for almost everything. Using Python, we can simplify even a...

3 minutes read.

Read numpy array in Python

Numpy is a numerical python that deals with multidimensional arrays mostly used in storing multiple values. Python's core scientific computing package is called NumPy. This Python library provides multidimensional array...

9 minutes read.

Python Network Programming

In network programming, python plays a very important role. Python provides full support for encoding and decoding data and network protocol in its standard library. Writing a network program in...

3 minutes read.

Python Set issuperset() method

Python Set issuperset() method The set.issuperset() method in Python returns a boolean value True if all items in the specified set exists in the original set, else it returns False. Syntax set.issuperset (set1) Parameter set- This parameter represents the...

2 minutes read.