Dev Prakash Sharma

Dev Prakash Sharma

414 Articles Published

Articles by Dev Prakash Sharma

Page 34 of 42

How do I close a tkinter window?

Dev Prakash Sharma
Dev Prakash Sharma
Updated on 04-Mar-2021 14K+ Views

Creating an application using tkinter is easy but sometimes, it becomes difficult to close the window or the frame without closing it through the button on the title bar. In such cases, we can use the .destroy() method to close the window.As tkinter attributes are independent of each other, we can create a separate method to close the window using a button.Example#Import the library from tkinter import * #Create an instance of window win = Tk() #Set the geometry of the window win.geometry("700x400") #Define a function to close the window def close_win():    win.destroy() #Create a ...

Read More

Good example of functional testing a Python Tkinter application

Dev Prakash Sharma
Dev Prakash Sharma
Updated on 04-Mar-2021 3K+ Views

Let us suppose that we have a GUI-based Python tkinter application that takes the text input from the user and validates by saving it in a new text file. The file contains the same text input that the user has typed. We can check and validate the user input from the file.In Functional Testing, we are primarily concerned about backend API, database, user-server communication, Input and output, etc.To check the application using the functional testing strategy, we have to first understand the user requirement and the input/output. After testing the pre-phase, we test our application for different test cases.For example, ...

Read More

Dynamically Resize Buttons When Resizing a Window using Tkinter

Dev Prakash Sharma
Dev Prakash Sharma
Updated on 04-Mar-2021 2K+ Views

Python has many rich libraries for creating and developing GUI-based applications. Tkinter is one of the most commonly used Python libraries for creating GUI-based applications. It has many features like adding widgets and other necessary attributes necessary for creating an application.A button is a widget which can be assigned for some particular task or event. However, to dynamically resize or position the button widget, we can configure its position and layout using the Grid module in tkinter. To resize the button dynamically, we can use rowconfiguration() and coloumnconfiguration() methods.In a tkinter Grid system, there are four attributes which can be ...

Read More

Creating a Transparent window in Python Tkinter

Dev Prakash Sharma
Dev Prakash Sharma
Updated on 04-Mar-2021 1K+ Views

Python is the most popular language for developing and creating functional and desktop applications. It has a rich library of different modules and functions which provides extensibility and accessibility to create and develop applications.Tkinter is the most commonly used library for creating GUI-based applications. It has features like adding widgets and other necessary attributes.Let us suppose that we want to create a transparent window using tkinter. To create the transparent window, we can use the attributes property and define the opacity value.Example#Importing the tkinter library from tkinter import * #Create an instance of tkinter frame win= Tk() #Define ...

Read More

Creating a Frameless window in Python Tkinter

Dev Prakash Sharma
Dev Prakash Sharma
Updated on 04-Mar-2021 5K+ Views

Tkinter is the most commonly used Python library for creating GUI-based applications. It has features like adding widgets and other necessary attributes.Let us suppose that we want to create a borderless window using tkinter. To create a borderless window, we can use the overrideredirect method which basically disables the window and removes the window element such as the closing button, title, minimization element and buttons, etc.overrideredirect is a Boolean function which can be either True or False. Once the window is opened, it can be closed by pressing Alt+F4.Example#Importing the tkinter library from tkinter import * #Create an instance ...

Read More

Create a Date Picker Calendar in Tkinter

Dev Prakash Sharma
Dev Prakash Sharma
Updated on 04-Mar-2021 3K+ Views

Tkinter is a popular Python library for creating and developing applications. It has various methods and functions that can be used for adding multiple features in an application.Tkcalendar is one of the tkinter packages that can be used to create GUI-based calendars in the window and thus, we can perform multiple operations like selecting the data, picking and scheduling the event through the calendar application and many more.However, in this article, we will see how we can create a Date Picker calendar using the Tkcalendar package. Before that, we have to install the package in our local environment using pip ...

Read More

Average Speed Calculator using Tkinter

Dev Prakash Sharma
Dev Prakash Sharma
Updated on 04-Mar-2021 560 Views

In this article, we will see how to create a GUI-based application that will calculate the average speed. The average speed of a moving object can be calculated using the following formula, Average Speed = Distance / [Hours + (Minutes/60)]To select the input value, we will use the SpinBox method that is used to create a spinner for a range of values. These values are Distance (Kilometers), Hours, and Minutes.Examplefrom tkinter import * #Create an instance of tkinter frame win = Tk() #Set the geometry and resize the frame win.geometry("700x400") win.resizable(0, 0) win.title("Average Speed Calculator") # Create Label ...

Read More

How to Plot Cluster using Clustermaps class in Matplotlib

Dev Prakash Sharma
Dev Prakash Sharma
Updated on 23-Feb-2021 324 Views

Let us suppose you have given a dataset with various variables and data points thus in order to plot the cluster map for the given data points we can use Clustermaps class.In this example, we will import the wine quality dataset from the https://archive.ics.uci.edu/ml/datasets/wine+quality.import matplotlib.pyplot as plt import numpy as np import seaborn as sns sns.set(style='white') #Import the dataset wine_quality = pd.read_csv(‘winequality-red.csv’ delimeter=‘;’)Let us suppose we have raw data of wine Quality datasets and associated correlation matrix data.Now let us plot the clustermap of the data, row_colors = wine_quality["quality"].map(dict(zip(wine_quality["quality"].unique(), "rbg"))) g = sns.clustermap(wine_quality.drop('quality', axis=1), standard_scale=1, robust=True, row_colors=row_colors, cmap='viridis')Plot the ...

Read More

C++ Program to Check Whether a given Binary Tree is a Full Binary Tree or not

Dev Prakash Sharma
Dev Prakash Sharma
Updated on 23-Feb-2021 2K+ Views

Given a Binary Tree, the task is to check whether it is a Full Binary Tree or not. A Binary Tree is said to be a Full Binary Tree if every node has zero or two children.For ExampleInput-1Output:1Explanation: Every node except the leaf node has two children, so it is a full binary tree.Input-2: Output:0Explanation: Node 2 has only one child, so it is not a full binary tree.Approach to Solve this ProblemTo check whether a given binary tree is full or not, we can check recursively for the left subtree and right subtree.Input a given Binary Tree having nodes and its children.A ...

Read More

C++ Program to find the smallest digit in a given number

Dev Prakash Sharma
Dev Prakash Sharma
Updated on 23-Feb-2021 4K+ Views

Given a non-negative number, the task is to find its smallest digit.For exampleInput:N = 154870Output:0Explanation: In the given number '154870', the smallest digit is '0'.Approach to Solve this ProblemThe simplest approach to solve this problem is to extract the last digit in the given number using the remainder theorem. While traversing the number, we will check if the extracted digit is less than the last digit, then return the output.Take a number n as the input.An integer function smallest_digit(int n) takes 'n' as the input and returns the smallest digit in the given number.Now initialize min as the last digit of the ...

Read More
Showing 331–340 of 414 articles
« Prev 1 32 33 34 35 36 42 Next »
Advertisements