0
from turtle import *
import time
ht()
setup(width=500, height=500, startx=0, starty=0)
x=0
y=0
goto(0, 0)
colormode(255)
while True:
write("Please type your screens size in pixels into the console.", move=False, align="center", font=("Arial", 10, "normal"))
x = int(input('x'))
y = int(input('y'))
if x > 0:
print('.')
if y > 0:
print('...')
break
if x==0:
x=1000
y=500
break
else:
clear()
write("Please enter a valid number (ie. x, y)", move=False, align="center", font=("Arial", 28, "normal"))
setup(width=1400, height=800, startx=100, starty=20)
clear()
def FADE_IN_OUT(arg, align, font, size, Norm, fspeedin, fspeedout, pause):
r=255
g=255
b=255
for i in range(100):
pencolor((r,g,b))
write(arg, move=False, align=align, font=(font, size, Norm))
r-=25.5
g-=25.5
b-=25.5
time.sleep(fspeedin/100)
clear()
time.sleep(pause)
for i in range(100):
pencolor((r,g,b))
write(arg, move=False, align=align, font=(font, size, Norm))
r+=25.5
g+=25.5
b+=25.5
time.sleep(fspeedout/100)
clear()
FADE_IN_OUT("47 Studios", "center", "Arial", x/5, "normal", 2.5, 2.5, 5)
#the following is the error message I receive:
Traceback (most recent call last):
File "C:/Python34/Survive.py", line 48, in <module>
FADE_IN_OUT("47 Studios", "center", "Arial", x/5, "normal", 2.5, 2.5, 5)
File "C:/Python34/Survive.py", line 33, in FADE_IN_OUT
write(arg, move=False, align=align, font=(font, size, Norm))
File "<string>", line 1, in write
File "C:\Python34\lib\turtle.py", line 3431, in write
end = self._write(str(arg), align.lower(), font)
File "C:\Python34\lib\turtle.py", line 3403, in _write
self._pencolor)
File "C:\Python34\lib\turtle.py", line 597, in _write
fill = pencolor, font = font)
File "<string>", line 1, in create_text
File "C:\Python34\lib\tkinter\__init__.py", line 2342, in create_text
return self._create('text', args, kw)
File "C:\Python34\lib\tkinter\__init__.py", line 2318, in _create
*(args + self._options(cnf, kw))))
_tkinter.TclError: expected integer but got "200.0"
テキストをフェードイン/フェードインしようとしていますが、範囲外であるというエラーメッセージが表示されます。私はcolormode(255)を使用するように言われてきましたが、それは動作しません。私は255が高いかどうか分からないが助けてください。python turtle colormode not working
はどうもありがとうございましたPythonの2のコードを実行してみてください –