Found 525 Articles for Tkinter

How to take input in a text widget and display the text in tkinter?

Dev Prakash Sharma
Updated on 16-Dec-2021 11:01:59
We can use the Tkinter text widget to insert text, display information, and get the output from the text widget. To get the user input in a text widget, we've to use the get() method. Let's take an example to see how it works.Example# Import the required library from tkinter import * from tkinter import ttk # Create an instance of tkinter frame win=Tk() # Set the geometry win.geometry("700x350") def get_input():    label.config(text=""+text.get(1.0, "end-1c")) # Add a text widget text=Text(win, width=80, height=15) text.insert(END, "") text.pack() # Create a button to get the text input b=ttk.Button(win, ... 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
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
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
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
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
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
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
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

How to set a certain number of rows and columns of a Tkinter grid?

Dev Prakash Sharma
Updated on 16-Dec-2021 10:41:34
In Tkinter, you can set the GUI of the application by using a different geometry manager. The grid geometry manager is one of the most useful geometry managers in tkinter that is used to set the widgets location in the application using the 2D geometry form.With a grid geometry manager, you can set a certain number of rows and columns and place the widget in any location of the application. To set a certain number of rows and columns, you’ll need to specify the size value of the row and column configuration that helps to set the location of a ... Read More

How to insert a temporary text in a tkinter Entry widget?

Kiran Kumar Panigrahi
Updated on 26-Oct-2021 14:43:03
To insert a temporary text in a tkinter Entry widget, we will bind the event with the Entry widget and call a user-defined function to delete the text inside the Entry widget.Steps −Import the tkinter library and create an instance of tkinter frame.Set the size of the frame using geometry method.Create a user-defined method "temp_text()" to capture the event and delete the temporary text inside the Entry widget.Create an Entry widget inside the Root window and set its properties such as background color, width, and border width.Use the insert() method of the Entry widget to insert a string ... Read More
Previous 1 ... 3 4 5 6 7 ... 53 Next