# This file is part of the Coral project.
# Please read the copyright notice in the LICENSE file.

import coral
import coral.modeler.extension
import coral.modeler.dlg.DebugBrowserDlg
import qt

class DebugBrowser(coral.modeler.dlg.DebugBrowserDlg.DebugBrowserDlg,
                   coral.modeler.extension.ModelerTool):
    def __init__(self, parent):
        coral.modeler.extension.ModelerTool.__init__(self)
        coral.modeler.dlg.DebugBrowserDlg.DebugBrowserDlg.__init__(self, parent)
        self.debugtext.setReadOnly(True)
        self.doIt()

    def doIt(self):
        coral.setDebugObserver(self.observerFromKernel)
        self.observerFromKernel()

    def close(self,x=0):
        coral.setDebugObserver(None)
        return coral.modeler.dlg.DebugBrowserDlg.DebugBrowserDlg.close(self,x)
        
    def observerFromKernel(self):
        s = coral.getDebugLog()
        self.debugtext.append(s)

