Home > database >  How to solve the following error in my python code, I'm trying to build a program using tiknter
How to solve the following error in my python code, I'm trying to build a program using tiknter

Time:06-01

#the error Traceback (most recent call last): File "c:\Users\User\Desktop\assignment testing\week8\2810 lab\gui\gui1 (1).py", line 18, in root.iconbitmap(r"c:/Users/User/Desktop/assignment testing/week8/2810 lab/gui") File "C:\Users\User\AppData\Local\Programs\Python\Python310\lib\tkinter_init_.py", line 2109, in wm_iconbitmap return self.tk.call('wm', 'iconbitmap', self._w, bitmap) _tkinter.TclError: bitmap "c:/Users/User/Desktop/assignment testing/week8/2810 lab/gui" not defined >

#The code
from tkinter import *
from tkinter import ttk
import tkinter as tk
from typing import Counter 
from tkcalendar import Calendar, DateEntry 
from PIL import ImageTk,Image
from tkinter import messagebox
import sqlite3;

#connect to databse
con = sqlite3.connect('Crash Statistics Victoria.db')
cur = con.cursor()

#root
root = Tk()
root.title('Accidents Analysis')
root.geometry("900x600")
root.iconbitmap(r"c:/Users/User/Desktop/assignment testing/week8/2810 lab/gui") //line 18
root.config(background = "#FFFFFF")```

CodePudding user response:

I'm not that good but i'll try to answer hope it helps

remove the ```

root.config(background = "#FFFFFF")```

the image you are trying to upload might not be .ico you'll need to make sure its either 16x16, 32x32, 64x64 pixels, this might help although i'm not sure there are a lot online just google - https://convertio.co/jpg-ico/

root.iconbitmap(r"c:/Users/User/Desktop/assignment testing/week8/2810 lab/gui") //line 18

if this did not help then I have no clue, I had the same issue 2 days ago and it was because I didn't have a .ico icon so it could be different for you, hope this helps!

CodePudding user response:

Your iconbitmap file extension should be .ico, .png or .jpeg

If problem still persists, try adding root.update() at execution

  • Related