前提・実現したいこと
ubuntu20.04
python3.8を使用しています
画像をエンター押すことで切り替えたいと考えています
ですが、現状はimageに全画像が読み込まれているために表示ができていません。
なので、エンターを押すたびに一枚ずつ読み込むようなプログラムに変えたいです。
申し訳ございませんがご教示いただけないでしょうか。
該当のソースコード
def Image_insertion(self): files = natsorted(glob.glob("/home/limlab/deep_learning/japan_imagecaption/data/photo_data/*.jpg")) for n in range(len(files)): image = Image.open(files[n],'r') self.img = ImageTk.PhotoImage(image) width,height = image.size canvas = tkinter.Canvas(self,width=width,height=height) canvas.pack() canvas.create_image(width/2,height/2,image = self.img) def enter_fin(self): # テキストボックスのエンター部分 self.entry = tkinter.Entry(self,bd=5,width=80,fg="red",relief='raised') self.entry.place(x='30', y='500') text1 = self.entry.get() label1 = tkinter.Label(text=text1) label1.place(x=30, y=400) #エンター self.entry.bind('<Return>',self.Image_insertion)
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。