Dev Prakash Sharma has Published 548 Articles

Opening and reading a file with askopenfilename in Tkinter?

Dev Prakash Sharma

Dev Prakash Sharma

Updated on 22-Apr-2021 07:38:53

3K+ Views

When a user wants to open a file from a directory, the preferred way to do this is to display a popup where the user selects a file to Open. Like most tools and widgets, Tkinter provides us a way to open a dialog for opening a file, reading a ... Read More

Mouse Position in Python Tkinter

Dev Prakash Sharma

Dev Prakash Sharma

Updated on 22-Apr-2021 07:38:31

9K+ Views

Events are very useful to perform and manage multiple tasks in a large-scale application. We can bind a particular event with the keyboard buttons or mouse buttons using the bind(‘handler’, ‘callback’) method. Generally, the mouse pointer and its motion are tracked for the purpose of building a screensaver, 2D or ... Read More

How to set the font size of a Tkinter Canvas text item?

Dev Prakash Sharma

Dev Prakash Sharma

Updated on 22-Apr-2021 07:35:24

5K+ Views

Canvas is one of the flexible widgets in tkinter which controls the widgets with its power of functions, methods, and attributes. However, tkinter canvas can be used to create text using the create_text(options) constructor. We can define the text along with other properties in the constructor. After defining the text, ... Read More

How to set the sticky button property properly?

Dev Prakash Sharma

Dev Prakash Sharma

Updated on 22-Apr-2021 07:31:46

2K+ Views

Tkinter Buttons can be configured through the different available attributes and properties in Tkinter. We can add a sticky property to make it sticky relative to the window in which it is residing. The sticky property allows the widget to set the relative position in the window. To make a ... Read More

How to set font for Text in Tkinter?

Dev Prakash Sharma

Dev Prakash Sharma

Updated on 22-Apr-2021 07:31:28

9K+ Views

Tkinter has many inbuilt methods and functions which are used to provide different features in the widgets. We can customize the font-property of text widget in a tkinter application using the font(‘font-family’, font-size, ‘style’) attribute. The tuple can be declared inside the Text constructor.ExampleLet us have a look at the ... Read More

How to select at the same time from two Tkinter Listbox?

Dev Prakash Sharma

Dev Prakash Sharma

Updated on 22-Apr-2021 07:31:07

2K+ Views

Let us consider a situation for a particular system to keep selecting multiple files from a directory and, once copied in the clipboard, paste them into another directory. The idea of making multiple selections in ListBoxes can be implemented by using the exportselection property. The property prevents the selected options ... Read More

How to reset the background color of a Python Tkinter button?

Dev Prakash Sharma

Dev Prakash Sharma

Updated on 22-Apr-2021 07:27:58

2K+ Views

Tkinter buttons are useful for handling events within the application. We can configure the button properties such as text style, font-family, background color, text color, and text size using predefined properties.We can reset the background color and other properties by defining a callback function.Example#Import the tkinter library from tkinter import ... Read More

How to remove the outline of an oval in Tkinter?

Dev Prakash Sharma

Dev Prakash Sharma

Updated on 22-Apr-2021 07:25:48

969 Views

With Tkinter canvas, we can draw shapes for 2D or 3D applications, we can create images, draw animation, and many more things. Let us suppose that we have to create an oval that should be drawn aesthetically on the canvas. There can be other features that can be present to ... Read More

How to pass an argument to the event handler in Tkinter?

Dev Prakash Sharma

Dev Prakash Sharma

Updated on 22-Apr-2021 07:25:27

2K+ Views

In most situations, the callback functions can refer to as an Instance Method. An instance method accesses all its members and performs operations with them without specifying any arguments.Let's consider a case where more than one component is defined and we want to handle some events with those components. To ... Read More

How to open a new window by the user pressing a button in a tkinter GUI?

Dev Prakash Sharma

Dev Prakash Sharma

Updated on 22-Apr-2021 07:23:31

15K+ Views

Tkinter creates a default window (i.e., master or root window) for every application. In tkinter, we can create a Popup window or a child window by defining a Toplevel(master) constructor. This will allow the tkinter application to create another window which can be resized dynamically by defining its size property.ExampleIn ... Read More

Advertisements