Found 604 Articles for Tkinter

How to create hyperlink in a Tkinter Text widget?

Dev Prakash Sharma
Updated on 07-Jun-2021 10:58:36

3K+ Views

Tkinter Text widgets are generally used for accepting multiline user input in the given text field. For a particular text document, the content may contain hyperlinks too which is useful in case we want to redirect the user. You can create hyperlinks within the text widget by using HyperLinkManager snippet in Python.The HyperLinkManager code snippet adds the hyperlink on the keyword within the text widget. You can download the HyperLinkManager Snippet from here−https://github.com/codewithdev/Code-Snippets/blob/master/tkinter/tkHyperlinkManager.py/Once the snippet has been downloaded, you can import it in the notebook by typing "from tkHyperLinkManager import HyperlinkManager"Example# Import the required libraries from tkinter import * from ... Read More

Using OpenCV with Tkinter

Dev Prakash Sharma
Updated on 07-Jun-2021 10:56:32

6K+ Views

Open CV is a Python library that is used to work with Computer Vision and other artificial artifacts. Open CV has inbuilt functions and methods which provide access to work with Computer Vision in Artificial Intelligence and Machine Learning. Some of the examples of Open CV are: face detection, object detection, X-ray and other industrial uses.Using Tkinter Library, we can create an interactive application that uses OpenCV as the essential part of the application.To create the application, you are required to install OpenCV in your local machine and make sure that Python Pillow package is pre-installed. You can install these ... Read More

What is a better Tkinter geometry manager than .grid()?

Dev Prakash Sharma
Updated on 07-Jun-2021 10:53:58

278 Views

The Geometry Manager is one of the specific features in the Tkinter Library. It provides structure to all the Tkinter widgets in the window. The Geometry Manager is used for formatting the layout and position of the widget in a Tkinter application window.To format the look and appearance of any widget, we have three general methods in Geometry Manager.Pack Geometry ManagerGrid Geometry ManagerPlace Geometry ManagerEach Geometry Manager has some features that provide a different style and layout to the widgets. The Pack Geometry Manager is the most commonly used layout manager which gives access to add padding, margin, fill and ... Read More

Inheriting from Frame or not in a Tkinter application

Dev Prakash Sharma
Updated on 07-Jun-2021 10:51:16

888 Views

In the Object-Oriented Programming Paradigm, Inheritance is used for acquiring the properties of the base class and using them in a derived class. Considering the case for a Tkinter application, we can inherit all the properties of a frame defined in a base class such as background color, foreground color, font properties, etc., into a derived class or a frame.In order to support Inheritance, we have to define a class that contains some basic properties of a frame such as height, width, bg, fg, font, etc.Example# Import Tkinter Library from tkinter import * # Create an instance of Tkinter ... Read More

Creating scrollable Listbox within a grid using Tkinter

Dev Prakash Sharma
Updated on 26-May-2021 12:13:53

3K+ Views

A Listbox widget displays a list of items such as numbers list, items list, list of employees in a company, etc. There might be a case when a long list of items in a Listbox needs a way to be viewed inside the window. For this purpose, we can attach scrollbars to the Listbox widget by initializing the Scrollbar() object. If we configure and attach the Listbox with the scrollbar, it will make the Listbox scrollable.ExampleIn this example, we will create a Listbox with a list of numbers ranging from 1 to 100. The Listbox widget has an associated Scrollbar ... Read More

Vertical and Horizontal Scrollbars on Tkinter Widget

Dev Prakash Sharma
Updated on 26-May-2021 12:13:02

3K+ Views

Scrollbars are useful to provide dynamic behavior in an application. In a Tkinter application, we can create Vertical as well as Horizontal Scrollbars. Scrollbars are created by initializing the object of Scrollbar() widget.To create a horizontal scrollbar, we have to provide the orientation, i.e., "horizontal" or "vertical". Scrollbars can be accessible once we configure the particular widget with the scrollbars.Example#Import the required libraries from tkinter import * #Create an instance of Tkinter Frame win = Tk() #Set the geometry of Tkinter Frame win.geometry("700x350") #Create some dummy Text text_v = "Python is dynamically-typed and garbage-collected. It supports multiple ... Read More

Call a Function with a Button or a Key in Tkinter

Dev Prakash Sharma
Updated on 26-May-2021 12:10:47

9K+ Views

Let assume that we want to call a function whenever a button or a key is pressed for a particular application. We can bind the function that contains the operation with a button or key using the bind(', ' callback_function) method. Here, you can bind any key to the event or function that needs to be called.ExampleIn this example, we have created a function that will open a dialog box whenever we click a button.#Import the required libraries from tkinter import * from tkinter import ttk from tkinter import messagebox #Create an instance of Tkinter Frame win = Tk() ... Read More

How to clear Text widget content while clicking on the Entry widget itself in Tkinter?

Dev Prakash Sharma
Updated on 26-May-2021 12:09:09

4K+ Views

Tkinter Text widget is an Input widget that supports multiline user input. It is also known as Text Editor which allows users to write the content and data in it. The content of the text widget can be cleared by defining the delete(0, END) command. Similarly, we can clear the content by clicking the Entry widget itself. This can be achieved by binding the function with a click event.Example#Import the required libraries from tkinter import * #Create an instance of Tkinter Frame win = Tk() #Set the geometry of Tkinter Frame win.geometry("700x250") #Define a function to clear ... Read More

How to change the Entry Widget Value with a Scale in Tkinter?

Dev Prakash Sharma
Updated on 26-May-2021 12:07:50

1K+ Views

Tkinter Entry widget is an input widget that supports only single-line user input. It accepts all the characters in the text field unless or until there are no restrictions set for the input. We can change the value of the Entry widget with the help of the Scale widget. The Scale widget contains a lower value and a threshold that limits the user to adjust the value in a particular range.To update the value in the Entry widget while updating the value of Scale widget, we have to create a variable that has to be given to both the scale ... Read More

How to use pip or easy_install Tkinter on Windows?

Dev Prakash Sharma
Updated on 26-May-2021 12:07:27

878 Views

Tkinter is a Python library that is used to develop desktop-based GUI applications. In order to develop a Tkinter application, we have to make sure that Python is installed in our local system. We can install Tkinter in our local machine by using the pip install tkinter command in the Command Prompt or shell.Once we enter the command pip install tkinter in the command shell, it will just start running the process of installing Tkinter in the local system.First, we will make sure that Python is installed in our system. In order to check if Python is installed, use the following ... Read More

Advertisements