“Tkinter -Ladebild” Code-Antworten

Tkinter -Ladebild

from tkinter import *
from PIL import ImageTk, Image

root = Tk()

c = Canvas(root, width=500, height=500)
c.pack()

img = ImageTk.PhotoImage(Image.open(r"imagepath\imagename.extension"))
c.create_image(x, y, image=img, anchor=NW)
Blue Badger

Tkinter -Ladebild

pip install Pillow
Bazinga

Bild in tkinter

import tkinter as tk
window = tk()
canvas = Canvas(window, width=300, height=300)
image = PhotoImage('path')
canvas.create_image(height=40, width=40, img=image) 
Tejas Naik

Bild in tkinter

import tkinter
from tkinter import *
from PIL import Image, ImageTk

root = Tk()

# Position text in frame
Label(root, text = 'Position image on button', font =('<font_name>', <font_size>)).pack(side = TOP, padx = <x_coordinate#>, pady = <y_coordinate#>)

# Create a photoimage object of the image in the path
photo = PhotoImage(file = "</path/image_name>")

# Resize image to fit on button
photoimage = photo.subsample(1, 2)

# Position image on button
Button(root, image = photoimage,).pack(side = BOTTOM, pady = <y_coordinate#>)
mainloop()
mustafa saad

Ähnliche Antworten wie “Tkinter -Ladebild”

Fragen ähnlich wie “Tkinter -Ladebild”

Weitere verwandte Antworten zu “Tkinter -Ladebild” auf Python

Durchsuchen Sie beliebte Code-Antworten nach Sprache

Durchsuchen Sie andere Codesprachen