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
Photo Tkinter TEXT background image _ShevaKadu 5 1,167 Nov-02-2020, 10:34 AM
Last Post: joe_momma
  tkinter | Button color text on Click Maryan 2 354 Oct-09-2020, 08:56 PM
Last Post: Maryan
  [Tkinter] Text Upload LearningLittlebyLittle 0 310 Sep-04-2020, 07:55 PM
Last Post: LearningLittlebyLittle
  [Tkinter] Indentation for Tkinter-made Text Editor ShakeyPakey 4 882 Jun-08-2020, 03:13 PM
Last Post: menator01
  How to make button text bold in Tkinter? scratchmyhead 2 987 May-16-2020, 02:53 AM
Last Post: scratchmyhead
  [Tkinter] changing title text to bold in tkinter Kumarkv 2 1,568 May-09-2020, 10:41 PM
Last Post: Larz60+
  Tkinter - Need Help setting Height of a TextInputBox itslewis 1 407 Mar-22-2020, 02:37 AM
Last Post: deanhystad
  [Tkinter] Tkinter Winget python text Marc 5 649 Mar-13-2020, 11:17 PM
Last Post: Marc
  tkinter how to unselect text in textbox Battant 0 552 Feb-17-2020, 02:00 PM
Last Post: Battant
  Make Label Text background (default color) transparent using tkinter in python barry76 1 9,879 Nov-28-2019, 10:19 AM
Last Post: Larz60+

Forum Jump:

User Panel Messages

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