Found 604 Articles for Tkinter

How to change the font on ttk.Entry in Tkinter?

Dev Prakash Sharma
Updated on 21-Apr-2021 07:44:11

2K+ Views

There are times when a user wants to insert the 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.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 ... Read More

How can I resize the root window in Tkinter?

Dev Prakash Sharma
Updated on 21-Apr-2021 07:43:48

3K+ Views

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, height)method takes width and height as instances 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.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 ... Read More

Get the text of a button widget in Tkinter

Dev Prakash Sharma
Updated on 21-Apr-2021 07:43:05

10K+ Views

Let us suppose that for a particular application, we want to retrieve the button value by its name. In such cases, we can use the .cget() function. Every tkinter widget supports the .cget() function, as it can be used to retrieve the widget configuration such as value or name.ExampleIn this particular example, we will create a button and then store the button text in a variable "mytext". Using the variable, we will display the text 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 ... Read More

Get Application Version using Python

Dev Prakash Sharma
Updated on 21-Apr-2021 07:42:48

2K+ Views

In software industries, whenever developers add a new feature, fix bugs in a particular application, they name the application to a new version, as it helps to recognize the recently updated features in that application.Using Python, we can get the version of any application. We will use pywin32 to interact with the executable files. It provides access to the win32 API which gives the ability to create COM and objects.First, install the required package by typing pip install pywin32 in the command shell.Import Dispatch to get the version number of the application.Create a variable to store the location of the ... Read More

Extract hyperlinks from PDF in Python

Dev Prakash Sharma
Updated on 04-Mar-2024 12:36:37

4K+ Views

Python has a large set of libraries for handling different types of operations. To extract the data and meta-information from a PDF, we use the PyPdf2 package. It is easy to use and has many different operations or toolkits such as Extracting the data from the PDF, Searching Keyword in the Document, Extracting Meta Information such as finding Hyperlinks, URL and other information. Using the PyPDF2 package, we will extract the hyperlink from a pdf document.We will follow these steps to extract the hyperlinks from a PDF, Install PyPDF2 in the local machine by typing pip install PyPDF2 in ... Read More

Disable Exit (or [ X ]) in Tkinter Window

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

7K+ Views

The window manager implements the Tkinter window control icons. To hide and show the Tkinter window control icons, we can use the built-in function, which describes whether we want to disable control icons’ functionality.To disable the Exit or [X] control icon, we have to define the protocol() method. We can limit the control icon definition by specifying an empty function for disabling the state of the control icon.Example#Import the tkinter library from tkinter import * from tkinter import ttk #Create an instance of Tkinter frame win= Tk() #Define the geometry of the function win.geometry("750x250") def close_win():    win.destroy() def disable_event(): ... Read More

Creating Tkinter full-screen application

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

1K+ 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

1K+ 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

15K+ 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

465 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

Advertisements