0
from tkinter import *
import win32api
from tkinter import filedialog
from mood import Dominant
from form import Assessment
import json
ca=Assessment()
window=Toplevel()
window.withdraw()
window.title("Analysis")

When I try to change title on the window still the title appears as "tk". I saw some answers but they were related OOP in the main window I could not change the title.

  • You remove the window then change its title. How do you know it hasn't changed? – Tim Roberts Oct 06 '21 at 06:19
  • At first, I had two windows then removed the second one by menas of withdraw() function then put the .title() after as you see but still window title is "tk" of course after I run the code :) – ugur çapan Oct 06 '21 at 06:22
  • https://stackoverflow.com/questions/2395431/using-tkinter-in-python-to-edit-the-title-bar See if that helps. – Kshitij Joshi Oct 06 '21 at 06:29
  • I run additional two windows on the main window which open with buttons in tkinter. I do not know whether it effect or not the main window's title. – ugur çapan Oct 06 '21 at 06:29
  • You are hiding the window, so how do you know the title has not changed – Delrius Euphoria Oct 06 '21 at 06:36
  • Still it has not changed yet. Is it related with Toplevel? but I have tried the option already that is window.winfo_toplevel().title("Analysis") – ugur çapan Oct 06 '21 at 06:37
  • You are right @Cool Cloud but The window appears blank but the tk titled runs properly. So I do know why tk titled works and my desired window does not ? – ugur çapan Oct 06 '21 at 06:39

1 Answers1

1

You changed the title of the hidden Toplevel() (since you have executed window.withdraw()), not the visible root window (created implicitly).

Use window.master.title("Analysis") to change the title of the visible root window.

Or create the root window explicitly and change its title as below:

import tkinter as tk
root = tk.Tk()
window=tk.Toplevel()
window.withdraw()
root.title("Analysis")
root.mainloop()
acw1668
  • 40,144
  • 5
  • 22
  • 34
  • "You changed the title of the hidden Toplevel() (since you have executed window.withdraw()), not the visible root window (created implicitly)." That was the part I did have no clue why it was happening. Thank you :) – ugur çapan Oct 06 '21 at 06:51