Skip to content

Commit

Permalink
GTK to raise error if image path is not valid
Browse files Browse the repository at this point in the history
  • Loading branch information
obulat authored May 28, 2018
1 parent cd403d6 commit 2e2cee9
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/gtk/toga_gtk/widgets/imageview.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@ def set_image(self, image):
with urlopen(request) as result:
input_stream = Gio.MemoryInputStream.new_from_data(result.read(), None)
self._original_pixbuf = GdkPixbuf.Pixbuf.new_from_stream(input_stream, None)
elif os.path.isabs(self.image.path):
self._original_pixbuf = GdkPixbuf.Pixbuf.new_from_file(self.image.path)
full_image_path = self.image.path if os.path.isabs(self.image.path) else os.path.join(toga.App.app_dir, self.image.path)
if os.path.isfile(full_image_path):
self._original_pixbuf = GdkPixbuf.Pixbuf.new_from_file)
else:
self._original_pixbuf = GdkPixbuf.Pixbuf.new_from_file(os.path.join(toga.App.app_dir, self.image.path))

raise ValueError("No image file available at ", path)
self.rehint()

def rehint(self):
Expand Down

0 comments on commit 2e2cee9

Please sign in to comment.