Skip to content

Commit

Permalink
Image Viewer: Improve error messages
Browse files Browse the repository at this point in the history
  • Loading branch information
janezd committed May 22, 2024
1 parent 07ba906 commit 7b9b99d
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions orangecontrib/imageanalytics/widgets/owimageviewer.py
Original file line number Diff line number Diff line change
Expand Up @@ -218,14 +218,16 @@ class Outputs:
selected_data = Output("Selected Images", Orange.data.Table)
data = Output("Data", Orange.data.Table)

class Error(OWWidget.Error):
class Warning(OWWidget.Warning):
no_images_shown = Msg(
"Unable to display images! Please ensure that the chosen "
"Image Filename Attribute store the correct paths to the images."
"Unable to display images. Check that the chosen "
"Image Filename Attribute stores correct paths to images."
)
no_image_attr = Msg(
"Data does not contain any variables with image names.\n"
"Numeric variables cannot store image names."

class Error(OWWidget.Error):
no_image_attr = Msg(
"Data does not contain any variables with image file names or URLs.\n"
"Data contains no text variables."
)

settingsHandler = settings.DomainContextHandler()
Expand Down Expand Up @@ -350,7 +352,7 @@ def _propose_image_and_title_attr(self):

def clear(self):
self.data = None
self.Error.no_images_shown.clear()
self.Warning.no_images_shown.clear()
self.Error.no_image_attr.clear()
if self.__watcher is not None:
self.__watcher.finishedAt.disconnect(self.__on_load_finished)
Expand All @@ -364,7 +366,7 @@ def clear(self):
self.selected_items = set()

def setupModel(self):
self.Error.no_images_shown.clear()
self.Warning.no_images_shown.clear()
if self.data is not None:
urls = column_data_as_qurl(self.data, self.image_attr)
titles = column_data_as_str(self.data, self.title_attr)
Expand Down Expand Up @@ -479,7 +481,7 @@ def commit(self):
def _updateStatus(self):
count = len([item for item in self.items if item.future is not None])
if self._errcount == count:
self.Error.no_images_shown()
self.Warning.no_images_shown()

def onDeleteWidget(self):
self.clear()
Expand Down

0 comments on commit 7b9b99d

Please sign in to comment.