Reputation: 31
I am attempting to produce a small program to better understand how tkinter works within python.
As such I wanted to know how I can set an icon and update the title of a tkinter window.
I have written the below code, is anyone able to advise on how I would achieve the above within this script?
from Tkinter import *
import Tkinter as Tk
import ttk
class Test(Tk.Tk):
def __init__(self, *args, **kwargs):
Tk.Tk.__init__(self, *args, **kwargs)
app = Test()
app.state("zoomed")
app.mainloop()
# I'm having problems with this could I get any help?
app.wm_iconbitmap('xxxxxxx.ico')
app.title('Vikings Lore')
Upvotes: 0
Views: 6323
Reputation: 320
For Linux (worked for me) you need add also '@' at the begin of string:
app_icon = '/home/user/icons/number-three_66512.XBM'
root.iconbitmap('@' + app_icon)
If you get error _tkinter.TclError: error reading bitmap file
use XBM format instead of ICO.
Upvotes: 1
Reputation: 4740
You can set the title of a tkinter window using the below snippet:
from tkinter import *
root = Tk()
root.wm_title("Hello, world")
This will set the title of the root window to Hello, world
.
As for the icon, this can be set using the below snippet:
from tkinter import *
root = Tk()
root.iconbitmap("icon.ico")
This will set the icon of the root window to the file icon.ico
.
If you need further basic help with tkinter http://effbot.org/tkinterbook/ is your best friend.
Upvotes: 1