Reputation: 335
I am writing a python app using Tkinter and I cannot find a way to change the default title Tk
in OS top bar (Gnome top bar and dock too).
I can set the main window title but it does not change the string in the top bar where it stays Tk
. Honestly I am surprised I cannot find anyone asking this same question.
I am developing on Ubuntu 18.04 using Python 3.6
This is a sample code to replicate the problem:
import tkinter as tk
if __name__ == "__main__":
mainWindow = tk.Tk()
mainWindow.title("TEST")
mainWindow.geometry("1024x600")
mainWindow.mainloop()
I would expect to read the string TEST
in the main window frame title, in the OS top bar and in the OS application dock, but I get it only in the windows frame title. The rest display Tk
Upvotes: 8
Views: 1110
Reputation: 940
Use className
mainWindow = tk.Tk(className='Ghanshyam')
According to python Docs on tkinter:
The Tk class is instantiated without arguments. This creates a toplevel widget of Tk which usually is the main window of an application. Each instance has its own associated Tcl interpreter.
Upvotes: 4
Reputation: 27
The top bar title in Ubuntu is not set by the application running, it is set by the desktop entry for the app. I'm not sure why it works the way it does when there is no desktop entry present, but you can create a file like this and import it into Ubuntu for it to work properly.
[Desktop Entry]
Type=Application
Terminal=false
Icon=/path/to/icon/icon.png
Name=TITLE (this is what handles the top bar title)
Exec=/path/to/file/executable
Categories=Utility;
See this question on AskUbuntu.
Upvotes: 0