CaptionWindow.py 文件源码

python
阅读 20 收藏 0 点赞 0 评论 0

项目:JetsonTX1_im2txt 作者: Netzeband 项目源码 文件源码
def __init__(self, VideoStream, CaptionFunc = None):
    self._CaptionFunc = CaptionFunc
    self._VideoStream = VideoStream

    # Set up GUI
    self._Window = tk.Tk()
    self._Window.wm_title("Image Captioning Demo")
    self._Window.config(background="#FFFFFF")
    self._Window.rowconfigure(0, weight=1)
    self._Window.columnconfigure(0, weight = 1)
    self._Window.minsize(480, 320)

    # Graphics window
    self._ImageFrame = tk.Frame(self._Window)
    self._ImageFrame.grid(row=0, column=0, columnspan=3, rowspan=2, padx=10, pady=10, sticky=tk.N+tk.S+tk.E+tk.W)
    self._ImageFrame.rowconfigure(0, weight=1)
    self._ImageFrame.columnconfigure(0, weight=1)

    # Capture video frames
    self._IsVideoRunnung = True
    self._VideoLabel = tk.Label(self._ImageFrame)
    self._VideoLabel.grid(row=0, column=0, sticky=tk.N+tk.S+tk.E+tk.W)
    self._VideoLabel.rowconfigure(0, weight=1)
    self._VideoLabel.columnconfigure(0, weight=1)
    self._showVideoFrame() 

    # Control Frame
    self._ControlFrame = tk.Frame(self._Window)
    self._ControlFrame.grid(row = 2, column=0, padx=10, pady=2, sticky=tk.N+tk.S)
    self._ControlFrame.rowconfigure(0, weight=0, minsize=30)
    self._ControlFrame.columnconfigure(0, weight=0)

    # Pause Button
    self._PauseButton = tk.Button(self._ControlFrame, text="Pause", command=self._pressPause)
    self._PauseButton.grid(row = 0, column = 0)
    self._Window.bind("<Key>", self._pressKey)

    # Captioning Button
    self._CaptionButton = tk.Button(self._ControlFrame, text="Caption", command=self._pressCaption)
    self._CaptionButton.grid(row = 0, column = 1)

    # Open Button
    self._OpenButton = tk.Button(self._ControlFrame, text="File...", command=self._openImage)
    self._OpenButton.grid(row = 0, column = 2)

    # Text Output
    self._TextFrame = tk.Frame(self._Window)
    self._TextFrame.grid(row = 3, column=0, padx=10, pady=2, sticky=tk.N+tk.S+tk.E+tk.W)
    self._TextFrame.rowconfigure(0, weight=1)
    self._TextFrame.columnconfigure(0, weight=1)
    ScrollBar = tk.Scrollbar(self._TextFrame)
    ScrollBar.grid(column=6, sticky=tk.W+tk.S+tk.N)
    self._OutputText = tk.Text(self._TextFrame, height=3, width=50)
    self._OutputText.grid(row=0, columnspan=5, column=0, sticky=tk.N+tk.S+tk.W+tk.E)
    self._OutputText.rowconfigure(0, weight=1)
    self._OutputText.columnconfigure(0, weight=1)
    ScrollBar.config(command=self._OutputText.yview)
    self._OutputText.config(yscrollcommand=ScrollBar.set)
    self._OutputText.delete('1.0', tk.END)
    self._OutputText.config(font=("Courier", 22))
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号