Programming Articles - Page 1225 of 3363

Creating Tkinter full-screen application

Dev Prakash Sharma
Updated on 08-Oct-2021 13:01:26

3K+ Views

Tkinter initially creates a window that contains application components such as widgets and control bars. We can switch a native-looking application to a full-screen application by using the attribute(‘-fullscreen’, True) method. To make the window full-screen, just invoke the method with the particular window.Example# Import tkinter library from tkinter import * # Create an instance of tkinter frame or window win = Tk() # Set the geometry of tkinter frame win.geometry("750x250") # Create a Text widget text= Label(win, text=" HelloWelcome to Tutorialspoint.com!", font=('Century Schoolbook', 20, 'italic bold')) text.pack(pady=30) win.attributes('-fullscreen', True) win.mainloop()OutputExecuting the above code will ... Read More

Creating a prompt dialog box using Tkinter?

Dev Prakash Sharma
Updated on 21-Apr-2021 07:34:02

2K+ Views

Dialog Boxes are handy for informing users to perform certain operations. We are already familiar with the dialog boxes and interacted with them many times. In a particular Tkinter application, we can create any type of dialog boxes, such as Message, User Interaction Dialogs, Single Value Entry Dialogs, File chooser, etc. To create dialog boxes, Tkinter has several built-in packages like a messagebox, simpledialog, filedialog, and colorchooser.ExampleIn this example, we will create a message box to inform the user to choose an option.#Import the tkinter library from tkinter import * from tkinter import messagebox #Create an instance of Tkinter frame ... Read More

Convert PDF to CSV using Python

Dev Prakash Sharma
Updated on 21-Apr-2021 07:33:41

17K+ Views

Python is well known for its huge library of packages. With the help of libraries, we will see how to convert a PDF to a CSV file. A CSV file is nothing but a collection of data, framed along with a set of rows and columns. There are various packages available in the Python library to convert PDF to CSV, but we will use the Tabula-py module. The major part of tabula-py is written in Java that first reads the PDF document and converts the Python DataFrame into a JSON object.In order to work with tabula-py, we must have Java ... Read More

Convert Images to PDFs using Tkinter

Dev Prakash Sharma
Updated on 21-Apr-2021 07:33:13

647 Views

Python is a scripting language and thus, it helps in many ways to create file converters such as CSV to PDF, PDF to DOC, and vice-versa. With the help of certain libraries, we can also create an application that converts images into PDF. To create such an application, we use the img2pdf module in Python. It helps to parse the image binary and converts it into PDFs.We will follow these steps to create an application, First, make sure the system has img2pdf requirements already in place. Type pip install img2pdf on your terminal to install the package. Import img2pdf in ... Read More

Changing ttk Button Height in Python

Dev Prakash Sharma
Updated on 21-Apr-2021 07:32:52

4K+ Views

Ttk adds styles to the tkinter’s standard widget which can be configured through different properties and functions. We can change the height of the ttk button by using the grid(options) method. This method contains various attributes and properties with some different options. If we want to resize the ttk button, we can specify the value of internal padding such as ipadx and ipady.ExampleLet us understand it with an example, #Import tkinter library from tkinter import * from tkinter import ttk #Create an instance of tkinter frame or window win = Tk() #Set the geometry of tkinter frame win.geometry("750x250") #Create a ... Read More

Python Program to solve Maximum Subarray Problem using Divide and Conquer

AmitDiwan
Updated on 19-Apr-2021 11:13:29

432 Views

When it is required solve the maximum subarray problem using the divide and conquer method, Below is the demonstration of the same −Example Live Demodef max_crossing_sum(my_array, low, mid, high):    sum_elements = 0    sum_left_elements = -10000    for i in range(mid, low-1, -1):    sum_elements = sum_elements + my_array[i]    if (sum_elements > sum_left_elements):       sum_left_elements = sum_elements    sum_elements = 0    sum_right_elements = -1000    for i in range(mid + 1, high + 1):       sum_elements = sum_elements + my_array[i]       if (sum_elements > sum_right_elements):     ... Read More

Sort a List of Tuples in Increasing Order by the Last Element in Each Tuple using Python program

AmitDiwan
Updated on 19-Apr-2021 11:12:41

916 Views

When it is required to sort a list of tuples in increasing order based on last element of every tuple, a method is defined, that iterates over the tuple and performs a simple swap to achieve the same.Below is the demonstration of the same −Example Live Demodef sort_tuple(my_tup):    my_len = len(my_tup)    for i in range(0, my_len):       for j in range(0, my_len-i-1):          if (my_tup[j][-1] > my_tup[j + 1][-1]):             temp = my_tup[j]             my_tup[j]= my_tup[j + 1]         ... Read More

Python Program to Generate Random Numbers from 1 to 20 and Append Them to the List

AmitDiwan
Updated on 19-Apr-2021 11:12:22

614 Views

When it is required to generate random numbers within a given range and append them to a list, a method is defined, that generates random numbers and ‘append’s them to an empty list.Below is the demonstration of the same −Example Live Demoimport random def random_gen(beg, end, my_num):    my_result = []    for j in range(my_num):       my_result.append(random.randint(beg, end))    return my_result my_num = 19 beg = 1 end = 20 print("The number is :") print(my_num) print("The start and end values are :") print(beg, end) print("The elements are : ") print(random_gen(beg, end, my_num))OutputThe number is : 19 The start ... Read More

Python Program to Find the Cumulative Sum of a List where the ith Element is the Sum of the First i+1 Elements From The Original List

AmitDiwan
Updated on 19-Apr-2021 11:11:58

461 Views

When it is required to find the sum of a list where the specific element is sum of first few elements, a method is defined, that takes list as parameter. It uses list comprehension to find the cumulative sum.Below is the demonstration of the same −Example Live Demodef cumulative_sum(my_list):    cumulative_list = []    my_length = len(my_list)    cumulative_list = [sum(my_list[0:x:1]) for x in range(0, my_length+1)]    return cumulative_list[1:] my_list = [10, 20, 25, 30, 40, 50] print("The list is :") print(my_list) print("The cumulative sum is :") print (cumulative_sum(my_list))OutputThe list is : [10, 20, 25, 30, 40, 50] The cumulative ... Read More

Python Program to Find all Numbers in a Range which are Perfect Squares and Sum of all Digits in the Number is Less than 10

AmitDiwan
Updated on 19-Apr-2021 11:11:40

1K+ Views

When it is required to find all numbers in a range where there are perfect square, and sum of digits in the number is less than 10, list comprehension is used.Below is the demonstration of the same −Example Live Demolower_limit = int(input(“Enter the lower range: “)) upper_limit = int(input(“Enter the upper range: “)) my_list = [] my_list = [x for x in range(lower_limit,upper_limit+1) if (int(x**0.5))**2==x and sum(list(map(int,str(x))))

Advertisements