Skip to content

Python code snippet – How to add turtle in tkinter?

from tkinter import *
from turtle import RawTurtle, TurtleScreen
"""
Will make a tk window and a TurtleScreen with a turtle in it
"""
root = Tk()              # the tk window
can = Canvas(root)       # a canvas what will turn into turtle screen
tsc = TurtleScreen(can)  # the screen inside tk window
tur = RawTurtle(tsc)     # the turtle; what you can do any turtle stuff with
See also  How to print smallest number in Python?

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.