turtle-graphics

My text in my clock python is not aligning properly

不羁岁月 提交于 2020-06-27 04:08:06
问题 My text in my turtle module is not aligning properly, it is aligned up and to the left. I want it to align exactly where the turtle is. Can anyone help? I tried setting the xcor and ycor of the turtle up and to the left by 5 units and that did not work. Any help would be greatly appreciated. Code: import time from datetime import datetime,date import turtle t = turtle.Pen() while True: turtle.tracer(0, 0) hour_hand = float(datetime.today().hour) minute_hand = float(datetime.today().minute)

Python Turtle - Disable Window Resize

半世苍凉 提交于 2020-06-26 04:47:42
问题 Is there a way to disable the window resizing in the Turtle module? E.G - Disable the maximize and minimize button and disable the ability to drag the window out or in. Thanks! 回答1: There's another way of doing it which is a little more 'hacky' but works well for projects that are already written using TurtleScreen and not a RawTurtle . It is actually a one-liner: screen = turtle.Screen() # ... screen.cv._rootwindow.resizable(False, False) This accesses the root window of the scrollable

Embedding turtle graphics in Pyqt5 interface

流过昼夜 提交于 2020-06-23 15:59:25
问题 I'm trying to make GUI in pyqt5 with only a button and a simple recursive drawing what're the ideal tools for this task? I tried Turtle which is simple and get the job done but I don't know how to embed the graphics inside pyqt it opens a different window 回答1: turtle is built on top of tkinter. tkinter and pyqt5 each use their own event loop. I don't think it is possible (or at least, it wouldn't be very easy) to mix two different GUI toolkits ( tkinter and pyqt5 ) in one app. If you want to

How to handle clicks on a turtle and clicks off of a turtle separately?

余生颓废 提交于 2020-06-17 15:48:28
问题 Using the Python 3 "turtle" module, I am trying to handle two different click conditions separately: If a turtle is clicked on, it should call a function. (In the example below, it should switch from black to red, or vice versa.) If a click is NOT on a (visible) turtle, a different function should be called (to create a turtle at that point). Right now I can make this work using two different mouse buttons, like so: #!/usr/local/bin/python3 import turtle sc = turtle.Screen() def new_turtle(x,

turtle.Screen().screensize() not outputting the right screensize [duplicate]

℡╲_俬逩灬. 提交于 2020-06-17 07:59:50
问题 This question already has an answer here : How can I change the size of my python turtle window? (1 answer) Closed 4 months ago . I have written some code to place dots all around the screen randomly; however, it does not cover the entire screen: import turtle import random t = turtle.Turtle() color = ["red", "green", "blue", "pink", "yellow", "purple"] t.speed(-1) for i in range(0, 500): print(turtle.Screen().screensize()) z = turtle.Screen().screensize() x = z[0] y = z[1] t.color(color

Python, Turtle Graphics, Key bindings

让人想犯罪 __ 提交于 2020-06-17 00:51:09
问题 I'm trying to figure out a way to make it to when I hold down a key the player will constantly move, or just have the player move forward constantly with just turtle graphics, (I do have pygame installed also) import turtle from turtle import * #Setup Screen wn = turtle.Screen() wn.setup(700,700) wn.title("white") wn.bgcolor("black") #Create Player player = turtle.Turtle() player.penup() player.shape("triangle") player.color("white") def forward(): player.forward(20) def lef(): player.left(90

Python turtle ondrag event vs. compound shapes

此生再无相见时 提交于 2020-06-15 04:13:05
问题 When I register a polygon, or a compound shape with only a single component, I'm able to create a turtle cursor using that shape, add a drag event handler, and drag it around the screen. But when I register a compound shape with a second component, I can no longer drag it: from turtle import Turtle, Screen, Shape def simple_polygon(turtle): turtle.begin_poly() turtle.circle(50) turtle.end_poly() screen.register_shape("simple_polygon", turtle.get_poly()) turtle.reset() def compound_single

Python(Turtle Module) - Mouse Cursor Position in Window

烂漫一生 提交于 2020-06-12 09:13:06
问题 How would I go about finding the current position of the mouse pointer in the turtle screen? I want it so I have the mouse position before I click and while im moving the cursor. I have searched google and this website can't find anything besides how to get the position after a click. 回答1: turtle.getcanvas() returns a Tkinter Canvas. Like with a Tkinter window, you can get the current mouse pointer coordinates by winfo_pointerx and .winfo_pointery on it: canvas = turtle.getcanvas() x, y =

Can't import turtle

孤街醉人 提交于 2020-06-09 05:34:08
问题 I'm a complete novice, so I appreciate the answers. I'm trying to get turtle on my powershell, because that's what the book I'm reading says to do but this shows up, import : The term 'import' is not recognized as the name of a cmdlet,function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again. At line:1 char:1 + import turtle + ~~~~~~ + CategoryInfo : ObjectNotFound: (import:String) [],

Python Turtle mainloop() usage

人盡茶涼 提交于 2020-05-31 07:11:39
问题 I have the following code from an online tutorial to learn event-based programming by making a stop light that changes state when the mouse is clicked. Here is the entirety of my code: import turtle turtle.setup(400,500) wn = turtle.Screen() wn.title("Tess becomes a traffic light!") wn.bgcolor("lightgreen") tess = turtle.Turtle() def draw_housing(): tess.pensize(3) tess.color("black","darkgrey") tess.begin_fill() tess.forward(80) tess.left(90) tess.forward(200) tess.circle(40, 180) tess