Example #1
0
 def __init__(self):
     super(WebRender, self).__init__()
     vbox, temporary_directory = QVBoxLayout(self), mkdtemp()
     # Web Frame
     self.webFrame = QWebView()  # QWebView = QWebFrame + QWebSettings
     self.webFrame.setStyleSheet(
         "QWebView{ background:#fff }")  # no dark bg
     settings = self.webFrame.settings()  # QWebSettings instance
     settings.setDefaultTextEncoding("utf-8")
     settings.setIconDatabasePath(temporary_directory)
     settings.setLocalStoragePath(temporary_directory)
     settings.setOfflineStoragePath(temporary_directory)
     settings.setOfflineWebApplicationCachePath(temporary_directory)
     settings.setAttribute(QWebSettings.DeveloperExtrasEnabled, True)
     settings.setAttribute(QWebSettings.LocalStorageEnabled, True)
     settings.setAttribute(QWebSettings.OfflineStorageDatabaseEnabled, True)
     settings.setAttribute(QWebSettings.PluginsEnabled, True)
     settings.setAttribute(QWebSettings.DnsPrefetchEnabled, True)
     settings.setAttribute(QWebSettings.JavascriptCanOpenWindows, True)
     settings.setAttribute(QWebSettings.JavascriptCanCloseWindows, True)
     settings.setAttribute(QWebSettings.JavascriptCanAccessClipboard, True)
     settings.setAttribute(QWebSettings.SpatialNavigationEnabled, True)
     settings.setAttribute(QWebSettings.LocalContentCanAccessRemoteUrls,
                           True)
     settings.setAttribute(QWebSettings.OfflineWebApplicationCacheEnabled,
                           True)
     vbox.addWidget(self.webFrame)
Example #2
0
    def __init__(self,parent = None):
        QWebView.__init__(self,parent)
        self.page().setLinkDelegationPolicy(QWebPage.DontDelegateLinks)
        self.page().setContentEditable(True)
        

        QObject.connect(self, SIGNAL("loadFinished(bool)"), self.__evt_loadFinished)
        QObject.connect(self, SIGNAL("insertHTML(QString &)"), self.__evt_self_insert)
        QObject.connect(self, SIGNAL("changeColor(QString &,QString &)"), self.__evt_self_changecolor)
        
        self.__initActions()
Example #3
0
    def __init__(self, parent=None):
        QWebView.__init__(self, parent)
        self.page().setLinkDelegationPolicy(QWebPage.DontDelegateLinks)
        self.page().setContentEditable(True)

        QObject.connect(self, SIGNAL("loadFinished(bool)"),
                        self.__evt_loadFinished)
        QObject.connect(self, SIGNAL("insertHTML(QString &)"),
                        self.__evt_self_insert)
        QObject.connect(self, SIGNAL("changeColor(QString &,QString &)"),
                        self.__evt_self_changecolor)

        self.__initActions()
Example #4
0
    def __init__(self, url, process=None, parent=None):
        QWidget.__init__(self, parent)
        self._process = process
        vbox = QVBoxLayout(self)
        #Web Frame
        self.webFrame = QWebView(self)
        self.webFrame.setAcceptDrops(False)

        self.webFrame.load(QUrl(url))

        vbox.addWidget(self.webFrame)

        if process is not None:
            time.sleep(0.5)
            self.webFrame.load(QUrl(url))

        self.webFrame.page().currentFrame().setScrollBarPolicy(
            Qt.Vertical, Qt.ScrollBarAsNeeded)
        self.webFrame.page().currentFrame().setScrollBarPolicy(
            Qt.Horizontal, Qt.ScrollBarAsNeeded)
Example #5
0
    def __init__(self, parent):
        """
        Descript. :
        """
        QWidget.__init__(self, parent)

        self.home_url = None

        self.navigation_bar = QWidget(self)
        self.url_ledit = QLineEdit(self.navigation_bar)
        self.url_ledit.setReadOnly(True)
        self.home_button = QPushButton(self.navigation_bar)
        self.back_button = QPushButton(self.navigation_bar)
        self.forward_button = QPushButton(self.navigation_bar)

        self.home_button.setIcon(Qt4_Icons.load_icon("Home2"))
        self.back_button.setIcon(Qt4_Icons.load_icon("Left2"))
        self.forward_button.setIcon(Qt4_Icons.load_icon("Right2"))

        if QWEBVIEW_AVAILABLE:
            self.web_page_viewer = QWebView(self)
            self.web_page_viewer.settings().setObjectCacheCapacities(0, 0, 0)
        else:
            self.web_page_viewer = QTextBrowser(self)

        _navigation_bar_hlayout = QHBoxLayout(self.navigation_bar)
        _navigation_bar_hlayout.addWidget(self.home_button)
        _navigation_bar_hlayout.addWidget(self.back_button)
        _navigation_bar_hlayout.addWidget(self.forward_button)
        _navigation_bar_hlayout.addWidget(self.url_ledit)
        _navigation_bar_hlayout.setSpacing(2)
        _navigation_bar_hlayout.setContentsMargins(2, 2, 2, 2)

        _main_vlayout = QVBoxLayout(self)
        _main_vlayout.addWidget(self.navigation_bar)
        _main_vlayout.addWidget(self.web_page_viewer)
        _main_vlayout.setSpacing(2)
        _main_vlayout.setContentsMargins(2, 2, 2, 2)

        self.web_page_viewer.setSizePolicy(QSizePolicy.Expanding,
                                           QSizePolicy.Expanding)

        self.home_button.clicked.connect(self.go_to_home_page)
        self.back_button.clicked.connect(self.go_back)
        self.forward_button.clicked.connect(self.go_forward)
Example #6
0
def print_pdf(html, destination):
	#app = QApplication(sys.argv)
 
	web = QWebView()
	web.setHtml(html)
	#app = QApplication.instance()
	#app.processEvents()
 
	printer = QPrinter()
	printer.setPageSize(QPrinter.A4)
	printer.setOutputFormat(QPrinter.PdfFormat)
	printer.setOutputFileName(destination)
	web.print_(printer)
 
	app.exit()
Example #7
0
class WebRender(QWidget):
    """Render a web page inside the tools dock area."""
    def __init__(self):
        super(WebRender, self).__init__()
        vbox, temporary_directory = QVBoxLayout(self), mkdtemp()
        # Web Frame
        self.webFrame = QWebView()  # QWebView = QWebFrame + QWebSettings
        self.webFrame.setStyleSheet(
            "QWebView{ background:#fff }")  # no dark bg
        settings = self.webFrame.settings()  # QWebSettings instance
        settings.setDefaultTextEncoding("utf-8")
        settings.setIconDatabasePath(temporary_directory)
        settings.setLocalStoragePath(temporary_directory)
        settings.setOfflineStoragePath(temporary_directory)
        settings.setOfflineWebApplicationCachePath(temporary_directory)
        settings.setAttribute(QWebSettings.DeveloperExtrasEnabled, True)
        settings.setAttribute(QWebSettings.LocalStorageEnabled, True)
        settings.setAttribute(QWebSettings.OfflineStorageDatabaseEnabled, True)
        settings.setAttribute(QWebSettings.PluginsEnabled, True)
        settings.setAttribute(QWebSettings.DnsPrefetchEnabled, True)
        settings.setAttribute(QWebSettings.JavascriptCanOpenWindows, True)
        settings.setAttribute(QWebSettings.JavascriptCanCloseWindows, True)
        settings.setAttribute(QWebSettings.JavascriptCanAccessClipboard, True)
        settings.setAttribute(QWebSettings.SpatialNavigationEnabled, True)
        settings.setAttribute(QWebSettings.LocalContentCanAccessRemoteUrls,
                              True)
        settings.setAttribute(QWebSettings.OfflineWebApplicationCacheEnabled,
                              True)
        vbox.addWidget(self.webFrame)

    def render_page(self, url):
        """Render a web page from a local file."""
        self.webFrame.load(QUrl('file:///' + url))

    def render_from_html(self, html, url=None):
        """Render a webpage from a string."""
        url = url and QUrl(url) or ""
        self.webFrame.setHtml(html, url)
Example #8
0
    def __init__(self,parent = None):
        QWebView.__init__(self,parent)
        
        self.__initActions()

        QObject.connect(self.page().networkAccessManager(),SIGNAL("finished (QNetworkReply *)"),self.__evt_networkfinished)
Example #9
0
class BrowserWidget(QWidget):

    ###############################################################################
    # RecentProjectItem SIGNALS
    ###############################################################################
    """
    openProject(QString)
    openPreferences()
    dontOpenStartPage()
    """

    ###############################################################################

    def __init__(self, url, process=None, parent=None):
        QWidget.__init__(self, parent)
        self._process = process
        vbox = QVBoxLayout(self)
        #Web Frame
        self.webFrame = QWebView(self)
        self.webFrame.setAcceptDrops(False)

        self.webFrame.load(QUrl(url))

        vbox.addWidget(self.webFrame)

        if process is not None:
            time.sleep(0.5)
            self.webFrame.load(QUrl(url))

        self.webFrame.page().currentFrame().setScrollBarPolicy(
            Qt.Vertical, Qt.ScrollBarAsNeeded)
        self.webFrame.page().currentFrame().setScrollBarPolicy(
            Qt.Horizontal, Qt.ScrollBarAsNeeded)

    def start_page_operations(self, url):
        opt = file_manager.get_basename(url.toString())
        self.emit(SIGNAL(opt))

    def shutdown_pydoc(self):
        if self._process is not None:
            self._process.kill()

    def find_match(self, word, back=False, sensitive=False, whole=False):
        self.webFrame.page().findText(word)