Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8477289
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T18:25:24+00:00 2026-06-10T18:25:24+00:00

How do I draw an image in a tkinter window (I’m using python 3.3)?

  • 0

How do I draw an image in a tkinter window (I’m using python 3.3)? I’m looking for a statement which would draw an image at a given position on a tkinter window.

yeah…

Any answers would be appreciated. And here’s the source code of the program (if it can be called that) that I want to use the code in, in case you need it.

from tkinter import *

class craftClass():
    def __init__(self, x = 80, y = 80, xmotion = 0, ymotion = 0, health = 20):
        self.xPos, self.yPos = x, y
        self.dx, self.dy = xmotion, ymotion
    def moveCraft(self):
        self.xPos += self.dx
        self.yPos += self.dy

class missileClass():
    def __init__(self, x = 0 , y = 0):
        self.xPos, self.yPos = x, y

class alienClass():
    def __init__(self, x, y):
        self.xPos, self.yPos = x, y

    def moveForCraft(self, craftX, craftY):
        if self.xPos < craftX:
            self.xPos += 2
        elif self.xPos > craftX:
            self.xPos -= 2
        else:
            pass

    if self.yPos < craftY:
        self.yPos += 2
    elif self.yPos > craftY:
        self.yPos -= 2
    else:
        pass

craft = craftClass()
missileArray = []
alienArray = []

def keypress(event):
    if event.keysym == 'Escape':
        root.destroy()
x = event.char
if x == "w":
    craft.dy = 1
elif x == "s":
    craft.dy = -1
elif x == "a":
    craft.dx = -1
elif x == "d":
    craft.dx = 1
else:
    print(x)

root = Tk()
print(craft.dx)
while True:
try:
    root.bind_all('<Key>', keypress)
    craft.moveCraft()
    root.update()
except TclError:
    print("exited. tcl error thrown. llop broken")
    break

I’m well aware that the spacing is sorta messed up, but that’s something that happened while copying

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T18:25:26+00:00Added an answer on June 10, 2026 at 6:25 pm

    You will need to use a Canvas widget to put your images in specified (x,y) positions.

    In Python 3, you can do like this:

    import tkinter
    
    tk = tkinter.Tk()
    can = tkinter.Canvas(tk)
    can.pack()
    img = tkinter.PhotoImg("<path/to/image_file>.gif")
    can.create_image((x_coordinate, y_coordinate), img)
    

    Please note that due to Python 3 not having an official PIL* release, you are limited to read images of type GIF, PGM or PPM – if you need other file types, check this answer.

    The Canvas widget is quite powerfull, and allows you to position your images, shows what is on it through an "canvas.update" call, and remove an item displayer with a "canvas.delete(item_id)" call. Check its documentation.

    While Tkinter should be enough for your simple game, consider taking a look at Pygame, for a better multimedia support, or maybe Pyglet, or even higher level multimedia framework called Kivy.

    *(update): As of 2015, there is Pillow – a fork that is a drop in replacement of the old PIL project, and which resumed proper development of the project, including support for Python 3.x

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using PIL to draw text on an image. How would I wrap a
I draw an image in OnRender method of my custom FrameworkElement. I would like
I'm trying to draw grayscale image in color as texture in OpenGL using two
I am making an app in which i have to draw image in canvas
How can I draw image with rounded corners in Cairo/Gtk? In any language.
I'm trying to draw image using UIImage 's drawInRect: method. Here is the code:
When user clicked on the screen, I can draw image using Canvas.drawBitmap(). Then I
I am using following code to draw scaled image in PaintListener. e.gc.drawImage(image, 0, 0,
I am finding a way to draw image with per pixel alpha using UIView
I want to draw image(bmp) using an image pointer by VS2005(MFC). But I don't

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.