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.
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"
I created GUI in Python (Python2.7) using Tkinter. I wish to have it up and running for both RHEL7.4 and RHEL5.11 versions. On REHL7.4, it works fine but on RHEL5.11, it gives the following error:
Traceback (most recent call last):
File "configure_workstation.py", line 28, in <module>
app = ConfigureWorkstation(wsObj)
File "/tmp/hnoman/v0.62/ConfigureWorkstation.py", line 90, in __init__
frame = F(self.fMenu, self)
File "/tmp/hnoman/v0.62/WorkstationInfoMenu.py", line 35, in __init__
self.generateHostnameFrame()
File "/tmp/hnoman/v0.62/WorkstationInfoMenu.py", line 50, in generateHostnameFrame
self.oLocation = ttk.OptionMenu(self.fHostname, self.location, dict[1], *dict.values())
File "/usr/local/python27/lib/python2.7/lib-tk/ttk.py", line 1591, in __init__
Menubutton.__init__(self, master, **kw)
File "/usr/local/python27/lib/python2.7/lib-tk/ttk.py", line 797, in __init__
Widget.__init__(self, master, "ttk::menubutton", kw)
File "/usr/local/python27/lib/python2.7/lib-tk/ttk.py", line 554, in __init__
_load_tile(master)
File "/usr/local/python27/lib/python2.7/lib-tk/ttk.py", line 46, in _load_tile
master.tk.eval('package require tile') # TclError may be raised here
_tkinter.TclError: can't find package tile
Can someone guide how to overcome this?
I've been working with the same Python/Tkinter code for a week now, and seemingly out of nowhere I am getting the error "Bad label specification":
Traceback (most recent call last):
File "C:/Users/shapirju/Desktop/NumericalAnalysis-Project2/gui.py", line 1188, in <module>
gui = App()
File "C:/Users/shapirju/Desktop/NumericalAnalysis-Project2/gui.py", line 62, in __init__
self.createWidgets()
File "C:/Users/shapirju/Desktop/NumericalAnalysis-Project2/gui.py", line 70, in createWidgets
self.interpLabelframe = LabelFrame(self.root, text = "Interpolation", labelanchor=N)
File "C:\Program Files\Python27\lib\lib-tk\ttk.py", line 776, in __init__
Widget.__init__(self, master, "ttk::labelframe", kw)
File "C:\Program Files\Python27\lib\lib-tk\ttk.py", line 555, in __init__
Tkinter.Widget.__init__(self, master, widgetname, kw=kw)
File "C:\Program Files\Python27\lib\lib-tk\Tkinter.py", line 2096, in __init__
(widgetName, self._w) + extra + self._options(cnf))
_tkinter.TclError: Bad label anchor specification 443664640LN
It is caused by the line self.interpLabelframe = LabelFrame(self.root, text = "Interpolation", labelanchor=N)
As this worked a few hours ago, maybe this is an environmental issue? I cannot find anything about this issue on Google.
Changing it to self.interpLabelframe = LabelFrame(self.root, text = "Interpolation", labelanchor='n') fixes the issue.
According to the source code for LabelFrame, the label anchors are defined as strings 'n', 'we', etc.
I am trying to insert an image to window but I get an error.
Traceback (most recent call last):
File "C:\Users\Afro\AppData\Local\Programs\Python\Python35\lib\tkinter\__init__.py", line 1549, in __call__
return self.func(*args)
File "C:\Users\Afro\Desktop\h.py", line 151, in start
pic_lab = Label(wind,image=pik)
File "C:\Users\Afro\AppData\Local\Programs\Python\Python35\lib\tkinter\__init__.py", line 2605, in __init__
Widget.__init__(self, master, 'label', cnf, kw)
File "C:\Users\Afro\AppData\Local\Programs\Python\Python35\lib\tkinter\__init__.py", line 2138, in __init__
(widgetName, self._w) + extra + self._options(cnf))
_tkinter.TclError: image "pyimage2" doesn't exist
Here's my code
wind = Tk()
name = money.jpg'
pik = ImageTk.PhotoImage(Image.open(name))
pic_lab = Label(wind,image=pik)
pic_lab.grid()
What do I need to do?
The string 'money.jpg' that is assigned to the variable name is missing a single quotation mark on the left.
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!