Orange Forum • View topic - Errors in OWidgets

Errors in OWidgets

A place to ask questions about methods in Orange and how they are used and other general support.

Errors in OWidgets

Postby Petra.Kralj » Fri Nov 04, 2005 16:45


I am programming some Orange Widgets and I don't know how are
they supposed to handle errors.

What should a widget do if it gets continuous data on ist input, but it
processes only discrete data?

Thanks for your answer in advance.


Postby Gregor Leban » Tue Nov 08, 2005 20:31

There are many ways you can report such an event.

One way is to use the error function that displays a red triangle above the widget icon in the Orange Canvas. To use it you would add something like this in your function that handles new data:

Code: Select all
def data(self, data):
    if data.domain.classVar.varType != orange.VarTypes.Discrete: # or some other condition
            self.error("Can only handle data sets with discrete class value.")
            self.error()    # this will remove the error icon if it exists

Another way is to call QMessageBox function, that displays a message box. the problem with this function is that until you close the message box, the processing of other events is stopped. For an example how to use QMessageBox you can look in in the Visualize folder of orange widgets.

If you don't like any of the above solutions you can also try adding a statusbar in your widget and print there some text if you can't handle your data set. To create a status bar in your widget you just set the wantStatusBar to 1 when calling OWWidget.__init__ . To set the text in this statusbar you just call self.setStatusBarText(text).

I hope this helps.

Best regards,

Return to Questions & Support