Let us consider that we have created a listbox using the Listbox method in Tkinter and we want to remove multiple selected items from this list.In order to select the multiple list from the Listbox, we will use selectmode as MULTIPLE. Now iterating over the list, we can perform the delete operation using some buttons.Example#Import the required libraries from tkinter import * #Create an instance of tkinter frame or window win= Tk() #Set the geometry win.geometry("700x400") #Create a text Label label= Label(win, text="Select items from the list", font= ('Poppins bold', 18)) label.pack(pady= 20) #Define the function ... Read More
BeautifulSoup is a python library that pulls out the data from HTML and XML files. Using BeautifulSoup, we can also remove the empty tags present in HTML or XML documents and further convert the given data into human readable files.First, we will install BeautifulSoup library in our local environment using the command: pip install beautifulsoup4Example#Import the BeautifulSoup library from bs4 import BeautifulSoup #Get the html document html_object = """ Python is an interpreted, high-level and general-purpose programming language. Python's design philosophy emphasizes code readability with its notable use of significant indentation. """ #Let us create the soup ... Read More
Sometimes, while creating an application, we need to interact with external programs and applications. In order to interact with the system's applications and programs, we have to use os Module in python.In this article, we will see how we can interact with external programs and open files using the OS module in Python.First, we will define a function that will open the chosen file using the filedialog library in Python. Then, we will print the path and open the file using the os module.Example# Import the required Libraries from tkinter import * from tkinter import filedialog import os #Create ... Read More
In Tkinter, sometimes, we may want to make a text widget disabled. To achieve this, we can set the text configuration as DISABLED. This will freeze the text widget and will make it read-only.In this example, we will create a text widget and a button which will allow users to disable or freeze the text widget instantly.Example#Import the library from tkinter import * #Create an instance of window win= Tk() #Set the geometry of the window win.geometry("700x400") def disable_button(): text.config(state= DISABLED) #Label Label(win, text="Type Something", font=('Helvetica bold', 25), fg="green").pack(pady=20) #Create a Text widget text= ... Read More
Tkinter is widely used to create GUI based applications. It has many toolkits and functions or modules available which can be used to define the different attributes of a particular application. For building GUI applications it provides some widgets including buttons, text boxes and labels. We can customize the position of the widget and its coordinates on the tkinter frame using other functions and libraries.Let us suppose that we have created a text label widget which is having some position in the tkinter frame. Now, to get the actual coordinates of the widget, we can use the geometry methods available ... Read More
Tkinter allows developers to interact with the files inside the local system. In this article, we will see how to print a hardcopy of a file using Tkinter packages such as filedialog and win32api module.In order to import these packages, we have to first install these modules in our environment. To install win32api, we will use pip install pywin32Example#import the required libraries from tkinter import * from tkinter import filedialog import win32api #Create an instance of tkinter frame or window win= Tk() win.title('Print Hard Copy') win.geometry("700x400") #Define function def print_file(): file= filedialog.askopenfilename(initialdir="/", title="Select any file", filetypes=(("Text ... Read More
Increment operator (++)It is used to increment the value of a variable by 1. There are two types of increment operators, pre-increment and post-increment.The increment operator is placed before the operand in pre-increment and the value is first incremented and then the operation is performed on it.For example, z = ++a; a= a+1 z=aThe increment operator is placed after the operand in post-increment and the value is incremented after the operation is performed.For example, z = a++; z=a a= a+1Example 1Following is an example for pre-increment operator − Live Demomain ( ){ int A= 10, Z; Z= ++A; ... Read More
ProblemHow to identify a total number of upper-case alphabets in a string using C Programming?SolutionThe logic we used to count number of upper-case letters in a sentence is as follows −for(a=string[0];a!='\0';i++){ a=string[i]; if (isupper(a)){ counter=counter+1; //counter++; } }Example 1 Live Demo#include #include void main(){ //Declaring integer for number determination, string// int i=0; char a; char string[50]; int counter=0; //Reading User I/p// printf("Enter the string :"); gets(string); //Using For loop and predefined function to count upper case alpha's// for(a=string[0];a!='\0';i++){ a=string[i]; ... Read More
ProblemWrite a C program to display and add the elements using dynamic memory allocation functions.SolutionIn C, the library function malloc allocates a block of memory in bytes at runtime. It returns a void pointer, which points to the base address of allocated memory and it leaves the memory uninitialized.Syntaxvoid *malloc (size in bytes)For example, int *ptr;ptr = (int * ) malloc (1000);int *ptr;ptr = (int * ) malloc (n * sizeof (int));Note − It returns NULL, if the memory is not free.Example Live Demo#include #include void main(){ //Declaring variables and pointers, sum// int numofe, i, sum=0; int *p; ... Read More
The atexit() is a function that allows the user to register a function that has to be called based on program termination.It is a predefined function that is included in stdlib header files.Example 1 Live Demo#include #include void welcome(void){ printf("Welcome to New, "); } void world(void){ printf("World"); } int main(){ //test atexit ,call user defined function atexit(world); atexit(welcome); return 0; }OutputWelcome to New, WorldExample 2 Live Demo#include #include void first(void){ printf("This is a beautiful, "); } void second(void){ printf("Wonderful life"); } int main(){ //test atexit ,call user defined function atexit(second); atexit(first); ... Read More