Programming Articles - Page 1215 of 3363

How can I insert a string in an Entry widget that is in the "readonly" state using Tkinter?

Dev Prakash Sharma
Updated on 03-May-2021 08:58:54

942 Views

Tkinter Entry widget is used to insert single-line text input. We can use the Entry widget to create forms where single-line input is the prime requirement.Sometimes, we need to insert a predefined text inside the Entry Widget. In such cases, we can use insert(INSERT, ) method. These are generally called as Placeholders for the Entry widget.Let us suppose that we want to change the state of our text as read-only. Here, we can use state= ‘readonly’ property while configuring the Entry widget.Example#Import the required Libraries from tkinter import * from tkinter import ttk #Create an instance of tkinter frame win = ... Read More

Get contents of a Tkinter Entry widget

Dev Prakash Sharma
Updated on 20-Aug-2021 16:25:39

4K+ Views

An Entry widget is a basic one-line character widget that supports only single-line text input. An Entry widget can be defined by initializing the Entry(parent, width) constructor.To validate the Entry widget, we can use the get() method which results in the character entered in the Entry widget.Let us define an Entry widget that accepts single-line text input, and we will print the character that is input in the Entry widget.Example#Import the required Libraries from tkinter import * from tkinter import ttk #Create an instance of Tkinter frame win = Tk() #Set the geometry of Tkinter frame win.geometry("750x250") def get_content(): ... Read More

Default to and select the first item in Tkinter Listbox

Dev Prakash Sharma
Updated on 03-May-2021 08:50:24

4K+ Views

Tkinter Listbox widgets are used to display a scrollable list of items with vertically stacked menus. Sometimes, we may need to set the list item selected, by default. We can use the select_set(list_item_index) method by specifying the index of the list items that need to be selected by default.So, let us suppose that we have a list of programming languages in our Listbox and what we want is to set the first item selected, then we can provide the index of a first list item in the method. The method must be invoked before the end of mainloop() function.Example#Import tkinter ... Read More

Create multiple buttons with "different" command function in Tkinter

Dev Prakash Sharma
Updated on 03-May-2021 08:46:56

8K+ Views

A Button can be initialized using the for loop in a Tkinter application. Let us suppose that we want to create multiple buttons, each with different commands or operations defined in it. We have to first initialize the Button inside a for loop. The iterator will return the object for which multiple instances of the button will be created.ExampleIn this example, we will define some buttons that will have different commands or functionalities.#Import the required Libraries from tkinter import * from tkinter import ttk #Create an instance of Tkinter frame win = Tk() #Set the geometry of the Tkinter frame win.geometry("750x250") ... Read More

Converting Tkinter program to exe file

Dev Prakash Sharma
Updated on 03-May-2021 08:44:24

23K+ Views

Let us suppose that we want to create a standalone app (executable application) using tkinter. We can convert any tkinter application to an exe compatible file format using the PyInstaller package in Python.To work with pyinstaller, first install the package in the environment by using the following command, pip install pyinstallerOnce installed, we can follow the steps to convert a Python Script File (contains a Tkinter application file) to an Executable file.Install pyinstaller using pip install pyinstaller in Windows operating system. Now, type pyinstaller --onefile -w filename and press Enter.Now, check the location of the file (script file) and you will ... Read More

Change the color upon hovering over Button in Tkinter

Dev Prakash Sharma
Updated on 03-May-2021 08:40:58

6K+ Views

Let us suppose that we are creating an application in which we want to change the color of the Button widget while we hover upon it. We can have the hovering property by defining the Event Callbacks.To change the color of the Button while hovering on it, we have to bind the and events. For each event, we will configure the button property such as background color, foreground color, etc.Example#Import required libraries from tkinter import * #Create an instance of tkinter frame win= Tk() #Define the geometry of the window win.geometry("750x250") #Define functions def on_enter(e):    button.config(background='OrangeRed3', foreground= ... Read More

Binding mouse double click in Tkinter

Dev Prakash Sharma
Updated on 03-May-2021 07:44:15

3K+ Views

Let us suppose that for a particular application, we want to bind the mouse double-click so that it performs some event or operation. We can use the bind(‘’, handler) or bind(‘’, handler) methods to bind the mouse Left or Right Buttons with a handler or a callback function.ExampleIn this example, we will create an application that contains a button. When we double click the button, it will open a popup window.#Import required libraries from tkinter import * from tkinter import ttk #Create an instance of tkinter frame win= Tk() #Define the geometry of the window win.geometry("750x250") #Define a function def ... Read More

Automatically close window after a certain time in Tkinter

Dev Prakash Sharma
Updated on 30-Apr-2021 21:26:25

8K+ Views

In order to close a Tkinter application, we generally refer to close the parent window using the destroy() method. To close the Tkinter window automatically after a certain time limit, we have to use the after(time in ms, callback) method by specifying the time and the callback function which needs to be run after a certain time limit.Example#Import the required Libraries from tkinter import * from tkinter import ttk #Create an instance of tkinter frame win = Tk() #Set the geometry of tkinter frame win.geometry("750x270") #Initialize a Label widget Label(win, text= "This window will get closed after ... Read More

Difference Between Verification and Validation

Kiran Kumar Panigrahi
Updated on 14-Dec-2022 17:59:27

6K+ Views

Verification is the process of verifying something to ensure its correctness, while Validation is the process of validating something in which the user tests the system with some inputs and verifies whether the output is as per the expectation or not. In software testing, both Validation and Verification are the parts of the V-model in which the development and testing activities are started based on the requirement of document specification. In other words, we can say that Verification is the process to ensure whether the product that is developed is right or not. It verifies whether the developed product fulfils ... Read More

URLSearchParams values & keys() in Node

Mayank Agarwal
Updated on 28-Apr-2021 07:31:36

465 Views

Introduction to values()This function returns an iterator that allows us to iterate all over the values that are present in that object. It basically gives us a tool to select or iterate the values and then perform functions on them.SyntaxURLSearchParams.values();It will return an ES6 type iterator with the name-value pair over all the values.Example// Defining the parameters as a constant var params = new URLSearchParams( 'key1=value1&key2=value2&key3=value3'); // Iterating over the values of params for(var value of params.values()) {    console.log(value); }Outputvalue1 value2 value3Example// Defining the URL as a constant const params = new URLSearchParams('name=John&age=21'); // Iterating over the ... Read More

Advertisements