Python Forum
[Tkinter] Help setting text/title in dock/panel in tkinter gui
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[Tkinter] Help setting text/title in dock/panel in tkinter gui
#1
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()
Reply
#2
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.
Reply
#3
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...
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  [Tkinter] Updating tkinter text BliepMonster 5 5,671 Nov-28-2022, 01:42 AM
Last Post: deanhystad
  [Tkinter] The Text in the Label widget Tkinter cuts off the Long text in the view malmustafa 4 4,672 Jun-26-2022, 06:26 PM
Last Post: menator01
  [Tkinter] Tkinter Window Has no Title Bar gw1500se 4 2,796 Nov-07-2021, 05:14 PM
Last Post: gw1500se
  [Tkinter] Trouble changing Font within tkinter frame title AnotherSam 1 4,012 Sep-30-2021, 05:57 PM
Last Post: menator01
  tkinter change the text of the checkbox zazas321 1 3,759 Sep-17-2021, 06:19 AM
Last Post: zazas321
  tkinter text widget word wrap position chrisdb 6 7,460 Mar-18-2021, 03:55 PM
Last Post: chrisdb
  [Tkinter] tkinter.Menu – How to make text-variable? Sir 3 5,546 Mar-10-2021, 04:21 PM
Last Post: Sir
Photo Tkinter TEXT background image _ShevaKadu 5 7,655 Nov-02-2020, 10:34 AM
Last Post: joe_momma
  tkinter | Button color text on Click Maryan 2 3,316 Oct-09-2020, 08:56 PM
Last Post: Maryan
  [Tkinter] Text Upload LearningLittlebyLittle 0 2,014 Sep-04-2020, 07:55 PM
Last Post: LearningLittlebyLittle

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020