Articles on Trending Technologies

Technical articles with clear explanations and examples

How to display a Listbox with columns using Tkinter?

Dev Prakash Sharma
Dev Prakash Sharma
Updated on 25-Mar-2026 7K+ Views

The Tkinter Treeview widget is the standard way to create a listbox with columns in Python GUI applications. Unlike a basic Listbox, Treeview can display data in tabular format with multiple columns, headers, and sorting capabilities. Creating a Treeview Widget The Treeview widget is constructed using ttk.Treeview(parent, columns, **options). The show='headings' parameter hides the tree structure and displays only the columns ? import tkinter as tk from tkinter import ttk # Create main window window = tk.Tk() window.title("Listbox with Columns") window.geometry("700x350") # Create Treeview widget with 3 columns tree = ttk.Treeview(window, columns=("c1", "c2", "c3"), ...

Read More

How to open multiple filenames in Tkinter and add the file names to a list?

Dev Prakash Sharma
Dev Prakash Sharma
Updated on 25-Mar-2026 4K+ Views

To open multiple files in a Tkinter application and add their names to a list, we use the tkinter.filedialog package. This creates a dialog box to interact with external files on the system. Importing the Required Module First, import the filedialog module ? import tkinter.filedialog as fd Using askopenfilenames() Function The askopenfilenames() function opens a file explorer window that allows users to select multiple files. It returns a tuple of selected file paths. Syntax fd.askopenfilenames(parent=None, title="Open files", **options) Complete Example Here's a complete example that opens multiple ...

Read More

How to create a directly-executable cross-platform GUI app using Python(Tkinter)?

Dev Prakash Sharma
Dev Prakash Sharma
Updated on 25-Mar-2026 2K+ Views

Python is a programming language that can create cross-platform applications for Microsoft Windows, Mac OS, and Linux. To build GUI applications, we use the Tkinter library, and to convert them into executable files, we use packaging tools. Available Tools for Creating Executables Different tools are available for different operating systems − For Windows executables − PyInstaller, py2exe For Linux executables − Freeze For Mac executables − py2app PyInstaller is the most popular choice as it works across all platforms. Installing PyInstaller First, install ...

Read More

How to read multiple text files from a folder in Python?(Tkinter)

Dev Prakash Sharma
Dev Prakash Sharma
Updated on 25-Mar-2026 7K+ Views

Python provides powerful file handling capabilities through its built-in modules. The OS module allows you to interact with the operating system and work with files and directories efficiently. When you need to read multiple text files from a specific folder, you can use the OS module to iterate through directory contents and process only the files with desired extensions. Required Steps Import the OS module Define the directory path containing text files Create a function to read file contents Iterate through files and filter by extension Read and display the contents Example Here's ...

Read More

How do I show the same Matplotlib figure several times in a single IPython notebook?

Rishikesh Kumar Rishi
Rishikesh Kumar Rishi
Updated on 25-Mar-2026 974 Views

To show the same Matplotlib figure several times in a single Jupyter notebook, you can use the fig.show() method or plt.show(). This is useful when you want to display the same plot multiple times at different points in your notebook. Basic Approach Using fig.show() Create a figure once and display it multiple times using the figure's show method ? import matplotlib.pyplot as plt # Set figure size plt.rcParams["figure.figsize"] = [7.50, 3.50] plt.rcParams["figure.autolayout"] = True # Create figure and plot data fig, ax = plt.subplots() ax.plot([2, 4, 7, 5, 4, 1]) ax.set_title('Sample Line Plot') ...

Read More

How to plot sine curve on polar axes using Matplotlib?

Rishikesh Kumar Rishi
Rishikesh Kumar Rishi
Updated on 25-Mar-2026 882 Views

To plot a sine curve on polar axes using Matplotlib, we need to create a polar coordinate system and plot angular data. Polar plots are useful for representing periodic data and circular patterns. Steps to Create a Polar Sine Plot Set the figure size and adjust the padding between and around the subplots Create a new figure using figure() method Add polar axes using add_subplot(projection='polar') Generate angular data points (theta) and radius values using numpy Plot the data using plot() method on polar axes Display the figure using show() method Example import numpy ...

Read More

How do I find the intersection of two line segments in Matplotlib?

Rishikesh Kumar Rishi
Rishikesh Kumar Rishi
Updated on 25-Mar-2026 7K+ Views

To find the intersection of two line segments in Matplotlib, we calculate where two lines meet using their slopes and intercepts, then draw horizontal and vertical lines through that point. Mathematical Formula For two lines with equations y = m1*x + c1 and y = m2*x + c2, the intersection point is: x_intersection = (c1 - c2) / (m2 - m1) y_intersection = m1 * x_intersection + c1 Example Here's how to find and visualize the intersection point ? import matplotlib.pyplot as plt import numpy as np ...

Read More

How to show minor tick labels on a log-scale with Matplotlib?

Rishikesh Kumar Rishi
Rishikesh Kumar Rishi
Updated on 25-Mar-2026 8K+ Views

In Matplotlib, displaying minor tick labels on a log-scale plot requires special formatting since log scales typically only show major ticks by default. We can achieve this by using the tick_params() method and FormatStrFormatter to control minor tick appearance. Basic Log-Scale Plot with Minor Ticks Here's how to create a log-scale plot and display minor tick labels ? import numpy as np import matplotlib.pyplot as plt from matplotlib.ticker import FormatStrFormatter # Set figure size plt.rcParams["figure.figsize"] = [7.50, 3.50] plt.rcParams["figure.autolayout"] = True # Create data points x = np.linspace(-2, 2, 10) y = np.exp(x) ...

Read More

How to fill the area under a step curve using pyplot? (Matplotlib)

Rishikesh Kumar Rishi
Rishikesh Kumar Rishi
Updated on 25-Mar-2026 12K+ Views

To fill the area under a step curve using pyplot, you can use the fill_between() method with the step parameter. This creates filled regions beneath step plots, which are useful for displaying discrete data or histogram-like visualizations. Basic Step Curve with Fill Here's how to create a simple step curve with filled area ? import matplotlib.pyplot as plt import numpy as np # Set figure size plt.rcParams["figure.figsize"] = [7.50, 3.50] plt.rcParams["figure.autolayout"] = True # Create data points x = np.linspace(-10, 10, 100) y1 = np.sin(x) y2 = np.cos(x) # Fill area under step ...

Read More

Boxplot with variable length data in Matplotlib

Rishikesh Kumar Rishi
Rishikesh Kumar Rishi
Updated on 25-Mar-2026 708 Views

To make a boxplot with variable length data in Matplotlib, we can take the following steps − Set the figure size and adjust the padding between and around the subplots. Make a list of data points with different lengths. Make a box and whisker plot using boxplot() method. To display the figure, use show() method. Basic Example Here's how to create a boxplot with datasets of different lengths ? import matplotlib.pyplot as plt plt.rcParams["figure.figsize"] = [7.50, 3.50] plt.rcParams["figure.autolayout"] = True data = [[2, 4, 1, 3], [0, 4, 3, 2], [0, ...

Read More
Showing 4211–4220 of 61,297 articles
« Prev 1 420 421 422 423 424 6130 Next »
Advertisements