Dev Prakash Sharma

Dev Prakash Sharma

414 Articles Published

Articles by Dev Prakash Sharma

Page 30 of 42

How to delete Tkinter widgets from a window?

Dev Prakash Sharma
Dev Prakash Sharma
Updated on 26-Mar-2021 8K+ Views

Sometimes, we want to remove a widget that is of no use in the application. We can delete widgets from the window or frame using the .destroy method in tkinter. It can be invoked in the widget by defining a function for it.ExampleIn this example, we have created a button that will remove the text label widget from the window.#Import the tkinter library from tkinter import * #Create an instance of tkinter frame win = Tk() #Set the geometry win.geometry("650x450") #Define a function to remove the text from the screen def delete_text():    text.destroy() #Create a ...

Read More

How to display full-screen mode on Tkinter?

Dev Prakash Sharma
Dev Prakash Sharma
Updated on 26-Mar-2021 15K+ Views

Tkinter displays the application window by its default size. However, we can display a full-screen window by using attributes('fullscreen', True) method. The method is generally used for assigning a tkinter window with properties like transparentcolor,  alpha, disabled, fullscreen, toolwindow, and topmost.Example#Import the tkinter library from tkinter import * #Create an instance of tkinter frame win = Tk() #Set the geometry win.geometry("650x250") #Add a text label and add the font property to it label= Label(win, text= "Hello World!", font=('Times New Roman bold', 20)) label.pack(padx=10, pady=10) #Create a fullscreen window win.attributes('-fullscreen', True) win.mainloop()OutputRunning the above code will ...

Read More

How to make a Tkinter widget invisible?

Dev Prakash Sharma
Dev Prakash Sharma
Updated on 26-Mar-2021 5K+ Views

To make a tkinter widget invisible, we can use the pack_forget() method. It is generally used to unmap the widgets from the window.ExampleIn the following example, we will create a label text and a button that can be used to trigger the invisible event on the label text widget.#Import the required libraries from tkinter import * #Create an instance of tkinter frame win= Tk() #Set the geometry of frame win.geometry("600x250") #Set the resizable property False win.resizable(False, False) #Make the widgets Invisible def make_invisible(widget):    widget.pack_forget() #Create a label for the window or frame label=Label(win, text="Hello ...

Read More

How to make a Tkinter window jump to the front?

Dev Prakash Sharma
Dev Prakash Sharma
Updated on 26-Mar-2021 3K+ Views

In order to make the tkinter window or the root window jump above all the other windows, we can use attributes method that will generally take two values specifying the “topmost” value and the other is a Boolean value.Example#Importing the library from tkinter import * #Create an instance of tkinter window or frame win= Tk() #Setting the geometry of window win.geometry("600x250") #Create a Label Label(win, text= "Hello Everyone!", font=('Helvetica bold', 15)).pack(pady=20) #Make the window jump above all win.attributes('-topmost', 1) win.mainloop()OutputRunning the above code will make the window stay above all other windows,

Read More

How to put a Tkinter window on top of the others?

Dev Prakash Sharma
Dev Prakash Sharma
Updated on 26-Mar-2021 13K+ Views

Whenever we create a GUI program, tkinter generally presents the output screen in the background. In other words, tkinter displays the program window behind other programs. In order to put the tkinter window on top of others, we are required to use attributes('- topmost', True) property. It pulls up the window on the upside.Example#Importing the library from tkinter import * #Create an instance of tkinter window or frame win= Tk() #Setting the geometry of window win.geometry("600x350") #Create a Label Label(win, text= "Hello World! ", font=('Helvetica bold', 15)).pack(pady=20) #Make the window jump above all win.attributes('-topmost', True) ...

Read More

How to set default text for a Tkinter Entry widget?

Dev Prakash Sharma
Dev Prakash Sharma
Updated on 26-Mar-2021 7K+ Views

Tkinter Entry widget is used to print and display a single line of text taken from the user Input. It is used for many applications such as creating login forms, signup forms, and other user interaction forms.We can set the default text for the Entry Widget using insert() function by passing the default text as the argument.ExampleIn this example, we have created an Entry widget that has a default text.#Import the tkinter library from tkinter import * #Create an instance of tkinter frame win = Tk() #Set the geometry win.geometry("650x250") #Create an Entry Widget entry= Entry(win) entry.insert(END, 'Enter ...

Read More

How to set the border color of certain Tkinter widgets?

Dev Prakash Sharma
Dev Prakash Sharma
Updated on 26-Mar-2021 4K+ Views

Let us suppose we want to change the border color of a tkinter widget. We can configure the widget by passing the highlightcolor, highlightbackground property of the widget.ExampleIn this example, we have created an Entry widget and a button that can be triggered to change the border color of the Entry Widget.#Import the required libraries from tkinter import * #Create an instance of tkinter frame win= Tk() #Set the geometry of frame win.geometry("600x250") #Define a function to change the color of entry widget def change_color():    text.config(highlightthickness=2, highlightbackground="red") #Create a Entry widget for which we want ...

Read More

What is the difference between root.destroy() and root.quit() in Tkinter(Python)?

Dev Prakash Sharma
Dev Prakash Sharma
Updated on 26-Mar-2021 6K+ Views

When we invoke the destroy() method with the tkinter window object, it terminates the mainloop process and destroys all the widgets inside the window. Tkinter destroy() method is mainly used to kill and terminate the interpreter running in the background.However, quit() method can be invoked in order to stop the process after the mainloop() function. We can demonstrate the functionalities of both methods by creating a button Object.Example#Import the required libraries from tkinter import * #Create an instance of tkinter frame win= Tk() #Set the geometry of frame win.geometry("650x450") #Define a function for Button Object def quit_win(): ...

Read More

What is the difference between the widgets of tkinter and tkinter.ttk in Python?

Dev Prakash Sharma
Dev Prakash Sharma
Updated on 26-Mar-2021 7K+ Views

tkinter.ttk is a module that is used to style the tkinter widgets. Just like CSS is used to style an HTML element, we use tkinter.ttk to style tkinter widgets.Here are the major differences between tkinter widget and tkinter.ttk −Tkinter widgets are used to add Buttons, Labels, Text, ScrollBar, etc., however, tkinter.ttk supports a variety of widgets as compared to tkinter widgets.Tkinter.ttk doesn't support Place, Pack() and Grid(), thus it is recommended to use tkinter widget with ttk.Ttk has many features and configurations that extend the functionality of a native application and make it look more modern.Tkinter widget is a native ...

Read More

Word Dictionary using Python Tkinter

Dev Prakash Sharma
Dev Prakash Sharma
Updated on 06-Mar-2021 3K+ Views

In this article, we will create a GUI-based dictionary using PyDictionary and Tkinter Module.PyDictionary is a Python Module that helps to get meaning translations, antonyms and synonyms of words. It uses WordNet for getting meanings, Google for translations, and synonym.com for getting synonyms and antonyms. PyDictionary uses BeautifulSoup, Requests module as the dependencies.In order to create the application, we will first install these modules in our environment using pip install PyDictionaryAfter installing, we will create a tkinter frame and some other element.Example# Import Required Librares from tkinter import * from PyDictionary import PyDictionary # Create instances and objests dictionary ...

Read More
Showing 291–300 of 414 articles
« Prev 1 28 29 30 31 32 42 Next »
Advertisements