简体   繁体   中英

How to load images from a directory and move them

I am kind of new to python and I am trying to make a bot, I wanted to know the simplest way to get images from my files onto a screen in python. I want to load 2 images from my computer to pycharm/IDE python, both of the images are in a file -> Path: C:\Users\MyName\OneDrive\Desktop\bot_Images .

i also wanted to use turtle.write("Text Here", font=("Arial", 40, "normal")) to put text on the screen.

Then i would like to know how to move the text to be inside another image called text_box.png i need both images to be on the same turtle screen. How i would like it to be like

i would also like to know how to move the text box.

Please Help.

To display a image with turtle you want first initialize screen then use turtle.addshape() to add the image into turtle's shape list.

import turtle

screen = turtle.Screen()

bot_image_path = "<Absolute Path To Your Image>" # Note: The image must be gif format
screen.addshape(bot_image_path)  # Add image to turtle's shape list
turtle.shape(bot_image_path)  # Draw shape

To write the text within the textbox, you can use turtle.goto to move the cursor to the textbox's position and write the text.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM