No, there is no standard way. Tkinter has no way of knowing how long the title is on the titlebar. The OS / window manager has completely control of that portion of the window and doesn't expose any platform-independent way of getting at that information.
You would have to know not only the font used by the OS for window titles, but also whether there were any other decorations (eg: buttons, images, etc) that appear in the title area.
If you're fine with making assumptions that the font is the same as the default tkinter font, you can use tkinter's ability to measure the length of a string in a given font with the measure method of a font object.
I had to change the code for my computer, but this should work. Please tell me if you find something wrong or if it works. And, at the top that 'try' and 'except ImportError' is to find which version of Python you have. If you want to change the original text of the navbar, change the variable 'titletext'. The only downside is that it is not a 'standard' way to do it.
Asked in February 2016Viewed 1,163 timesVoted 9Answered 2 times