creation: 2017-01-11
both are easy to use but,
there is no transparency with tkinter labels-images.
image on image using Canvas
from tkinter import *
from PIL import Image, ImageTk
def game():
root = Tk()
canvas = Canvas(root, height = 450 , width = 450 )
canvas.grid()
goban = PhotoImage( file = "images/goban.png" )
stone = PhotoImage( file = "images/white.png" )
goban_width = (goban.width() / 2 )
goban_height = (goban.height() / 2 )
canvas.create_image(goban_width,goban_height,image = goban)
canvas.create_image( 100 , 200 ,image = stone)
root.mainloop()
game()
|
image on image using tkinter labels
from tkinter import *
from PIL import Image, ImageTk
def game():
root = Tk()
root.geometry( "450x450" )
goban = PhotoImage( file = "images/goban.png" )
stone = PhotoImage( file = "images/white.png" )
label_go = Label(root, image = goban)
label_go.place( x = 0 , y = 0 )
white = Label(root, image = stone)
white.place( x = 100 , y = 200 )
root.mainloop()
game()
|