-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.py
65 lines (62 loc) · 2.27 KB
/
test.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
import tkinter as tk
import PIL
from PIL import ImageTk
import cv2
from matplotlib.backends.backend_tkagg import (FigureCanvasTkAgg, NavigationToolbar2Tk)
# Implement the default Matplotlib key bindings.
from matplotlib.backend_bases import key_press_handler
from matplotlib.figure import Figure
import numpy as np
currentFrameIndex = 0
root = tk.Tk()
root.wm_title("Embedding in Tk")
decFrameCv = cv2.imread("frame" + str(currentFrameIndex) + ".jpg")
print("checking dec path: " + "frame" + str(currentFrameIndex) + ".jpg")
decFrame = PIL.ImageTk.PhotoImage(image=PIL.Image.fromarray(decFrameCv))
decFrameButton = tk.Button(root, text="hello", command=print("hello"))
decFrameButton.grid(row=0, column=0)
root.mainloop()
decFrameImageLabel = tk.Label(root, image=decFrame)
decFrameImageLabel.image = decFrame
decFrameImageLabel.grid(row=1, column=0)
# root.mainloop()
# decFrame1 = PIL.Image.open("frame" + str(currentFrameIndex) + ".jpg")
# print("checking dec path: " + "frame" + str(currentFrameIndex) + ".jpg")
# decFrame = tk.PhotoImage(file="frame" + str(currentFrameIndex) + ".jpg")
# root.decFrameImageLabel = tk.Label(root, image=decFrame)
# root.decFrameImageLabel.image = decFrame
# root.decFrameImageLabel.grid(row=0, column=0)
# root.mainloop()
# fig = Figure(figsize=(5, 4), dpi=100)
# t = np.arange(0, 3, .01)
# fig.add_subplot(111).plot(t, 2 * np.sin(2 * np.pi * t))
#
# canvas = FigureCanvasTkAgg(fig, master=root) # A tk.DrawingArea.
# canvas.draw()
# canvas.get_tk_widget().pack(side=tkinter.TOP, fill=tkinter.BOTH, expand=1)
#
# toolbar = NavigationToolbar2Tk(canvas, root)
# toolbar.update()
# canvas.get_tk_widget().pack(side=tkinter.TOP, fill=tkinter.BOTH, expand=1)
#
#
# def on_key_press(event):
# print("you pressed {}".format(event.key))
# key_press_handler(event, canvas, toolbar)
#
#
# canvas.mpl_connect("key_press_event", on_key_press)
#
#
# def _quit():
# root.quit() # stops mainloop
# root.destroy() # this is necessary on Windows to prevent
# # Fatal Python Error: PyEval_RestoreThread: NULL tstate
#
#
# button = tkinter.Button(master=root, text="Quit", command=_quit)
# button.pack(side=tkinter.BOTTOM)
#
# tkinter.mainloop()
# # If you put root.destroy() here, it will cause an error if the window is
# # closed with the window manager.