source: orange/orange/OrangeCanvas/orngHelp.py @ 8042:ffcb93bc9028

Revision 8042:ffcb93bc9028, 1.9 KB checked in by markotoplak, 3 years ago (diff)

Hierarchical clustering: also catch RuntimeError when importing matplotlib (or the documentation could not be built on server).

Line 
1from PyQt4.QtCore import *
2from PyQt4.QtGui import *
3from PyQt4.QtWebKit import *
4import os
5
6class HelpWindow(QDialog):
7    def __init__(self, canvasDlg):
8        QDialog.__init__(self)
9        self.setWindowTitle("Orange Canvas Help")
10        self.canvasDlg = canvasDlg
11       
12        self.setWindowIcon(QIcon(os.path.join(self.canvasDlg.widgetDir, "icons/Unknown.png")))
13
14
15        self.setLayout(QVBoxLayout())
16        self.layout().setMargin(2)       
17#===============================================================================
18#        hbox = QWidget(self)
19#        self.layout().addWidget(hbox)
20#        hbox.setLayout(QHBoxLayout())
21#        cb = QCheckBox(self)
22#        cb.setChecked(canvasDlg.settings["synchronizeHelp"])
23#        self.connect(cb, SIGNAL("stateChanged(int)"), self.synchronizeHelpClicked)
24#        hbox.layout().addWidget(cb)
25#        hbox.layout().addWidget(QLabel("Show context sensitive help", self))
26#        hbox.layout().addStretch(100)
27#===============================================================================
28       
29        self.helpBrowser = QWebView(self)
30        self.layout().addWidget(self.helpBrowser)
31       
32    def showHelpFor(self, widgetInfo, bringToFront=False):
33        helpFileName = os.path.join(widgetInfo.docDir(), "%s.htm" % (widgetInfo.fileName[2:])).replace("\\", "/")
34        if not os.path.exists(helpFileName):
35            QMessageBox.warning( None, "Not available", "Sorry, there is no documentation available for this widget.", QMessageBox.Ok)
36            return
37        self.open("file:///"+helpFileName)
38           
39    def open(self, url, bringToFront=False, modal=False):
40        self.helpBrowser.load(QUrl(url))
41        if modal:
42            self.exec_()
43        else:
44            self.show()
45            if bringToFront:
46                self.raise_()
47
48    def synchronizeHelpClicked(self, st):
49        canvasDlg.settings["synchronizeHelp"] = st == Qt.Checked
Note: See TracBrowser for help on using the repository browser.