why i can't use wm_iconphoto two times?
root = Tk()
root_2 = Tk()
root.wm_iconphoto(#something)
root_2.wm_iconphoto(#same or another thing)
#Error
when i try set iconphoto for the second Tk window it returns this error:
Traceback (most recent call last):
File "C:\Users\lenovo\AppData\Local\Programs\Python\Python311\Lib\tkinter\__init__.py", line 1948, in __call__
return self.func(*args)
^^^^^^^^^^^^^^^^
File "c:\Users\lenovo\Desktop\clauth.py", line 41, in a91
b02.wm_iconphoto(False,b52)
File "C:\Users\lenovo\AppData\Local\Programs\Python\Python311\Lib\tkinter\__init__.py", line 2183, in wm_iconphoto
self.tk.call('wm', 'iconphoto', self._w, *args)
_tkinter.TclError: can't use "pyimage1" as iconphoto: not a photo image
Related
I have a code that constantly updates a clock and it's like this:
class countdown:
#initiatiate stuff
def count(self):
# countdown
# update textbox with the correct time
self.countdown_complete = customtkinter.CTkButton(self.countdownWindow,width=100, height =30, text="Complete", font=("Verdana",18), command = lambda: self.save_info(self.timer, i),fg_color=self.lightbutton, text_color=self.lightfont, hover_color=self.lightbutton)
self.countdown_complete.place(relx=0.5, rely=0.7, anchor=CENTER)
# I have a save function which saves some value as well as delete the window
# when number reaches 00:00:00, count up and update label to say its overdue
the problem is that after the complete button is pressed and the udf linked to the button deletes the window, the rest of the code continues to run.
i have a dict with elements inside, so if there is 1 element and when the only element is deleted, the lines referencing the array's crashes because it is now empty.
I need a way to stop count() from continuing after the complete button is pressed and window is deleted.
at least that's what I think the error is, here is the error message:
Exception in Tkinter callback
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/tkinter/__init__.py", line 1921, in __call__
return self.func(*args)
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/tkinter/__init__.py", line 839, in callit
func(*args)
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/customtkinter/windows/widgets/scaling/scaling_tracker.py", line 178, in check_dpi_scaling
if window.winfo_exists() and not window.state() == "iconic":
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/tkinter/__init__.py", line 1112, in winfo_exists
self.tk.call('winfo', 'exists', self._w))
_tkinter.TclError: can't invoke "winfo" command: application has been destroyed
invalid command name "4649351040_click_animation"
while executing
"4649351040_click_animation"
("after" script)
Exception in Tkinter callback
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/tkinter/__init__.py", line 1921, in __call__
return self.func(*args)
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/tkinter/__init__.py", line 839, in callit
func(*args)
File "/Users/tanhongen/Documents/GitHub/computing-coursework_S4-01/main.py", line 700, in countdown
self.countdownWindow.after(1000, self.countdown_time.configure(text=self.timer)) # updating the timer
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/customtkinter/windows/widgets/ctk_label.py", line 189, in configure
self._label.configure(text=self._text)
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/tkinter/__init__.py", line 1675, in configure
return self._configure('configure', cnf, kw)
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/tkinter/__init__.py", line 1665, in _configure
self.tk.call(_flatten((self._w, cmd)) + self._options(cnf))
_tkinter.TclError: invalid command name ".!ctklabel2.!label"
This is the error I'm getting on my shell when I use the credentials to generate a python code on Tkinter Desingner:
window_data = self.file_data["document"]["children"][0]["children"][0]
IndexError: list index out of range
Exception in Tkinter callback
Traceback (most recent call last):
File "/usr/lib/python3.6/tkinter/__init__.py", line 1705, in __call__
return self.func(*args)
File "gui.py", line 72, in btn_clicked
designer.design()
File "/home/carol/Tkinter-Designer/tkdesigner/designer.py", line 29, in design
code = self.to_code()
File "/home/carol/Tkinter-Designer/tkdesigner/designer.py", line 21, in to_code
The Figma file:
https://www.figma.com/file/Zadkbq5PwiqK15LjxlFyWn/login?node-id=0%3A1
i am trying to do a turtle game with the tkinter.Tk() class.
Here is the code:
from tkinter import *
import turtle
main = Tk(className="Castle Game")
s=turtle.TurtleScreen(cv=main,mode='standard', colormode=1.0, delay=10)
cover=turtle.RawTurtle(s)
It tries to return the following:
>>> ================================ RESTART ================================
>>>
Traceback (most recent call last):
File "H:\2 Computer science\Year 9\4Python\Castle.py", line 7, in <module>
s=turtle.TurtleScreen(cv=main,mode='standard', colormode=1.0, delay=10)
File "C:\Python33\lib\turtle.py", line 989, in __init__
TurtleScreenBase.__init__(self, cv)
File "C:\Python33\lib\turtle.py", line 488, in __init__
self.cv.config(scrollregion = (-w//2, -h//2, w//2, h//2 ))
File "C:\Python33\lib\tkinter\__init__.py", line 1263, in configure
return self._configure('configure', cnf, kw)
File "C:\Python33\lib\tkinter\__init__.py", line 1254, in _configure
self.tk.call(_flatten((self._w, cmd)) + self._options(cnf))
_tkinter.TclError: unknown option "-scrollregion"
>>>
In turtle graphics, the cv option stands for canvas, but you're giving it a Tk. That's why there's an error. To fix that, you will need to do this:
from tkinter import *
import turtle
root=Tk(className="Castle Game")
main = Canvas(root)
main.pack()
s=turtle.TurtleScreen(cv=main,mode='standard', colormode=1.0, delay=10)
cover=turtle.RawTurtle(s)
By changing main to Canvas and pack it onto a root.
I'm trying to change the background image in a turtle window.
The code reads simply as this:
import turtle
turtle.bgpic("france53.gif")
The turtle window shows up blank and I get the following error message:
Traceback (most recent call last):
File "<ipython-input-25-45373f8f3ea2>", line 1, in <module>
bgpic("france53.gif")
File "<string>", line 1, in bgpic
File "/Users/danielcharrier/anaconda/lib/python3.4/turtle.py", line 1482, in bgpic
self._setbgpic(self._bgpic, self._bgpics[picname])
File "/Users/danielcharrier/anaconda/lib/python3.4/turtle.py", line 738, in _setbgpic
self.cv.itemconfig(item, image=image)
File "<string>", line 1, in itemconfig
File "/Users/danielcharrier/anaconda/lib/python3.4/tkinter/__init__.py", line 2416, in itemconfigure
return self._configure(('itemconfigure', tagOrId), cnf, kw)
File "/Users/danielcharrier/anaconda/lib/python3.4/tkinter/__init__.py", line 1310, in _configure
self.tk.call(_flatten((self._w, cmd)) + self._options(cnf))
TclError: image "pyimage12" doesn't exist
The file "france53.gif" is in the working directory. What should I do to make it work?
I'm using the Anaconda distribution for Mac OS X.
Thanks!
I am trying to draw an image onto a canvas (mid conversion from place to canvas) and this error appears
hastebin containing code:
http://hastebin.com/tuciyisisa.py
Traceback (most recent call last):
File "D:\Stuff\python\Coursework\AQADo\main.py", line 82, in <module>
app = Application(master=root)
File "D:\Stuff\python\Coursework\AQADo\main.py", line 74, in __init__
self.drawCounter(space_y, current_space, game_canvas)
File "D:\Stuff\python\Coursework\AQADo\main.py", line 26, in drawCounter
canvas.create_image(170, space_y[current_space["1a"]], counter1)
File "C:\Python34\lib\tkinter\__init__.py", line 2291, in create_image
return self._create('image', args, kw)
File "C:\Python34\lib\tkinter\__init__.py", line 2282, in _create
*(args + self._options(cnf, kw))))
_tkinter.TclError: unknown option "pyimage2"
canvas.create_image(170, space_y[current_space["1a"]], counter1)
There seems to be a problem with your function signature here. create_image expects a position tuple, plus keyword arguments. Try:
canvas.create_image((170, space_y[current_space["1a"]]), image=counter1)
Now your application runs without any apparent errors.