Dev Prakash Sharma

Dev Prakash Sharma

414 Articles Published

Articles by Dev Prakash Sharma

Page 9 of 42

How to package a Tkinter program to share with people?

Dev Prakash Sharma
Dev Prakash Sharma
Updated on 18-Jun-2021 4K+ Views

Tkinter is a cross-platform tk GUI toolkit based on Python library which is used to create and develop GUI-based applications. Tkinter application can be bundled in an executable or runnable file which enables the application to run without using Python interpreter or IDLE. The need for bundling an application becomes a priority when the user wants to share the application with other people without sharing the piece of code.Python has a variety of modules and extensions that gives access to the user to convert a running application into an executable, portable file. Each file runs on a different platform; thus, ...

Read More

Forcing Tkinter window to stay on top of fullscreen in Windows 10?

Dev Prakash Sharma
Dev Prakash Sharma
Updated on 18-Jun-2021 5K+ Views

To render widgets in a Tkinter application, we generally use mainloop() function which helps to display the widgets in a window. In many cases, tkinter window displays over the other windows or programs. While switching to other programs or windows, it seems difficult to find and switch back to the Tkinter window again.We can force our tkinter window to stay on Top of other window or programs by creating a function and defining win.lift() method in a loop. In the loop, it will execute win.after(2000, function()) function to ensure that the tkinter window will always stays on top of other windows.Example# Import ...

Read More

How to force Tkinter text widget to stay on one line?

Dev Prakash Sharma
Dev Prakash Sharma
Updated on 18-Jun-2021 2K+ Views

Tkinter text widget can be configured by using the configure(**options) function. We can use it to configure the background color, foreground color, wrapping and other properties of the text widget.The wrap properties of the Text widget describe that the cursor changes its position whenever it detects a new line. However, in Tkinter, the text widget can be wrapped by words and characters. In order to make our text widget to stay in one line, we can use wrap=None property.Example# Import the required libraries from tkinter import * import lorem # Create an instance of tkinter frame or window win=Tk() ...

Read More

How to fully change the color of a Tkinter Listbox?

Dev Prakash Sharma
Dev Prakash Sharma
Updated on 18-Jun-2021 4K+ Views

Tkinter Listbox widgets are very useful in the case of representing a large set of data items in form of list items. To configure the properties such as change the background color of the entire Listbox, we can use configure(**options) method to change the properties of the Listbox widget.Example# Import the required libraries from tkinter import * # Create an instance of tkinter frame or window win=Tk() # Set the size of the window win.geometry("700x350") # Add a Listbox widget with number as the list items listbox =Listbox(win) listbox.insert(END, "C++", "Java", "Python", "Rust", "GoLang", "Ruby", "JavScript", "C# ", ...

Read More

How to update information in the grid in Tkinter?

Dev Prakash Sharma
Dev Prakash Sharma
Updated on 18-Jun-2021 741 Views

Let us suppose that a Tkinter application has widgets placed in the window using the Grid Geometry Manager. In order to change the properties of the Tkinter widgets, we can use configure(**options) method. While rendering the widgets in the window, we have to assign the constructor to a variable that gives access to change the widget’s property globally.Example# Import the required libraries from tkinter import * # Create an instance of tkinter frame or window win=Tk() # Set the size of the window win.geometry("700x350") # Add a Label widget and assign it to a new variable label=Label(win, ...

Read More

Moving balls in Tkinter Canvas

Dev Prakash Sharma
Dev Prakash Sharma
Updated on 18-Jun-2021 2K+ Views

Tkinter is a standard Python library which is used to create GUI-based applications. To create a simple moving ball application, we can use the Canvas widget which allows the user to add images, draw shapes, and animating objects. The application has the following components, A Canvas widget to draw the oval or ball in the window.To move the ball, we have to define a function move_ball(). In the function, you have to define the position of the ball that will constantly get updated when the ball hits the canvas wall (left, right, top, and bottom).To update the ball position, we ...

Read More

How to capture events on Tkinter child widgets?

Dev Prakash Sharma
Dev Prakash Sharma
Updated on 18-Jun-2021 733 Views

Suppose we are creating an application that interacts with the user clicks on the Button visible in the application. To understand how exactly events work, we have to create a callback function as well as a trigger that will execute an event. Whenever the user clicks the button, the event happens and it needs to be captured on the screen.ExampleIn this example, we will create a Listbox widget that will have a list of items in it. When we select an item, then it will capture what the user has clicked. To figure out the captured event, we can use ...

Read More

How to create a Tkinter toggle button?

Dev Prakash Sharma
Dev Prakash Sharma
Updated on 18-Jun-2021 5K+ Views

Python has a rich set of libraries and modules that can be used to build various components of an application. Tkinter is another well-known Python library for creating and developing GUI-based applications. Tkinter offers many widgets, functions, and modules that are used to bring life to the application visuals. We can create button widgets to perform certain tasks in an application.In this application, we will create a toggle button that will turn the On/ Off Night and Day mode of the application. To create a toggle button, we have to first render the image in a Label.We define buttons and ...

Read More

What is the difference between focus and focus_set methods in Tkinter?

Dev Prakash Sharma
Dev Prakash Sharma
Updated on 18-Jun-2021 2K+ Views

Focus is used to refer to the widget or window which is currently accepting input. Widgets can be used to restrict the use of mouse movement, grab focus, and keystrokes out of the bounds. However, if we want to focus a widget so that it gets activated for input, then we can use focus.set() method. focus() is sometimes referred to as focus_set().focus_set() focuses on the widget when its window or widget gets focus.Example# Import the required libraries from tkinter import * from tkinter import ttk # Create an instance of tkinter frame or window win=Tk() # Set the size of ...

Read More

How can I change the text of the Tkinter Listbox item?

Dev Prakash Sharma
Dev Prakash Sharma
Updated on 18-Jun-2021 1K+ Views

To display a list of items in the application, Tkinter provides a Listbox widget. It is used to create a list of items vertically. When we want to change the text a specific Listbox item, then we have to first select the item by iterating over the listbox.curselection() and insert a new item after deletion. To insert a item in the list, you can use listbox.insert(**items).Example# Import the required libraries from tkinter import * from tkinter import ttk # Create an instance of tkinter frame or window win=Tk() # Set the size of the window win.geometry("700x350") # Create ...

Read More
Showing 81–90 of 414 articles
« Prev 1 7 8 9 10 11 42 Next »
Advertisements