Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
-
Economics & Finance
Articles on Trending Technologies
Technical articles with clear explanations and examples
How to create a borderless fullscreen application using Python-3 Tkinter?
In order to make a Tkinter window borderless and full-screen, we can use the utility method attributes('-fullscreen', True). Tkinter windows can be configured using functions and methods defined in the Tkinter library. Another similar method Tkinter provides to make the application window full-screen is overrideredirect(True). This method can be invoked only if the application needs to resize in its defined width and height only. Method 1: Using attributes('-fullscreen', True) The attributes('-fullscreen', True) method creates a true fullscreen window that covers the entire screen including the taskbar ? # Import the required Libraries from tkinter import ...
Read MoreHow to convert PDF files to Excel files using Python?
Python provides several libraries for handling file conversions. In this article, we'll learn how to convert PDF files to Excel format using the tabula-py module. The tabula-py library is built on Java technology and can extract tabular data from PDF documents and convert it into pandas DataFrames. Prerequisites Before working with tabula-py, ensure you have Java installed on your system, as the library depends on Java for PDF processing. Installation Install the required package using pip − pip install tabula-py Basic Syntax The main functions we'll use are − ...
Read MoreHow to add an image in Tkinter?
Adding images to Tkinter applications enhances the user interface and provides visual appeal. You can display images using PIL (Pillow) library with PhotoImage and Label widgets. Basic Image Display Here's a simple example that displays a fixed image in a Tkinter window ? import tkinter as tk from PIL import Image, ImageTk # Create main window root = tk.Tk() root.title("Image Display") root.geometry("400x300") # Load and display image try: # Load image using PIL img = Image.open("sample.jpg") # ...
Read MoreHow do you check if a widget has a focus in Tkinter?
In Tkinter, you can check if a widget has focus using the focus_get() method. This method returns the widget object that currently has focus, allowing you to compare it with your target widget to determine if it's focused. Using focus_get() Method The focus_get() method is called on the root window and returns the currently focused widget object. You can compare this returned object with your widget to check if it has focus ? import tkinter as tk # Create main window root = tk.Tk() root.geometry("400x300") root.title("Focus Check Example") # Create widgets entry1 = tk.Entry(root, ...
Read MoreHow do I get an event callback when a Tkinter Entry widget is modified?
Callback functions in Tkinter are used to handle specific events in widgets. You can add an event callback function to an Entry widget that triggers whenever the widget's content is modified. This is accomplished by creating a Tkinter variable (like StringVar) and using its trace() method to monitor changes. Basic Entry Widget Callback Here's how to create a callback that responds to Entry widget modifications − import tkinter as tk def callback(var): content = var.get() print(f"Entry modified: {content}") # Create main window win = tk.Tk() win.geometry("400x200") ...
Read MoreHow to change the font on ttk.Entry in Tkinter?
There are times when a user wants to insert information like Name, contact number, Email, address, etc. Tkinter has a simple way to handle these types of inputs through its Entry widgets. Tkinter Entry widgets can be styled using the ttk package. To change other properties of the Entry widgets such as font properties, text-size, and font-style, we can use the font('font-family font-size font-style') attribute. We can specify the font property in the entry constructor. Basic Example Here's how to create a ttk.Entry with custom font properties ? # Import tkinter library from tkinter import ...
Read MoreHow can I resize the root window in Tkinter?
In this example, we will see how to resize a tkinter window using the geometry manager. Tkinter geometry manager is generally used to configure the width and height of a tkinter window. The geometry(width x height) method takes width and height as parameters and resizes the window accordingly. We can also define the position of the tkinter window by adding geometry("width x height+X+Y") where X and Y are horizontal and vertical positions of the window. Basic Window Resizing Here's how to create and resize a tkinter window ? # Import tkinter library from tkinter import ...
Read MoreGet the text of a button widget in Tkinter
When building Tkinter applications, you may need to retrieve the text content of a button widget dynamically. The cget() method allows you to get configuration values from any Tkinter widget, including button text. Syntax The basic syntax to get button text is − button_text = button.cget('text') Example Let's create a button and retrieve its text to display in a label widget − # Import tkinter library from tkinter import * from tkinter import ttk # Create an instance of tkinter frame or window win = Tk() # Set the ...
Read MoreGet Application Version using Python
In software development, whenever developers add new features or fix bugs in an application, they assign it a new version number. This helps users identify the latest updates and features available in that application. Using Python, we can retrieve the version of any application installed on Windows systems. We'll use the pywin32 library to interact with executable files through the Win32 API, which provides access to Windows system information. Installation First, install the required package ? pip install pywin32 Getting Application Version Here's how to retrieve the version number of any Windows ...
Read MoreExtract hyperlinks from PDF in Python
To extract hyperlinks from PDF in Python can be done using several libraries like PyPDF2, PDFminer, and pdfx. Each offers different approaches and capabilities for extracting URLs from PDF documents. PyPDF2: A Python built-in library that acts as a PDF toolkit, allowing us to read and manipulate PDF files. PDFMiner: A tool used for extracting information from PDF documents, focusing on getting and analyzing text data. ...
Read More