Skip to content

Commit

Permalink
Catch Tk errors
Browse files Browse the repository at this point in the history
  • Loading branch information
thompson318 committed Apr 27, 2023
1 parent 299d87f commit 0fc718b
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions imshowtk/imshowtk.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"""A class to bring up a debugging window"""

from tkinter import Tk, Canvas, NW, PhotoImage
from tkinter import Tk, Canvas, NW, PhotoImage, TclError

def rgb2hex(red,green,blue):
"""
Expand Down Expand Up @@ -88,9 +88,11 @@ def imshow(self, frame):
if not self.initialised:
self.setup_window(frame)

print(frame.shape)
self.image = bitmap_to_photo(frame, self.subsample)
print(self.image.height())
print(self.image.width())
self.canvas.create_image(0, 0, anchor=NW, image=self.image)
try:
self.canvas.create_image(0, 0, anchor=NW, image=self.image)
except TclError as error_msg:
print ("Ignoring Tk error: ", str(error_msg))
return

self.tk_window.update()

0 comments on commit 0fc718b

Please sign in to comment.