python-turtle

Why doesn't this monkey patch work for python turtle?

穿精又带淫゛_ 提交于 2021-02-11 15:31:16
问题 So I'm trying to monkey patch the onkey function in turtle so it calls a function with the button hit instead of just calling it with no arguments. I'm using the string "tester" to see if it works, but it looks like the original functions never got changes. Can someone explain what I'm doing wrong? from threading import Thread from time import sleep from turtle import * def NEWonkeypress(self, fun, key=None): if fun is None: if key in self._keys: self._keys.remove(key) elif key is not None

Pylint Error with Python Turtle even though code executes properly

北战南征 提交于 2021-02-11 12:09:50
问题 import turtle class Polygon: def __init__(self,sides,name,size=100,color='black',line_thickness=3): self.sides=sides self.name=name self.size=size self.color=color self.line_thickness=line_thickness self.interior_angles=(self.sides-2)*180 self.angle=self.interior_angles/self.sides def draw(self): turtle.color(self.color) turtle.pensize(self.line_thickness) for i in range(self.sides): turtle.forward(self.size) turtle.right(180-self.angle) turtle.done() square=Polygon(4,'Square') square.draw()

Is there a way to change the location of a text box in turtle? It always shows up in the top left for me, but I want it in the bottom center

泄露秘密 提交于 2021-02-09 11:13:28
问题 import turtle screen = turtle.Screen() global answer answer = screen.textinput("Welcome to the game", "What's your name?") Here is a screenshot of what comes up. I can't seem to find anything describing a way to edit the box at all. I'm also looking for ways to edit the overall appearance of the box, as it's intended purpose is for dialogue in the game I'm working on. 回答1: The window with the input is made with tkinter. You can make your own function that makes it. Here is a sample of your

How to show two different photos as turtles?

谁说胖子不能爱 提交于 2021-02-07 10:10:21
问题 I'm trying to import two different pictures and show them in a line using Turtle (when I'll manage to do so they are supposed to move) but I can't find a way to show them together, the last picture I assigned to the turtle and the screen is taking over. This is my code: from turtle import Turtle, Screen from PIL import Image screen = Screen() height = 200 def create_players(height): player = Turtle() pic_name = input('write exact photo name: ') image = Image.open(pic_name) new_image = image

How to show two different photos as turtles?

瘦欲@ 提交于 2021-02-07 10:10:12
问题 I'm trying to import two different pictures and show them in a line using Turtle (when I'll manage to do so they are supposed to move) but I can't find a way to show them together, the last picture I assigned to the turtle and the screen is taking over. This is my code: from turtle import Turtle, Screen from PIL import Image screen = Screen() height = 200 def create_players(height): player = Turtle() pic_name = input('write exact photo name: ') image = Image.open(pic_name) new_image = image

How to show two different photos as turtles?

故事扮演 提交于 2021-02-07 10:10:01
问题 I'm trying to import two different pictures and show them in a line using Turtle (when I'll manage to do so they are supposed to move) but I can't find a way to show them together, the last picture I assigned to the turtle and the screen is taking over. This is my code: from turtle import Turtle, Screen from PIL import Image screen = Screen() height = 200 def create_players(height): player = Turtle() pic_name = input('write exact photo name: ') image = Image.open(pic_name) new_image = image

How to show two different photos as turtles?

你。 提交于 2021-02-07 10:08:54
问题 I'm trying to import two different pictures and show them in a line using Turtle (when I'll manage to do so they are supposed to move) but I can't find a way to show them together, the last picture I assigned to the turtle and the screen is taking over. This is my code: from turtle import Turtle, Screen from PIL import Image screen = Screen() height = 200 def create_players(height): player = Turtle() pic_name = input('write exact photo name: ') image = Image.open(pic_name) new_image = image

How to show two different photos as turtles?

谁说我不能喝 提交于 2021-02-07 10:08:41
问题 I'm trying to import two different pictures and show them in a line using Turtle (when I'll manage to do so they are supposed to move) but I can't find a way to show them together, the last picture I assigned to the turtle and the screen is taking over. This is my code: from turtle import Turtle, Screen from PIL import Image screen = Screen() height = 200 def create_players(height): player = Turtle() pic_name = input('write exact photo name: ') image = Image.open(pic_name) new_image = image

Error when opening different windows in turtle using tkinter

帅比萌擦擦* 提交于 2021-01-29 15:17:40
问题 I have a problem using turtle with tkinter in Python 3.8. Still new to programming so thanks in advance! I have a tkinter window where you can chose to play either level one or two, every time you start the program either level will work but once you have finished the level and try another level, including the same level I get an error. error message: "Exception in Tkinter callback Traceback (most recent call last): File "C:\Users\Kev\AppData\Local\Programs\Python\Python38\lib\tkinter\__init_

Python module turtle not importing correctly

六眼飞鱼酱① 提交于 2021-01-29 11:33:32
问题 This is my fist time using the turtle module in python but i can't seem to import it? Here's my code: import turtle turtle.shape("turtle") turtle.speed(1) turtle.forward(100) turtle.left(90) turtle.forward(100) turtle.left(90) turtle.forward(100) turtle.left(90) turtle.forward(100) turtle.left(90) turtle.exitonclick() I run this as $ python3 example.py And I get $ python3 example.py Traceback (most recent call last): File "example.py", line 1, in <module> from turtle import * File "/usr/lib