0
나는 Rasbperry Pi 3을 설정하고 Python 3을 사용했다. 나는 이미지를 찍을 수는 있지만 화면에서 그들을 새로 고쳐야한다. Tkinker에 아주 새로운 기능. 몇 가지 코드가 있지만 좋은 크기의 이미지를 캔버스에 배치하고 내 버튼 중 하나를 누를 때이를 새로 고치는 방법을 알고 싶습니다.python 3 tkinter images
#!/usr/bin/python
import tkinter
import RPi.GPIO as GPIO
import picamera
import time
from PIL import Image, ImageTk
def startup():
def callback(a):
if a==4:
thiscolour="yellow"
camera.capture('/home/pi/Desktop/image.jpg')
if a==2:
thiscolour="red"
lbl.configure(text=thiscolour+" has been pressed")
path = "/home/pi/Desktop/image.jpg"
img = Image.open(path)
new_width = 400
new_height = 600
#img = img.resize((new_width, new_height), Image.ANTIALIAS)
img.save('thisimage.jpg')
path="thisimage.jpg"
path="thisimage.jpg"
image = Image.open(path)
photo = ImageTk.PhotoImage(image)
img = ImageTk.PhotoImage(Image.open(path))
panel.configure(image=photo)
panel.pack()
camera = picamera.PiCamera()
path = "/home/pi/Desktop/image.jpg"
img = Image.open(path)
new_width = 400
new_height = 600
img = img.resize((new_width, new_height), Image.ANTIALIAS)
img.save('thisimage.jpg')
path="thisimage.jpg"
GPIO.setmode(GPIO.BCM)
GPIO.setwarnings(False)
buttonyellow = 4
buttonred = 2
t=0
GPIO.setup(buttonyellow, GPIO.IN, GPIO.PUD_UP)
GPIO.setup(buttonred, GPIO.IN, GPIO.PUD_UP)
window=tkinter.Tk()
window.title("Photobooth")
window.geometry("1000x800")
lbl=tkinter.Label(window,text="Instructions")
ent=tkinter.Entry(window)
btn=tkinter.Button(window,text="Press here", bg='red')
btn=tkinter.Button(window,text="Click me",bg='red',command=callback)
btn.pack()
lbl.pack()
ent.pack()
btn.pack()
GPIO.add_event_detect(buttonyellow, GPIO.FALLING, callback=callback, bouncetime=100)
GPIO.add_event_detect(buttonred, GPIO.FALLING, callback=callback, bouncetime=100)
path="thisimage.jpg"
image = Image.open(path)
photo = ImageTk.PhotoImage(image)
img = ImageTk.PhotoImage(Image.open(path))
panel = tkinter.Label(window, image = img)
panel.pack(side = "bottom", fill = "both", expand = "yes")
window.mainloop()
startup()
'버튼 (..., 명령 = FUNCTION_NAME)'와'canvas.create_image (...)' – furas
더 나은 몇 가지 튜토리얼 -http을 찾을 : //effbot.org/tkinterbook/ – furas
감사합니다. 나는 많은 튜토리얼을 발견했지만, 나는이 분야에 머물러있는 것 같다. – stixson99