Find Nth Node in Inorder Traversal of a Tree in Python

AmitDiwan
Updated on 15-Apr-2021 13:35:21

245 Views

When it is required to find the ‘n’th node using inorder traversal of a binary tree, a binary tree class is created with methods to set the root element, add elements to left or right, perform in order traversal and so on. An instance of the class is created, and it can be used to access the methods.Below is a demonstration of the same −Example Live Democlass BinaryTree_struct:    def __init__(self, key=None):       self.key = key       self.left = None       self.right = None    def set_root(self, key):       self.key = key ... Read More

Convert Singly Linked List to Circular List in Python

AmitDiwan
Updated on 15-Apr-2021 13:34:59

378 Views

When it is required to convert a singly linked list into a circular linked list, a method named ‘convert_to_circular_list’ is defined that ensures that the last elements points to the first element, thereby making it circular in nature.Below is a demonstration of the same −Example Live Democlass Node:    def __init__(self, data):       self.data = data       self.next = None class LinkedList_struct:    def __init__(self):       self.head = None       self.last_node = None    def add_elements(self, data):       if self.last_node is None:          self.head = Node(data) ... Read More

Disable Typing in a TTK Combobox in Tkinter

Dev Prakash Sharma
Updated on 15-Apr-2021 13:33:03

3K+ Views

The ttk.Combobox is used to create dropdown menus in the Entry Widgets. To create the options, we just simply pass the strings to the values object of combobox. We can disable the combobox by passing the state as “readonly”.ExampleIn the following example, we will create a combobox whose state is disabled.#Import tkinter library from tkinter import * from tkinter import ttk #Create an instance of tkinter frame win = Tk() #Set the geometry of tkinter window win.geometry("750x250") #Create an instance of StringVar var= StringVar() #Create an Label Label(win, text="Select any Language", font= ('Helvetica 15 bold')).pack(pady=20) #Create Object of Tkinter Combobox ... Read More

Expand Text Widget to Fill Entire Parent Frame in Tkinter

Dev Prakash Sharma
Updated on 15-Apr-2021 13:31:30

3K+ Views

Tkinter text widgets are generally used to create text fields that support multi-line user Input. Let us suppose that we have to resize the text widget that is defined in a separate frame. To enable the text widget to resize in its full screen, we can use the columnand row configuration property of the grid system.We will use the grid_columnconfigure() property. It has four valid options like, Minsize − To provide the minimum size to the screen permitted in the application.Weight − Adds space to the widget in the layout.uniform − Place the column in a uniform group with other ... Read More

Use Boto3 to Paginate Through Object Versions of an S3 Bucket in AWS Glue

Ashish Anand
Updated on 15-Apr-2021 13:30:08

728 Views

Problem Statement: Use boto3 library in Python to paginate through object versions of a S3 bucket from AWS Glue Data Catalog that is created in your accountApproach/Algorithm to solve this problemStep 1: Import boto3 and botocore exceptions to handle exceptions.Step 2: max_items, page_size and starting_token are the optional parameters for this function, while bucket_name is required parameters.max_items denote the total number of records to return. If the number of available records > max_items then a NextToken will be provided in the response to resume pagination.page_size denotes the size of each page.starting_token helps to paginate, and it uses NextKeyMarker from a ... Read More

Get List of All Versions of an Object from S3 in AWS

Ashish Anand
Updated on 15-Apr-2021 13:29:48

3K+ Views

In this article, we will see how to get the list of all versions of the object from S3 those are present in AWS Resource.ExampleList out all the versions of test.zip from Bucket_1/testfolder of S3.Problem Statement: Use boto3 library in Python to get list of all versions of the object from S3.Approach/Algorithm to solve this problemStep 1: Import boto3 and botocore exceptions to handle exceptions.Step 2: bucket_name is the required parameter.Step 3: Create an AWS session using boto3 libStep 4: Create an AWS client for s3Step 5: Now, list out all version of the object of the given bucket using ... Read More

Getting Every Child Widget of a Tkinter Window

Dev Prakash Sharma
Updated on 15-Apr-2021 13:28:18

13K+ Views

In order to get the information about the widgets, tkinter provides a set of methods that can be used to test the widgets in an application. In order to get the list of all the child widgets, we can use the winfo_children() method.ExampleIn this example, we have defined some widgets in a frame and by using the winfo_children() method, we will print the list containing the names of all the widgets.#Import tkinter library from tkinter import * #Create an instance of tkinter frame win = Tk() #Set the geometry win.geometry("750x200") #Create a frame frame= Frame(win) #Create label, button widgets Label(frame, ... Read More

Use Boto3 to Paginate Through All Triggers in AWS Glue

Ashish Anand
Updated on 15-Apr-2021 13:27:48

224 Views

Problem Statement: Use boto3 library in Python to paginate through all triggers from AWS Glue Data Catalog that is created in your accountApproach/Algorithm to solve this problemStep 1: Import boto3 and botocore exceptions to handle exceptions.Step 2: max_items, page_size and starting_token are the optional parameters for this functionmax_items denote the total number of records to return. If the number of available records > max_items, then a NextToken will be provided in the response to resume pagination.page_size denotes the size of each page.starting_token helps to paginate, and it uses NextToken from a previous response.Step 3: Create an AWS session using boto3 ... Read More

Check if a Singly Linked List is a Palindrome in Python

AmitDiwan
Updated on 15-Apr-2021 13:27:17

232 Views

When it is required to check if a singly linked list is a palindrome or not, methods to add an element, get the previous node and to check if a palindrome is formed are defined.Below is a demonstration of the same −Example Live Democlass Node:    def __init__(self, data):       self.data = data       self.next = None class LinkedList_struct:    def __init__(self):       self.head = None       self.last_node = None    def add_elements(self, data):       if self.last_node is None:          self.head = Node(data)       ... Read More

Disable Underlying Window When Popup is Created in Python Tkinter

Dev Prakash Sharma
Updated on 15-Apr-2021 13:26:46

2K+ Views

We are familiar with popup and used it in many applications. Popup in a tkinter application can be created by creating an instance of Toplevel(root) window. For a particular application, we can trigger the popup on a button object.Let us create a Python script to close the underlying or the main window after displaying the popup. We can close the main window while residing in a popup window by using the withdraw() method.ExampleThrough this example, we will create a popup dialog that can be triggered after clicking a button. Once the popup will open, the parent window will close automatically.#Import ... Read More

Advertisements