Reputation: 55
I'm writing a code and I'm getting this error:
this is all the nessacery code
import os
import random
from PIL import ImageTk, Image
import tkinter as tk
def controlmenu():
root = tk.Tk()
frame = tk.Frame(root)
frame.pack()
path = "C:\\Users\user\\Documents\\Codes\\Python\\beathouse\\images\\controllermapping.jpg"
img = ImageTk.PhotoImage(Image.open(path))
panel = tk.Label(root, image=img)
panel.pack(side="bottom", fill="both", expand="yes")
root.mainloop()
root = tk.Tk()
frame = tk.Frame(root)
root.config(bg="black")
root.title("menu")
frame.pack()
bgc = "black"
fgc = "white"
conrtols=tk.Button(frame,
fg=fgc,
bg=bgc,
text="view controls",
command=controlmenu)
conrtols.pack(side=tk.LEFT)
root.mainloop()
this is not the exact code but i tested this exactly and it threw this error
meaning there are the same errors
Upvotes: 1
Views: 2112
Reputation: 55
Credit to Cool Cloud.
So the code says:
root=tk.Tk()
Well it needs to say:
root=tk.TopLevel()
Upvotes: 1