Found 310 Articles for GUI-Programming

How to Delete Tkinter Text Box's Contents?

Dev Prakash Sharma
Updated on 04-Mar-2021 14:05:41

7K+ Views

Tkinter provides many functions and modules through which we can create fully featured applications with buttons, dialogue boxes, widgets, and many more.To create a text widget, we can use the tkinter entry widget function which is basically a constructor and it takes the window or frame of the tkinter. Further, we can delete the content of this text widget using the built-in method delete(first, last=None) which basically takes a range within the textbox.In this example, we will create a Delete Button which basically deletes all the contents from the given text box.Examplefrom tkinter import * win= Tk() win.geometry("600x300") ... Read More

How to create a Splash Screen using Tkinter?

Dev Prakash Sharma
Updated on 04-Mar-2021 14:04:14

2K+ Views

Let us suppose that we want to create a splash screen using tkinter. To create a splash screen, we will follow the steps given below −Create a splash screen with some labels in it.Make the splash screen borderless using the overrideredirect method.Create a function for the main window which will appear for a time just after the splash screen.Now using the after method, we can define the time for which the main window will appear.Example#Importing the tkinter library from tkinter import * #Create an instance of tkinter frame splash_win= Tk() #Set the title of the window splash_win.title("Splash Screen ... Read More

How to Crack PDF Files in Python?

Dev Prakash Sharma
Updated on 04-Mar-2021 14:02:18

981 Views

Python has a rich collection of libraries that are used for multiple purposes like creating and developing applications, web development, scientific computation, software testing, machine learning, and many more. Python is also used for testing and developing system applications in terms of information security. There are several other libraries and tools available that contain specific scripts used for creating hashes, information gathering, information retrieval, encryption and decryption, web crawling, spoofing, and many more.In this article, we will create a program that will decrypt a password protected PDF document. For decryption, we will use a word list that contains some common ... Read More

How to copy from clipboard using tkinter without displaying a window

Dev Prakash Sharma
Updated on 04-Mar-2021 13:59:48

553 Views

Let us suppose that in a particular application, we have to copy the content residing in the clipboard. We can access the clipboard using clipboard_get().After copying the text from the clipboard, it will reside in the cache memory through which we can debug the program and display the text in the frame, then we can see the copied text from the clipboard.First, we will create a window which will store the copied characters or text from the source using the get method. Once the execution is done, then we can hide the window by using the “withdraw” method in tkinter. ... Read More

How to Change the position of MessageBox using Python Tkinter

Dev Prakash Sharma
Updated on 04-Mar-2021 13:58:35

1K+ Views

Let us suppose that we want to create a dialogue box using tkinter. To create the dialogue box we can use the MessageBox library which contains several functions to quickly create dialogue types.To adjust the position of the created Dialogue Box, we can use its “toplevel” property which basically gives the priority to the current box and keeps all the other processes in the backend.It contains some other functions like title, message, and details. To change the position of the MessageBox widget, we will use geometry method.Example#import the tkinter library from tkinter import * #define the messagebox function ... Read More

How to center an image in canvas Python Tkinter

Dev Prakash Sharma
Updated on 04-Mar-2021 13:56:43

3K+ Views

Let us consider that we are creating a GUI-based application using Tkinter and we want to load an image in the Tkinter canvas.By default, the canvas loads the images according to its width and height. However, we can manipulate the position of an image in any direction (N, S, E, W, NS, EW, etc.) by passing the ‘Direction’ value in the anchor parameter. An anchor is a parameter which is invoked along with the image function; it defines the direction or position of the image in the canvas.By using anchor parameters, we can align the text and images in any ... Read More

How to add placeholder to an Entry in tkinter?

Dev Prakash Sharma
Updated on 04-Mar-2021 13:55:10

4K+ Views

Tkinter provides features to add widgets such as button, text, entry, dialogue and other attributes that help to develop an application. However, tkinter doesn't include a placeholder in the entry widget. Placeholders are the dummy text that appears in the entry widget to inform the user about it.In this article, we will add a placeholder in the entry widget using the insert(default value, text) function that takes a default value such as 0 along with the placeholder text.Example#Import tkinter library from tkinter import* #Create an instance of frame win= Tk() #Set geometry win.geometry("700x400") #Create a text Label ... Read More

How to add padding to a tkinter widget only on one side?

Dev Prakash Sharma
Updated on 04-Mar-2021 13:53:53

5K+ Views

Let us suppose that we want to add padding on one side (either top/bottom or left/right) of a particular widget. We can achieve this in Tkinter by using its pack() and grid() methods.In pack() method, we have to define the value for “padx” and “pady”. On the other hand, the grid method requires only two tuples, i.e., x and y for adding padding around either of X-axis or Y-axis.Example#import the required library from tkinter import * #Create an instance of window or frame win= Tk() win.geometry("700x400") #Create two buttons #Add padding in x and y axis b1= ... Read More

How do you run your own code alongside Tkinter's event loop?

Dev Prakash Sharma
Updated on 04-Mar-2021 13:52:39

1K+ Views

Tkinter is widely used to create and develop GUI based applications and games. Tkinter provides its window or frame where we execute our programs and functions along with other attributes.Let us consider that we are working with a particular application and we want to write the changes in the code while running the application. Tkinter provides a callback method which can be used to run the window while iterating over it. We can keep running the window using the after(duration, task) method that will basically run the changes after a duration.In this example, we will create a window which prints ... Read More

How do I get rid of the Python Tkinter root window?

Dev Prakash Sharma
Updated on 04-Mar-2021 13:50:14

8K+ Views

Sometimes, while testing a Tkinter application, we may need to hide the Tkinter default window or frame. There are two general methods through which we can either hide our Tkinter window, or destroy it.The mainloop() keeps running the Tkinter window until it is not closed by external events. In order to destroy the window we can use the destroy() callable method.However, to hide the Tkinter window, we generally use the “withdraw” method that can be invoked on the root window or the main window.In this example, we have created a text widget and a button “Quit” that will close the ... Read More

Advertisements