Python Forum
[Tkinter] Help setting text/title in dock/panel in tkinter gui - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: GUI (https://python-forum.io/forum-10.html)
+--- Thread: [Tkinter] Help setting text/title in dock/panel in tkinter gui (/thread-24880.html)



Help setting text/title in dock/panel in tkinter gui - FluxApex - Mar-08-2020

Hello all, I have tried doing a bit of searching elsewhere and within this forum with various kselfey phrases/words for my issue and I am either not asking the right questions or I don't know so I have come here if you don't mind. I have only been learning tkinter just recently, but I know Python and PyQyt fairly well so I thought it was time to learn tkinter as well; always good to have choices.

In Ubuntu Linux in Gnome desktop I have simple test gui with a Frame and Button and I can set the window title just fine with a couple of ways with:
self.winfo_toplevel().title('...')
and
root.title('...')
for example, but I can't figure out how to change the Gnome panel and docks text/title. I thought maybe I might have to set the Frame title it says it has no such attribute.

Any help/direction/comments is/are welcome.

Screenshot & code below:

[Image: tkinter-test-problem.png]

Here's my code:
#!/usr/bin/env python3
from sys import exit
from tkinter import (Button, Frame, Tk, PhotoImage)


class Application(Frame):
    def __init__(self, master=None):
        Frame.__init__(self, master)
        # self.winfo_toplevel().title('Tkinter Test')
        self.pack(side="top")
        # selftest = Button(self, text="Text", command=lambda: prntw('Test'))
        selftest = Button(self, text="Text", command=lambda: self.winfo_toplevel().wm_state('iconic'))
        self.button_img = b'iVBORw0KGgoAAAANSUhEUgAAADAAAAAQCAYAAABQrvyxAAAABmJLR0QAMwCZAP/A\
            AhXbAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAB3RJTUUH5AMHFyY1F3JDrwAAAB1p\
            VFh0Q29tbWVudAAAAAAAQ3JlYXRlZCB3aXRoIEdJTVBkLmUHAAABbElEQVRIx92W\
            vUuCURTGf97X7BqR72YYFUFDU0tfTuHQUKNjuNRW1J/Qn9HnlARtgVPUECTS0Ac2\
            OAkNkuIgLVczuolIy6tIUcm7XO3ZLvcZnuecw3mOhy+wbXsBWAMiwATQj3lkgSQQ\
            V0rdtX94vog/ADbobhwqpTa/GbBt+wJYNq0usLjN4HQUX3AK4RsAQBceqWYSlFO7\
            TdqlUmqlZaAbKu+1RwnGjpFjMz9ydD5N6XSduiq0OuFxZv7WdOVHtq5+Fd9uori3\
            1HyGLSnlDjBremyG5mKddSoQolF74+P5HqAunG1jFIPTUbf8iHBWpVH4glNu+ROC\
            HocAcqZF1EpZt/yccBLOKKqZhFt+UgBx0wbKqV10Pt0RV+fT7YEWt7TWRSnlsOlV\
            +v50jRyfxxsI/RlkDV1pBtmRBaC1PpdShoFJUwYausLrwwmN2hvCbyP8ATxWX+uU\
            UDf7vJxtN8VfKqVW/9cx16vn9CeHv4yHy0IdXgAAAABJRU5ErkJggg=='
        self.button_img = PhotoImage(data=self.button_img)
        selftest.config(image=self.button_img,
                        relief='flat', overrelief='flat')
        selftest.pack(side="top")


def prntw(args):
    print(args)


def main():
    root = Tk()
    root.title('Tkinter Test')
    app = Application(master=root)
    app.mainloop() 

if __name__ == '__main__':
    main()
    exit()



RE: Help setting text/title in dock/panel in tkinter gui - joe_momma - Mar-18-2020

I think your asking about a window icon. To be honest it's usually the last thing on my mind when creating a gui. On linux you would use a bitmap x10 16 bits:
def main():
    root = Tk()
    root.title('Tkinter Test')
    #root.iconbitmap('/path/to/your.bmp')
    app = Application(master=root)
    app.mainloop() 
on a window platform it's .ico
do a search for tkinter and window icon I believe the tk you see is the default icon.


RE: Help setting text/title in dock/panel in tkinter gui - FluxApex - Mar-18-2020

Ok, so since there's no associated image file it shows the "TK" text in place of where the icon would be? It is a bit easier in PyQt it seems, but I'm sure they both have their pros and cons. I'll try adding an icon & see if what happens. Thanks for the feedback; I'll test it out & get back with my results and close this post out...