1
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

python デジタルフォトフレームの作り方 -tkinter-

Last updated at Posted at 2022-07-19

7秒ごとに写真を変えていく

import tkinter

pnum = 0
def photograph():
  global pnum
  canvas.delete("PH")
  canvas.create_image(400,300,image=photo[pnum], tag="PH")#400 canvas内の画像の位置。x座標 300 canvas内の画像の位置。y座標。
  pnum = pnum + 1
  if pnum >= len(photo):
    pnum = 0
  root.after(7000, photograph)

root = tkinter.Tk()
root.title("デジタルフォト")
canvas = tkinter.Canvas(width=800, height=600)
canvas.pack()
photo = [
  tkinter.PhotoImage(file="cat5.png"), #pngじゃないとダメっぽい
  tkinter.PhotoImage(file="****.png"),
  tkinter.PhotoImage(file="****.png"),
  tkinter.PhotoImage(file="****.png")
]
photograph()
root.mainloop()

スクリーンショット 2022-07-20 0.28.14.png

1
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?