Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the difference between the title() method and wm_title() method in the Tkinter class?

I am using Python 2.7 and I wanted to know if there was a difference between the title() method and the wm_title() method for the Tkinter class. The following code:

import Tkinter as tk

root = tk.Tk()
root.title("My App")
root.mainloop()

and

import Tkinter as tk

root = tk.Tk()
root.wm_title("My App")
root.mainloop()

accomplishes the same thing. Is there something hidden that is going on?

like image 847
Sebastian Freeman Avatar asked Mar 12 '16 20:03

Sebastian Freeman


People also ask

What is the use of title () in tkinter?

The title in tkinter refers to a name assigned to the application window. It is mostly found on the top of the application. For this, we can use the title() function. We create a widget object using the Tk() function and use the title() function to add a title to this window.

What is the difference between from tkinter import * and import tkinter?

It comes with all the modules defined in tkinter. However, to save the major typing efforts, we import the tkinter library with some acronym further that can be used to create an instance of widgets. Thus, the application structures become more aesthetical by using the import tkinter as tk.

What is use of the Mainloop () in tkinter?

mainloop() tells Python to run the Tkinter event loop. This method listens for events, such as button clicks or keypresses, and blocks any code that comes after it from running until you close the window where you called the method.

What is Tk () in tkinter programming?

In order to create a tkinter application, we generally create an instance of tkinter frame, i.e., Tk(). It helps to display the root window and manages all the other components of the tkinter application. We can initialize the tkinter instance by assigning the variable to it.


1 Answers

Same thing really. wm methods are used to communicate with the window manager. Hence wm for window manager.

Wm class is used as a mixin by the root tk.Tk() window. You can access setting the title as you have by title or wm_title and other window manager attributes.

You can see the documentation here

like image 102
Pythonista Avatar answered Oct 23 '22 20:10

Pythonista