0

Importing Image/s in python

How do you add an image in python

15th Sep 2019, 4:53 PM
Josh
Josh - avatar
2 Answers
+ 3
Use Tkinter module from tkinter import * # pip install pillow from PIL import Image, ImageTk class Window( Frame ) : def __init __ ( self , master= None ) : Frame . __init __(self , master) self . master = master self . pack ( fill = BOTH , expand= 1 ) load = Image . open ( " Koder. jpg" ) render = ImageTk . PhotoImage ( load ) img = Label ( self , image= render) img. image = render img. place ( x = 0 , y = 0 ) root = Tk() app = Window( root ) root . wm_ title ( " Tkinter window" ) root . geometry( " 200x 120" ) root . mainloop()
15th Sep 2019, 5:48 PM
Jella
Jella - avatar
0
#Pygame does it shorter: import pygame_sdl2 as pygame pygame.init() image = pygame.image.load("smile.jpg") surface = pygame.display.set_mode(image.get_size()) surface.blit(image, image.get_rect()) pygame.display.flip() pygame.time.delay(5000) pygame.quit()
15th Sep 2019, 6:25 PM
Seb TheS
Seb TheS - avatar