Changeset 11292:136a860daa67 in orange


Ignore:
Timestamp:
01/29/13 13:27:22 (15 months ago)
Author:
Ales Erjavec <ales.erjavec@…>
Branch:
default
Message:

OWBaseWidget cleanup/compatibility.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • Orange/OrangeWidgets/OWBaseWidget.py

    r11269 r11292  
    2222from OWContexts import * 
    2323import sys, time, random, user, os, os.path, cPickle, copy 
     24import logging 
     25 
    2426import orange 
    2527from Orange import misc 
     
    4042 
    4143 
     44_log = logging.getLogger(__name__) 
     45 
    4246ERROR = 0 
    4347WARNING = 1 
    4448 
    45 TRUE=1 
    46 FALSE=0 
     49TRUE = 1 
     50FALSE = 0 
    4751 
    4852 
     
    116120 
    117121 
    118  
    119 ################## 
    120 # this definitions are needed only to define ExampleTable as subclass of ExampleTableWithClass 
    121122from orange import ExampleTable 
    122123 
     
    132133    def __new__(cls, *arg, **args): 
    133134        self = QDialog.__new__(cls) 
    134          
    135         #print "arg", arg 
    136         #print "args: ", args 
     135 
    137136        self.currentContexts = {}   # the "currentContexts" MUST be the first thing assigned to a widget 
    138137        self._useContexts = 1       # do you want to use contexts 
     
    406405 
    407406    def send(self, signalName, value, id = None): 
    408 #        if not self.hasOutputName(signalName): 
    409 #            print "Warning! Signal '%s' is not a valid signal name for the '%s' widget. Please fix the signal name." % (signalName, self.captionTitle) 
    410  
    411407        if self.linksOut.has_key(signalName): 
    412408            self.linksOut[signalName][id] = value 
     
    414410            self.linksOut[signalName] = {id:value} 
    415411 
    416         self.signalManager.send(self, signalName, value, id) 
    417  
     412        if self.signalManager is not None: 
     413            self.signalManager.send(self, signalName, value, id) 
    418414 
    419415    def getdeepattr(self, attr, **argkw): 
     
    792788        self.widgetStateHandler = handler 
    793789 
    794  
    795790    # if we are in debug mode print the event into the file 
    796     def printEvent(self, text, eventVerbosity = 1): 
    797         self.signalManager.addEvent(self.captionTitle + ": " + text, eventVerbosity = eventVerbosity) 
     791    def printEvent(self, text, eventVerbosity=1): 
     792        text = self.captionTitle + ": " + text 
     793 
     794        if eventVerbosity > 0: 
     795            _log.debug(text) 
     796        else: 
     797            _log.info(text) 
     798 
    798799        if self.eventHandler: 
    799             self.eventHandler(self.captionTitle + ": " + text, eventVerbosity) 
     800            self.eventHandler(text, eventVerbosity) 
    800801 
    801802    def openWidgetHelp(self): 
    802803        if "widgetInfo" in self.__dict__:  # This widget is on a canvas. 
    803804            qApp.canvasDlg.helpWindow.showHelpFor(self.widgetInfo, True) 
    804          
    805     def focusInEvent(self, *ev): 
    806         #print "focus in" 
    807         #if qApp.canvasDlg.settings["synchronizeHelp"]:  on ubuntu: pops up help window on first widget focus for every widget    
    808         #    qApp.canvasDlg.helpWindow.showHelpFor(self, True) 
    809         QDialog.focusInEvent(self, *ev) 
    810          
    811      
     805 
    812806    def keyPressEvent(self, e): 
    813807        if e.key() in (Qt.Key_Help, Qt.Key_F1): 
     
    819813            QDialog.keyPressEvent(self, e) 
    820814 
    821     def information(self, id = 0, text = None): 
     815    def information(self, id=0, text=None): 
    822816        self.setState("Info", id, text) 
    823         #self.setState("Warning", id, text) 
    824  
    825     def warning(self, id = 0, text = ""): 
     817 
     818    def warning(self, id=0, text=""): 
    826819        self.setState("Warning", id, text) 
    827         #self.setState("Info", id, text)        # if we want warning just set information 
    828  
    829     def error(self, id = 0, text = ""): 
     820 
     821    def error(self, id=0, text=""): 
    830822        self.setState("Error", id, text) 
    831823 
     
    838830                    changed = 1 
    839831        else: 
    840             if type(id) == str: 
    841                 text = id; id = 0       # if we call information(), warning(), or error() function with only one parameter - a string - then set id = 0 
     832            if isinstance(id, basestring): 
     833                # if we call information(), warning(), or error() function 
     834                # with only one parameter - a string - then set id = 0 
     835                text = id 
     836                id = 0 
    842837            if not text: 
    843838                if self.widgetState[stateType].has_key(id): 
     
    949944            (Qt.ControlModifier, Qt.Key_W): lambda self: self.setVisible(not self.isVisible())} 
    950945 
    951  
    952946    def scheduleSignalProcessing(self): 
    953         self.signalManager.scheduleSignalProcessing(self) 
     947        """ 
     948        Schedule signal processing by the signal manager. 
     949 
     950        ..note:: The processing is already scheduled at the most appropriate 
     951                 time so you should have few uses for this method. 
     952        """ 
     953        if self.signalManager is not None: 
     954            self.signalManager.scheduleSignalProcessing(self) 
    954955 
    955956    def setBlocking(self, state=True): 
Note: See TracChangeset for help on using the changeset viewer.