0
from __future__ import print_function
from Tkinter import *
from tkFont import Font
#import RPi.GPIO as GPIO
from subprocess import call
import time
from time import sleep
from PIL import Image
from PIL import ImageTk
###STARTING A CLASS###
class MyDialog(Frame):
def __init__(self, parent):
Frame.__init__(self,parent)
self.parent = parent
self.mouse_pressed = False
self.initUI()
delay = 1000
def initUI(self):
self.tkimg = [None]
self.img = None
self.parent.title("High Tatras")
self.pack(fill=BOTH, expand=1)
self.img = Image.open("C:/Code_data/captures/test1_raw.png")
self.img = Image.new('1', (100, 100), 0)
self.img = self.img.resize((400, 400), Image.ANTIALIAS)
self.tkimg[0] = ImageTk.PhotoImage(self.img)
#self.config(image=self.tkimg[0])
canvas = Canvas(self, width=400, height=800+20)
canvas.create_image(10, 10, anchor=NW, image=self.tkimg[0])
canvas.pack(fill=BOTH, expand=1)
self.update_idletasks()
self.after(delay, self.initUI())
def main():
root = Tk()
ex = MyDialog(root)
ex.initUI()
root.wait_window(ex.top)
if __name__ == '__main__':
main()
저는 웹캠으로 촬영 한 이미지를 자동으로 새로 고침하고 여기에서 생략 된 GUI를 자동으로 실행하는 GUI를 작성합니다. 이미지는 코드 (C : /Code_data/captures/test1_raw.png)와 같은 이름으로 로컬에 저장됩니다. 여기에 내 해결책이있다. 그러나 코드를 실행 한 후에 GUI가 잠시 나타나서 사라졌다. 내가 뭘 잘못하고있어? 효율적인 방법이 있는지 궁금합니다.Tkinter GUI, 이미지 자동 새로 고침
고마워요! 하지만 initUI self.after (delay, self.initUI())'에'File "user_interface3.py"줄 159를 계속 출력하고 오류를 반환합니다. RuntimeError : Python 객체를 호출하는 동안 최대 재귀 심도를 초과했습니다. 나는 어떻게 든 코드 내부에서 루프를 돌리고 어떤 출력도 내게 줄 수 없다고 생각한다. –