Found 310 Articles for GUI-Programming

Printing a list to a Tkinter Text widget

Gaurav Leekha
Updated on 13-Apr-2023 17:44:55

7K+ Views

When creating a graphical user interface (GUI) in Python with Tkinter, it's common to want to display data in a user-friendly format. One way to do this is to print a list of items to a Tkinter Text widget, which allows you to display the list with each item on a separate line. In this article, we'll cover how to print a list to a Tkinter Text widget and some tips for formatting the output. Creating a Tkinter Text Widget Before we can print a list to a Tkinter Text widget, we need to create the widget itself. Here's some ... Read More

How to attach a vertical scrollbar to a Treeview using Tkinter?

Dev Prakash Sharma
Updated on 16-Dec-2021 11:05:44

3K+ Views

If you want to display a list of items that contains some columns in it, then you can use the Treeview widget in Tkinter. The Treeview widget allows the user to add a large number of lists along with the properties that can be customized instantly.If you want to attach a vertical scrollbar to the list of items in a Treeview widget, then you can define a constructor of Scrollbar and configure it by adding the command to it. Let’s take an example and see how it works.Example# Import the required libraries from tkinter import * from tkinter import ttk ... Read More

How to disable multiselection on Treeview in tkinter?

Dev Prakash Sharma
Updated on 16-Dec-2021 11:04:14

1K+ Views

The Treeview widget is used to display a list of items with more than one feature in the form of columns. By default, the listed items in a Treeview widget can be selected multiple times, however you can disable this feature by using selectmode="browse" in the Treeview widget constructor. The Treeview widget can be implemented by using the Treeview(root, column, **options) constructor.ExampleThe following example demonstrates how to disable multiselection in a Treeview widget.# Import the required libraries from tkinter import * from tkinter import ttk # Create an instance of tkinter frame win=Tk() # Set the size of ... Read More

How to clear the text field part of ttk.Combobox in tkinter?

Dev Prakash Sharma
Updated on 16-Dec-2021 11:00:13

4K+ Views

The Combobox widget is one of the versatile widgets in tkinter that is used to create a dropdown list containing some values in it. You can select a value from the dropdown list that gets replaced by the default value of the combobox widget. You can create a combobox widget by initializing the constructor of Combobox(root, width, text) widget.Consider the case, if the user wants to clear the selected value from the combobox widget, the only way you can do so is to set the value of the combobox widget as NULL by using the set (' ') method. The ... Read More

Call the same function when clicking a Button and pressing Enter in Tkinter

Dev Prakash Sharma
Updated on 16-Dec-2021 10:58:25

631 Views

There are various built-in functions, widgets and methods available in the tkinter toolkit library which you can use to build robust and powerful desktop applications. The Button widget in tkinter helps users in creating buttons and performing different actions with the help of its functions. You can also bind the buttons to perform some specific events or callback by using the bind("button", callback) method.ExampleConsider the following example. to create a function that prints a message on the screen whenever the user presses the key. To bind the key with the function, you can use the bind("", callback) method.# ... Read More

How do I open a website in a Tkinter window?

Dev Prakash Sharma
Updated on 16-Dec-2021 10:56:45

4K+ Views

Tkinter offers many built-in functions and methods that contain several utility functions to help us construct a user-friendly application. In tkinter, if you want to open a webpage, you can use the built-in Python library, webview, which allows the users to view the HTML content in its own native GUI window. You can install the webview library by using the following command −pip install pywebviewTo create a window that will open the requested HTML content, you have to first create a window container by using the create_window(win_title, 'URL') method and specify the URL in the method. This will create a ... Read More

Python Tkinter – How to position a topLevel() widget relative to the root window?

Dev Prakash Sharma
Updated on 16-Dec-2021 10:55:30

5K+ Views

In Tkinter, the toplevel widget is used to create a popup modal window. The popup window created by the toplevel window works similar to the default window of the tkinter application. It can have widgets such as text widget, button widget, canvas widget, frame, etc.The size and position of the toplevel window can be decided by making it flexible throughout the screen. In the toplevel window, all the widgets are always placed on top of the other windows.You can use root.winfo_x() and root.winfo_y() to get the position of the root window. Then, you can use the geometry method to position ... Read More

Creating a LabelFrame inside a Tkinter Canvas

Dev Prakash Sharma
Updated on 16-Dec-2021 10:54:10

1K+ Views

Tkinter provides many built-in widgets which can be used to create highlevel desktop applications. The LabelFrame widget is one of them, which allows the users to add a labelled frame. The Label is another widget in the LabelFrame, which is used to add text or images in a frame or any container.There are two main components of the LabelFrame widget, The Title Bar (also known as the text of the LabelFrame widget).The content (the content of the LabelFrame widget. You can add an image, or text as the content inside the LabelFrame widget.)To define a LabelFrame widget, you’ll need to ... Read More

How to get a new API response in a Tkinter textbox?

Dev Prakash Sharma
Updated on 16-Dec-2021 10:52:25

914 Views

APIs are extremely useful in implementing a service or feature in an application. APIs help to establish the connection between the server and a client, so whenever a client sends a request using one of the API methods to the server, the server responds with a status code (201 as a successful response) to the client.You can make a request to any API you want using one of the methods (GET, POST, PUT or DELETE). However, if you want to create an application where you need a request to the server using one of the publicly available API (for example, ... Read More

Adding coloured text to selected text in Tkinter

Dev Prakash Sharma
Updated on 16-Dec-2021 10:42:46

1K+ Views

If we want to implement a text editor in an application that can accept multiline user input, then we can use the Tkinter Text widget. The Text widget in Tkinter is generally used to create a text editor for an application, where we can write text and perform operations like selecting, editing and creating a specific text in the application.If you want to highlight a text and provide a color to the highlighted text, then you can use the tag_add("start", "first", "second") method. The tag_add() method takes two arguments for selecting the specified text from the text widget. You can ... Read More

Previous 1 ... 3 4 5 6 7 ... 31 Next
Advertisements