Changeset 4964:0673c7d5912b in orange


Ignore:
Timestamp:
07/14/08 13:40:49 (6 years ago)
Author:
gregor <gregor@…>
Branch:
default
Convert:
64f7724524c0631258e0aa41b5a79a56b99109b7
Message:
  • removed activateLoadedSettings
  • added new constructor to basewidget
Location:
orange/OrangeWidgets
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • orange/OrangeWidgets/OWBaseWidget.py

    r4883 r4964  
    103103 
    104104class OWBaseWidget(QDialog): 
    105     def __init__(self, parent = None, signalManager = None, title="Orange BaseWidget", modal=FALSE, savePosition = False, resizingEnabled = 1, **args): 
    106         # the "currentContexts" MUST be the first thing assigned to a widget 
    107         self.currentContexts = {} 
    108         self._guiElements = []      # used for automatic widget debugging 
     105    def __new__(cls, *arg, **args): 
     106        self = QDialog.__new__(cls) 
     107 
     108        #print "arg", arg 
     109        #print "args: ", args 
     110        self.currentContexts = {}   # the "currentContexts" MUST be the first thing assigned to a widget 
    109111        self._useContexts = 1       # do you want to use contexts 
    110112        self._owInfo = 1            # currently disabled !!! 
     
    112114        self._owError = 1           # do we want to see errors 
    113115        self._owShowStatus = 0      # do we want to see warnings and errors in status bar area of the widget 
    114  
     116        self._guiElements = []      # used for automatic widget debugging 
     117        for key in args: 
     118            if key in ["_owInfo", "_owWarning", "_owError", "_owShowStatus", "_useContexts", "_category", "_settingsFromSchema"]: 
     119                self.__dict__[key] = args[key]        # we cannot use __dict__.update(args) since we can have many other 
     120 
     121        return self 
     122 
     123 
     124    def __init__(self, parent = None, signalManager = None, title="Orange BaseWidget", modal=FALSE, savePosition = False, resizingEnabled = 1, **args): 
    115125        # do we want to save widget position and restore it on next load 
    116126        self.savePosition = savePosition 
     
    124134        self.__dict__.update(orngOrangeFoldersQt4.directoryNames) 
    125135 
    126         title = title.replace("&","") 
    127         self.setCaption(title) # used for widget caption 
     136        self.setCaption(title.replace("&","")) # used for widget caption 
    128137 
    129138        # number of control signals, that are currently being processed 
     
    167176    def setWidgetIcon(self, iconName): 
    168177        if os.path.exists(iconName): 
    169             self.setWindowIcon(QIcon(iconName)) 
     178            pass 
    170179        elif os.path.exists(os.path.join(self.widgetDir, iconName)): 
    171             self.setWindowIcon(QIcon(os.path.join(self.widgetDir, iconName))) 
     180            iconName = os.path.join(self.widgetDir, iconName) 
    172181        elif os.path.exists(os.path.join(self.widgetDir, "icons/" + iconName)): 
    173             self.setWindowIcon(QIcon(os.path.join(self.widgetDir, "icons/" + iconName))) 
     182            iconName = os.path.join(self.widgetDir, "icons/" + iconName) 
    174183        elif os.path.exists(os.path.join(os.path.dirname(sys.modules[self.__module__].__file__), "icons/" + iconName)):        # search for icons also in the folder where the module is 
    175             self.setWindowIcon(QIcon(os.path.join(os.path.dirname(sys.modules[self.__module__].__file__), "icons/" + iconName))) 
     184            iconName = os.path.join(os.path.dirname(sys.modules[self.__module__].__file__), "icons/" + iconName) 
    176185        elif os.path.exists(os.path.join(self.widgetDir, "icons/Unknown.png")): 
    177             self.setWindowIcon(QIcon(os.path.join(self.widgetDir, "icons/Unknown.png"))) 
     186            iconName = os.path.join(self.widgetDir, "icons/Unknown.png") 
     187             
     188        frame = QPixmap(os.path.join(self.widgetDir, "icons/frame.png")) 
     189        icon = QPixmap(iconName) 
     190        result = QPixmap(icon.size()) 
     191        painter = QPainter() 
     192        painter.begin(result) 
     193        painter.drawPixmap(0,0, frame) 
     194        painter.drawPixmap(0,0, icon) 
     195        painter.end() 
     196        self.setWindowIcon(QIcon(result)) 
     197         
    178198 
    179199    # ############################################## 
     
    334354            except: 
    335355                settings = None 
     356 
     357            if hasattr(self, "_settingsFromSchema"): 
     358                if settings: settings.update(self._settingsFromSchema) 
     359                else:        settings = self._settingsFromSchema 
    336360 
    337361            # can't close everything into one big try-except since this would mask all errors in the below code 
     
    624648#            try: 
    625649#                import win32help 
    626 #                if win32help.HtmlHelp(0, "%s/doc/catalog.chm::/catalog/%s/%s.htm" % (orangedir, self.category, self.__class__.__name__[2:]), win32help.HH_DISPLAY_TOPIC): 
     650#                if win32help.HtmlHelp(0, "%s/doc/catalog.chm::/catalog/%s/%s.htm" % (orangedir, self._category, self.__class__.__name__[2:]), win32help.HH_DISPLAY_TOPIC): 
    627651#                    return 
    628652#            except: 
     
    631655            try: 
    632656                import webbrowser 
    633                 webbrowser.open("file://%s/doc/widgets/catalog/%s/%s.htm" % (orangedir, self.category, self.__class__.__name__[2:]), 0, 1) 
     657                webbrowser.open("file://%s/doc/widgets/catalog/%s/%s.htm" % (orangedir, self._category, self.__class__.__name__[2:]), 0, 1) 
    634658                return 
    635659            except: 
     
    638662        try: 
    639663            import webbrowser 
    640             webbrowser.open("http://www.ailab.si/orange/doc/widgets/catalog/%s/%s.htm" % (self.category, self.__class__.__name__[2:])) 
     664            webbrowser.open("http://www.ailab.si/orange/doc/widgets/catalog/%s/%s.htm" % (self._category, self.__class__.__name__[2:])) 
    641665            return 
    642666        except: 
     
    741765if __name__ == "__main__": 
    742766    a=QApplication(sys.argv) 
    743     oww=OWBaseWidget() 
     767    oww=OWBaseWidget(adfaf=1) 
    744768    oww.show() 
    745769    a.exec_() 
  • orange/OrangeWidgets/OWFreeVizOptimization.py

    r4883 r4964  
    128128            OWGUI.rubber(self.LinearTransformationTab) 
    129129 
    130  
    131         self.resize(320,650) 
    132         #self.setMinimumWidth(310) 
    133         #self.tabs.setMinimumWidth(310) 
    134  
    135 ##        self.parentWidget.learnersArray[3] = S2NHeuristicLearner(self, self.parentWidget) 
    136         self.activateLoadedSettings() 
    137  
    138  
    139     def activateLoadedSettings(self): 
    140130        self.forceLawChanged() 
    141131        self.updateForces() 
    142132        self.cbforcebal.setDisabled(self.cbDisableAttractive.isChecked() or self.cbDisableRepulsive.isChecked()) 
     133        self.resize(320,650) 
     134##        self.parentWidget.learnersArray[3] = S2NHeuristicLearner(self, self.parentWidget) 
     135 
    143136 
    144137    # ############################################################## 
  • orange/OrangeWidgets/OWkNNOptimization.py

    r4919 r4964  
    17371737##    ow = OWInteractionAnalysis() 
    17381738##    ow = OWGraphAttributeHistogram() 
    1739     a.setMainWidget(ow) 
    17401739    ow.show() 
    17411740    a.exec_() 
Note: See TracChangeset for help on using the changeset viewer.