“Gambar di Tkinter” Kode Jawaban

cara menambahkan gambar di tkinter

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

Gambar di 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

Gambar di Tkinter

pip install Pillow
Bazinga

cara menempatkan gambar di 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

Gambar di 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

Gambar di 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

Jawaban yang mirip dengan “Gambar di Tkinter”

Pertanyaan yang mirip dengan “Gambar di Tkinter”

Lebih banyak jawaban terkait untuk “Gambar di Tkinter” di Python

Jelajahi jawaban kode populer menurut bahasa

Jelajahi bahasa kode lainnya