-1
我寫這個類兩種方法:的Python的Tkinter - Tcl錯誤
import tkinter, random
class MojaGrafika:
def __init__(self):
self.canvas = tkinter.Canvas(width=400, height=300)
self.canvas.pack()
def text(self, text, x, y, farba=None):
self.x = x
self.y = y
self.t = text
self.canvas.create_text(self.x, self.y, text=self.t)
然後我運行它(G = MojaGrafika(),g.text(200,150, 'P', '紅') ) 和這個錯誤來了:
Traceback (most recent call last):
File "<pyshell#11>", line 1, in <module>
g.text(200, 150, 'P', 'red')
File "C:\Users\zuzha\Documents\Cvicenia z programovania 2016\ZS\15.cvicenie.py", line 102, in text
self.p = self.canvas.create_text(self.x, self.y, text=self.t)
File "C:\Users\zuzha\AppData\Local\Programs\Python\Python35-32\lib\tkinter\__init__.py", line 2344, in create_text
return self._create('text', args, kw)
File "C:\Users\zuzha\AppData\Local\Programs\Python\Python35-32\lib\tkinter\__init__.py", line 2320, in _create
*(args + self._options(cnf, kw))))
_tkinter.TclError: bad screen distance "P"
有人可以幫我嗎?
感謝
是最後一句('PL:ZLAkolejnośćargumentów')答案不知何故一部分? –
@BryanOakley是的它回答波蘭語 - 我看到OP在代碼中使用波蘭語單詞。 – furas
是的,我剛剛發現了,謝謝! – Susan