“Bild in tkinter” Code-Antworten

So fügen Sie ein Bild in Tkinter hinzu

from tkinter import *
root=Tk()
img=PhotoImage(file='sunshine.jpg')
Label(root,image=img).pack()
root.mainloop()
Krypton 36

Bild in tkinter

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

Bild in tkinter

pip install Pillow
Bazinga

So platzieren Sie das Bild in Tkinter

import tkinter 
from PIL import Image, ImageTk

load= Image.open("/Users/omprakash/Desktop/Gmail-new-logo.jpg")
render = ImageTk.PhotoImage(load)
img = Label(root, image=render)
img.place(x=100, y=100)
Quaint Quail

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 “Bild in tkinter”

Fragen ähnlich wie “Bild in tkinter”

Weitere verwandte Antworten zu “Bild in tkinter” auf Python

Durchsuchen Sie beliebte Code-Antworten nach Sprache

Durchsuchen Sie andere Codesprachen