Python Forum
[Tkinter] _tkinter.TclError: bitmap "Icon.gif" not defined
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[Tkinter] _tkinter.TclError: bitmap "Icon.gif" not defined
#1
I'm trying to change the icon of the tkinter window for the following code:
from tkinter import * # gives access to tkinter GUI library

def hello():
    name = textbox1.get() # gets name from textbox1
    print = "Hello " + name # creates Hello name string 
    textbox2["text"] = print # prints that string in textbox2

window = Tk() # opens tkinter window
window.title("Names") # sets title of the window as names
window.geometry("1000x1000") # dimentions
window.wm_iconbitmap("Icon.gif") # changes tkinter window icon 
window.configure(background  = "black") # sets window background to green

logo = PhotoImage(file = "logo.gif") # displays logo.gif in a label widget
logoimage = Label(image = logo) # this can't be changed while the program is running 
logoimage.place(x = 50, y = 20, width = 200, height = 120) # position and dimentions

textbox1 = Entry(text = "") # creates textbox1 where data is entered 
textbox1.place(x = 145, y = 200, width = 125, height = 25) # position and dimentions
textbox1["bg"] = "white" # white background 
textbox1["fg"] = "black" # black font

label1 = Label(text = "Enter a name") # creates label with this text
label1.place(x = 20, y = 200, width = 125, height = 25) # position and dimentions
label1["bg"] = "red" # red background 
label1["fg"] = "blue" # blue font

textbox2 = Message(text = print) # creates textbox1 displaying the variable print
textbox2.place(x = 145, y = 250, width = 125, height = 25) # position and dimentions
textbox2["bg"] = "white" # white background 
textbox2["fg"] = "black" # black font

button1 = Button(text = "Press me", command = hello) # creates button which runs the hello sub-program
button1.place(x = 20, y = 250, width = 125, height = 25) # position and dimentions
button1["bg"] = "blue" # blue background 
button1["fg"] = "red" # red font

window.mainloop() # keeps program running 
But I keep getting this error message:

Error:
File "c:/Users/djwil/Documents/python/learning python/Chapter 17 - more Tkinter/Ch17-c1.py", line 11, in <module> window.wm_iconbitmap("Icon.gif") # changes tkinter window icon File "C:\Users\djwil\AppData\Local\Programs\Python\Python38-32\lib\tkinter\__init__.py", line 2071, in wm_iconbitmap return self.tk.call('wm', 'iconbitmap', self._w, bitmap) _tkinter.TclError: bitmap "Icon.gif" not defined
I'm not sure why I'm getting this error as I've saved the icon.gif file in the same folder as the program itself. Can anyone help?
Reply


Messages In This Thread
_tkinter.TclError: bitmap "Icon.gif" not defined - by djwilson0495 - Aug-05-2020, 09:47 AM
RE: Help with Tkinter - by deanhystad - Aug-05-2020, 02:24 PM
RE: Help with Tkinter - by wuf - Aug-05-2020, 02:27 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  tkinter.TclError: can't invoke "canvas" command cybertooth 8 5,976 Feb-23-2023, 06:58 PM
Last Post: deanhystad
  [Tkinter] tkinter.TclError: expected integer but got " " TWB 2 3,694 Feb-19-2023, 05:11 PM
Last Post: TWB
Exclamation [PyQt] Setting icon on QAction from outside QGuiApplication gradlon93 3 1,722 Jan-04-2023, 11:37 AM
Last Post: gradlon93
  PyQt6 QAction with icon and string malonn 2 1,686 Sep-12-2022, 11:59 AM
Last Post: malonn
  how to remove icon ilyess68ysl 4 3,679 Oct-15-2021, 10:05 AM
Last Post: ilyess68ysl
  [Tkinter] _tkinter.TclError: can't invoke "destroy" command: application has been destroyed knoxvilles_joker 6 15,564 Apr-25-2021, 08:41 PM
Last Post: knoxvilles_joker
  "tkinter.TclError: NULL main window" Rama02 1 5,844 Feb-04-2021, 06:45 PM
Last Post: deanhystad
  [Tkinter] _tkinter.TclError: image "pyimage2" doesn't exist Killdoz 1 10,638 May-30-2020, 09:48 AM
Last Post: menator01
  Icon in tkinter menator01 8 4,948 May-03-2020, 02:01 PM
Last Post: wuf
  tkinter.TclError: bad window path name kenwatts275 3 14,787 Apr-26-2020, 08:16 PM
Last Post: kenwatts275

Forum Jump:

User Panel Messages

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