Changeset 10966:7ea3b3f2e9b2 in orange


Ignore:
Timestamp:
08/16/12 15:30:43 (20 months ago)
Author:
Ales Erjavec <ales.erjavec@…>
Branch:
default
Message:

Replaced 'OWReport.report' references with 'OWReport.get_instance()'.

This returns 'qApp.canvasDlg.reportWindow' if present (see #1226).

Location:
Orange/OrangeWidgets
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • Orange/OrangeWidgets/OWReport.py

    r10580 r10966  
    2929 
    3030report = None 
     31 
     32 
     33def get_instance(): 
     34    """Return the global ReportWindow instance or None if it was not yet 
     35    initialized. 
     36 
     37    """ 
     38    if hasattr(qApp, "canvasDlg") and hasattr(qApp.canvasDlg, "reportWindow"): 
     39        return qApp.canvasDlg.reportWindow 
     40    else: 
     41        return report 
     42 
     43 
    3144def escape(s): 
    3245    return s.replace("\\", "\\\\").replace("\n", "\\n").replace("'", "\\'") 
  • Orange/OrangeWidgets/OWWidget.py

    r10209 r10966  
    5858 
    5959        self.__reportData = None 
    60         if OWReport.report and not noReport and hasattr(self, "sendReport"): 
     60        if OWReport.get_instance() and not noReport and hasattr(self, "sendReport"): 
    6161            self.buttonBackground.show() 
    6262            self.reportButton = OWGUI.button(self.buttonBackground, self, "&Report", self.reportAndFinish, debuggingEnabled=0) 
     
    177177        self.__reportData = "" 
    178178        if needDirectory: 
    179             return OWReport.report.createDirectory() 
     179            return OWReport.get_instance().createDirectory() 
    180180        else: 
    181181            return True 
     
    200200 
    201201    def getUniqueFileName(self, patt): 
    202         return OWReport.report.getUniqueFileName(patt) 
     202        return OWReport.get_instance().getUniqueFileName(patt) 
    203203 
    204204    def getUniqueImageName(self, nm="img", ext=".png"): 
    205         return OWReport.report.getUniqueFileName(nm + "%06i" + ext) 
     205        return OWReport.get_instance().getUniqueFileName(nm + "%06i" + ext) 
    206206 
    207207    def reportImage(self, filenameOrFunc, *args): 
     
    288288    def finishReport(self): 
    289289        if self.__reportData is not None: 
    290             OWReport.report(self.reportName, self.__reportData or "", self.widgetId, self.windowIcon())#, self.getSettings(False)) 
     290            OWReport.get_instance()(self.reportName, self.__reportData or "", self.widgetId, self.windowIcon())#, self.getSettings(False)) 
    291291            self.__reportData = None 
    292292 
Note: See TracChangeset for help on using the changeset viewer.