Kiran Kumar Panigrahi has Published 426 Articles

How to update a Button widget in Tkinter?

Kiran Kumar Panigrahi

Kiran Kumar Panigrahi

Updated on 26-Oct-2021 14:39:35

2K+ Views

We can update a Button widget in Tkinter in various ways, for example, we can change its size, change its background color, or remove its border, etc. In the following example, we will create three Button widgets and each of the buttons, upon clicking, will call a different function to ... Read More

How to show the status of CAPS Lock Key in tkinter?

Kiran Kumar Panigrahi

Kiran Kumar Panigrahi

Updated on 26-Oct-2021 14:32:34

656 Views

We can use the and bindings to check if the CAPS Lock Key is ON or off. In the following example, we will create two user-defined functions "caps_lock_on()" and "caps_lock_off()" which will capture the event of Lock-KeyPress and Lock-KeyRelease and print the status on the screen.Example# Import required ... Read More

How to call a function using the OptionMenu widget in Tkinter?

Kiran Kumar Panigrahi

Kiran Kumar Panigrahi

Updated on 26-Oct-2021 14:28:55

4K+ Views

Let's take an example and see how to call a function using OptionMenu widget in Tkinter. In the example, we will use a StringVar object and call its get() method. A StringVar object in Tkinter can help manage the value of a widget.We will create an OptionMenu widget and fill ... Read More

How to use a StringVar object in an Entry widget in Tkinter?

Kiran Kumar Panigrahi

Kiran Kumar Panigrahi

Updated on 26-Oct-2021 13:51:25

4K+ Views

A StringVar object in Tkinter can help manage the value of a widget such as an Entry widget or a Label widget. You can assign a StringVar object to the textvariable of a widget. For example, data = ['Car', 'Bus', 'Truck', 'Bike', 'Airplane'] var = StringVar(win) my_spinbox = ... Read More

How to set a default string value on a Tkinter Spinbox?

Kiran Kumar Panigrahi

Kiran Kumar Panigrahi

Updated on 26-Oct-2021 13:48:55

2K+ Views

To set a default string value on a Tkinter Spinbox, we will have to use the set method. Let us take an example and see how to create a spinbox with a set of string values and then set a default string.Steps −Import the tkinter library and create an instance ... Read More

How to draw a line following mouse coordinates with tkinter?

Kiran Kumar Panigrahi

Kiran Kumar Panigrahi

Updated on 26-Oct-2021 13:46:39

2K+ Views

To draw a line following mouse coordinates, we need to create a function to capture the coordinates of each mouse-click and then draw a line between two consecutive points. Let's take an example and see how it can be done.Steps −Import the tkinter library and create an instance of tkinter ... Read More

How to place the text at the center of an Entry box in Tkinter?

Kiran Kumar Panigrahi

Kiran Kumar Panigrahi

Updated on 26-Oct-2021 13:44:13

8K+ Views

To put a border around a Frame in Tkinter, we have to use the highlightbackground and highlightthickeness parameters while creating the Frame. Let's take an example and see how to use these two parameters.Steps −Import the tkinter library and create an instance of tkinter frame.Set the size of the frame ... Read More

Copy from clipboard using Python and Tkinter

Kiran Kumar Panigrahi

Kiran Kumar Panigrahi

Updated on 26-Oct-2021 13:40:07

5K+ Views

To copy from clipboard, we can use the clipboard_get() method of Tkinter. Let's take an example and see how to get the data from the clipboard and display it on a Tkinter window.Steps −Import the tkinter library and create an instance of tkinter frame.Set the size of the frame using ... Read More

Display the Host Name and IP Address on a Tkinter Window

Kiran Kumar Panigrahi

Kiran Kumar Panigrahi

Updated on 26-Oct-2021 13:37:35

625 Views

To obtain a user's IP address, we can use Python's native networking interface, socket. First of all, we need to query the device's host name and then get its associated IP address.In this example, we will use the socket library to get the host name and IP address and print ... Read More

How to draw a dashed line on a Tkinter canvas?

Kiran Kumar Panigrahi

Kiran Kumar Panigrahi

Updated on 26-Oct-2021 13:35:43

3K+ Views

To draw a dashed line on a Tkinter canvas, we can use the dash parameter of create_line() method.Steps −Import the tkinter library and create an instance of tkinter frame.Set the size of the frame using geometry method.Create a Canvas widget and set its height and width.Next, use the create_line function ... Read More

Advertisements