Exemplo n.º 1
0
    def __init__(self, URL, process=None, main=None):
        QWidget.__init__(self)
        BaseCentralWidget.__init__(self)
        self.path = URL
        self.process = process

        v_box = QVBoxLayout(self)
        #Web Frame
        QWebSettings.globalSettings().setAttribute(QWebSettings.PluginsEnabled,
                                                   True)
        self.webFrame = QWebView()
        self.webFrame.setAcceptDrops(False)
        factory = WebPluginFactory(self, main)
        self.webFrame.page().setPluginFactory(factory)
        self.webFrame.load(QUrl(URL))

        v_box.addWidget(self.webFrame)

        if process is not None:
            time.sleep(0.5)
            self.webFrame.reload()

        if self.path.endswith(
                'startPage.html') and sys.platform.find('win') != -1:
            content = manage_files.read_file_content(self.path)
            pathCss = os.path.join(resources.PRJ_PATH, 'doc', 'styles',
                                   'ninja.css')
            pathJs = os.path.join(resources.PRJ_PATH, 'doc', 'rsc')
            content = content.replace('styles/ninja.css',
                                      pathCss).replace('src="rsc',
                                                       'src="' + pathJs)
            self.webFrame.setHtml(content)
Exemplo n.º 2
0
    def __init__(self, URL, process=None, main=None):
        QWidget.__init__(self)
        BaseCentralWidget.__init__(self)
        self.path = URL
        self.process = process

        v_box = QVBoxLayout(self)
        #Web Frame
        QWebSettings.globalSettings().setAttribute(QWebSettings.PluginsEnabled, True)
        self.webFrame = QWebView()
        self.webFrame.setAcceptDrops(False)
        factory = WebPluginFactory(self, main)
        self.webFrame.page().setPluginFactory(factory)
        self.webFrame.load(QUrl(URL))

        v_box.addWidget(self.webFrame)

        if process is not None:
            time.sleep(0.5)
            self.webFrame.reload()

        if self.path.endswith('startPage.html') and sys.platform.find('win') != -1:
            content = manage_files.read_file_content(self.path)
            pathCss = os.path.join(resources.PRJ_PATH, 'doc', 'styles', 'ninja.css')
            pathJs = os.path.join(resources.PRJ_PATH, 'doc', 'rsc')
            content = content.replace('styles/ninja.css', pathCss).replace('src="rsc', 'src="' + pathJs)
            self.webFrame.setHtml(content)
Exemplo n.º 3
0
def main():
    if len(sys.argv) == 2:
        appid = sys.argv[1]
        app = QtSingleApplication(appid, [appid] + sys.argv[2:])
        if app.isRunning():
            sys.exit(0)
        errors.app = app
        desktopEntry = desktop.getEntry(appid)

        if desktopEntry.get('X-%s-plugins' % APP_NAME) == '1':
            QWebSettings.globalSettings().setAttribute(
                QWebSettings.PluginsEnabled, True)

        w = BrowserWindow(appid, desktopEntry.getBaseUrl(),
                          desktopEntry.getName())
    else:
        appGuid = '3a34b884-8ab4-4a60-a243-dae69928a82e'
        app = QtSingleApplication(appGuid, ['Webplier'] + sys.argv[2:])
        if app.isRunning():
            sys.exit(0)
        w = SiteListWindow()
    w.show()
    app.setActivationWindow(w)

    sys.exit(app.exec_())
Exemplo n.º 4
0
    def __init__(self):
        QWidget.__init__(self)

        vbox = QVBoxLayout(self)
        # Web Frame
        self.webFrame = QWebView()
        QWebSettings.globalSettings().setAttribute(QWebSettings.DeveloperExtrasEnabled, True)
        vbox.addWidget(self.webFrame)
Exemplo n.º 5
0
 def __init__(self, view: Amendment('view/', lambda v: hasattr(v, 'mode') and (v.mode.name == 'web') and (v.widget is None))): #, orig_editor=None):
     self.view = view
     QWebView.__init__(self)
     view.widget = self
     self.load(QUrl(view.filebuf.file_name))
     self.page().setContentEditable(True)
     QNetworkProxyFactory.setUseSystemConfiguration(True);
     QWebSettings.globalSettings().setAttribute(QWebSettings.PluginsEnabled, True);
     QWebSettings.globalSettings().setAttribute(QWebSettings.AutoLoadImages, True);
Exemplo n.º 6
0
    def __init__(self):
        QWidget.__init__(self)

        vbox = QVBoxLayout(self)
        #Web Frame
        self.webFrame = QWebView()
        QWebSettings.globalSettings().setAttribute(
            QWebSettings.DeveloperExtrasEnabled, True)
        vbox.addWidget(self.webFrame)
Exemplo n.º 7
0
Arquivo: main.py Projeto: chozabu/PyIM
def main():  
	app = QtGui.QApplication(sys.argv)  
	QWebSettings.globalSettings().setAttribute(QWebSettings.DeveloperExtrasEnabled, True);
	
	myObj = QtJsBridge()
	
	webView = QtWebKit.QWebView()  
	# Make myObj exposed as JavaScript object named 'pyObj'
	webView.page().mainFrame().addToJavaScriptWindowObject("pyObj", myObj)
	myObj.mainframe=webView.page().mainFrame()
	webView.setHtml(html)  
	
	window = QtGui.QMainWindow()  
	window.setCentralWidget(webView)  
	window.show()  
	
	cf = json.load(open('config.json'))
	client = xmpp.Client(cf['login2'])
	client.connect(server=(cf['server'],int(cf['port'])))
	client.auth(cf['username'], cf['passwd'], 'botty')
	
	
	client.RegisterHandler('message', myObj.gotmsg)
	#client.RegisterHandler('chat', self.gotmsg)
	client.sendInitPresence()
	
	#need to call this later on too.
	roster =  client.getRoster()
	myObj.rkeys = [str(r) for r in roster.keys()]
	
	#give js obj access to send. could wrap in another method if paranoid :P
	myObj.send = client.send
	myObj.mainframe.evaluateJavaScript("getRoster();")
	
	#this get messages section could be improved, or replaced!
	global cancheckmsgs
	cancheckmsgs = True
	def checkmsgs():
		global cancheckmsgs
		if not cancheckmsgs: return
		cancheckmsgs = False
		socketlist = {client.Connection._sock:'xmpp',sys.stdin:'stdio'}
		
		(i , o, e) = select.select(socketlist.keys(),[],[],.01)
		for each in i:
			print each
			if socketlist[each] == 'xmpp':
				client.Process(.01)
		cancheckmsgs = True
	
	timer = QTimer()
	timer.timeout.connect(checkmsgs)
	timer.start(100)
	
	sys.exit(app.exec_())  
Exemplo n.º 8
0
 def show_help(self):
     html = resource_string("emzed.core.explorers", "help_peakmapexplorer.html")
     QWebSettings.globalSettings().setFontFamily(QWebSettings.StandardFont, 'Courier')
     QWebSettings.globalSettings().setFontSize(QWebSettings.DefaultFontSize, 12)
     v = QWebView(self)
     v.setHtml(html)
     dlg = QDialog(self, Qt.Window)
     dlg.setMinimumSize(300, 300)
     l = QVBoxLayout(dlg)
     l.addWidget(v)
     dlg.setLayout(l)
     dlg.show()
Exemplo n.º 9
0
    def __init__(self, *args, **kwargs):
        logging.debug('Starting __init__')
        self.url = kwargs['url']
        self.ghost = ghost.Ghost(wait_timeout=60)
        logging.debug('Created Ghost object')

        QWebSettings.globalSettings().setAttribute(QWebSettings.AutoLoadImages, False)
        QWebSettings.globalSettings().setAttribute(QWebSettings.PluginsEnabled, False)
        self.page, self.resources = self.ghost.open(self.url)
        self.frame = self.ghost.main_frame
        self.body = self.ghost.main_frame.findFirstElement('body')
        logging.debug('Fetched the page')
Exemplo n.º 10
0
 def show_help(self):
     html = resource_string("emzed.core.explorers", "help_peakmapexplorer.html")
     QWebSettings.globalSettings().setFontFamily(QWebSettings.StandardFont, 'Courier')
     QWebSettings.globalSettings().setFontSize(QWebSettings.DefaultFontSize, 12)
     v = QWebView(self)
     v.setHtml(html)
     dlg = QDialog(self, Qt.Window)
     dlg.setMinimumSize(300, 300)
     l = QVBoxLayout(dlg)
     l.addWidget(v)
     dlg.setLayout(l)
     dlg.show()
Exemplo n.º 11
0
 def webSettings(self):
     self.cookiesjar = PersistentCookieJar(self)
     self.zoom = self.readZoom()
     # Required by Youtube videos (HTML5 video support only on Qt5)
     QWebSettings.globalSettings().setAttribute(QWebSettings.PluginsEnabled, self.plugins)
     # We don't want Java
     QWebSettings.globalSettings().setAttribute(QWebSettings.JavaEnabled, False)
     # We don't need History
     QWebSettings.globalSettings().setAttribute(QWebSettings.PrivateBrowsingEnabled, True)
     # Required for copy and paste clipboard integration
     QWebSettings.globalSettings().setAttribute(QWebSettings.JavascriptCanAccessClipboard, True)
     # Enabling Inspeclet only when --debug=True (requires more CPU usage)
     QWebSettings.globalSettings().setAttribute(QWebSettings.DeveloperExtrasEnabled, self.debug)
Exemplo n.º 12
0
 def webSettings(self):
     self.cookiesjar = PersistentCookieJar(self)
     self.zoom = self.readZoom()
     # Required by Youtube videos (HTML5 video support only on Qt5)
     QWebSettings.globalSettings().setAttribute(QWebSettings.PluginsEnabled, self.plugins)
     # We don't want Java
     QWebSettings.globalSettings().setAttribute(QWebSettings.JavaEnabled, False)
     # We don't need History
     QWebSettings.globalSettings().setAttribute(QWebSettings.PrivateBrowsingEnabled, True)
     # Required for copy and paste clipboard integration
     QWebSettings.globalSettings().setAttribute(QWebSettings.JavascriptCanAccessClipboard, True)
     # Enabling Inspeclet only when --debug=True (requires more CPU usage)
     QWebSettings.globalSettings().setAttribute(QWebSettings.DeveloperExtrasEnabled, self.debug)
Exemplo n.º 13
0
    def __init__(self, url, process=None, parent=None):
        QWidget.__init__(self, parent)
        itab_item.ITabItem.__init__(self)
        self._id = url
        self._process = process
        vbox = QVBoxLayout(self)
        #Web Frame
        QWebSettings.globalSettings().setAttribute(QWebSettings.PluginsEnabled,
                                                   True)
        self.webFrame = QWebView(self)
        self.webFrame.setAcceptDrops(False)
        factory = WebPluginFactory(self)

        self.webFrame.page().setPluginFactory(factory)
        self.webFrame.load(QUrl(url))

        vbox.addWidget(self.webFrame)

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

        if url == resources.START_PAGE_URL:
            self.webFrame.page().setLinkDelegationPolicy(
                QWebPage.DelegateAllLinks)
            self.connect(self.webFrame, SIGNAL("linkClicked(QUrl)"),
                         self.start_page_operations)
            if sys.platform == "win32":
                content = file_manager.read_file_content(self.ID)
                pathCss = os.path.join(resources.PRJ_PATH, 'doc', 'css',
                                       'style.css')
                pathJs = os.path.join(resources.PRJ_PATH, 'doc', 'js', 'libs')
                pathImg = os.path.join(resources.PRJ_PATH, 'doc', 'img')
                content = content.replace('css/style.css', pathCss).replace(
                    'src="js/libs/',
                    'src="%s\\' % pathJs).replace('src="img/',
                                                  'src="%s\\' % pathImg)
                self.webFrame.setHtml(content)
            self._id = 'Start Page'
            policy = Qt.ScrollBarAlwaysOff
        else:
            policy = Qt.ScrollBarAsNeeded
        self.webFrame.page().currentFrame().setScrollBarPolicy(
            Qt.Vertical, policy)
        self.webFrame.page().currentFrame().setScrollBarPolicy(
            Qt.Horizontal, policy)
Exemplo n.º 14
0
    def __init__(self, url, process=None, parent=None):
        QWidget.__init__(self, parent)
        itab_item.ITabItem.__init__(self)
        self._id = url
        self._process = process
        vbox = QVBoxLayout(self)
        #Web Frame
        QWebSettings.globalSettings().setAttribute(
            QWebSettings.PluginsEnabled, True)
        self.webFrame = QWebView(self)
        self.webFrame.setAcceptDrops(False)
        factory = WebPluginFactory(self)

        self.webFrame.page().setPluginFactory(factory)
        self.webFrame.load(QUrl(url))

        vbox.addWidget(self.webFrame)

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

        if url == resources.START_PAGE_URL:
            self.webFrame.page().setLinkDelegationPolicy(
                QWebPage.DelegateAllLinks)
            self.connect(self.webFrame, SIGNAL("linkClicked(QUrl)"),
                self.start_page_operations)
            if sys.platform == "win32":
                content = file_manager.read_file_content(self.ID)
                pathCss = os.path.join(
                    resources.PRJ_PATH, 'doc', 'css', 'style.css')
                pathJs = os.path.join(resources.PRJ_PATH, 'doc', 'js', 'libs')
                pathImg = os.path.join(resources.PRJ_PATH, 'doc', 'img')
                content = content.replace('css/style.css',
                    pathCss).replace(
                    'src="js/libs/', 'src="%s\\' % pathJs).replace(
                    'src="img/', 'src="%s\\' % pathImg)
                self.webFrame.setHtml(content)
            self._id = 'Start Page'
            policy = Qt.ScrollBarAlwaysOff
        else:
            policy = Qt.ScrollBarAsNeeded
        self.webFrame.page().currentFrame().setScrollBarPolicy(
            Qt.Vertical, policy)
        self.webFrame.page().currentFrame().setScrollBarPolicy(
            Qt.Horizontal, policy)
Exemplo n.º 15
0
  def __init__(self, parent, debug=False):
    super(QGoogleMap, self).__init__(parent)
    if debug :
      QWebSettings.globalSettings().setAttribute(QWebSettings.DeveloperExtrasEnabled, True)
      self.setPage(_LoggedPage())

    self.initialized = False
    self.loadFinished.connect(self.onLoadFinished)
    self.page().mainFrame().addToJavaScriptWindowObject("qtWidget", self)
    self.connect(self.page().networkAccessManager(),
                 SIGNAL("sslErrors(QNetworkReply*, const QList<QSslError> & )"),
                 self.__manageSslErrors)
    basePath = os.path.abspath(os.path.dirname(__file__))
    if hasattr(sys, 'frozen'):
      htmlFile = os.path.join(os.path.dirname(sys.executable), "resources", 'maps', 'qgmap.html')
    else:
      htmlFile = os.path.join(basePath, "qgmap.html")
    qurl = QUrl.fromLocalFile(QFileInfo(htmlFile).absoluteFilePath())
    self.load(qurl)
Exemplo n.º 16
0
 def __init__(self, window):
     QWebView.__init__(self)
     self.window = window
     with open(get_resource_path("scudcloud.js"), "r") as f:
         self.js = f.read()
     # Required by Youtube videos (HTML5 video support only on Qt5)
     QWebSettings.globalSettings().setAttribute(QWebSettings.PluginsEnabled, True)
     # We don't want Java
     QWebSettings.globalSettings().setAttribute(QWebSettings.JavaEnabled, False);
     # We don't need History
     QWebSettings.globalSettings().setAttribute(QWebSettings.PrivateBrowsingEnabled, True);
     # Required for copy and paste clipboard integration
     QWebSettings.globalSettings().setAttribute(QWebSettings.JavascriptCanAccessClipboard, True)
     # Enabling Inspeclet only when --debug=True (requires more CPU usage)
     QWebSettings.globalSettings().setAttribute(QWebSettings.DeveloperExtrasEnabled, self.window.debug)
     self.setZoomFactor(self.window.zoom)
     self.page().setLinkDelegationPolicy(QtWebKit.QWebPage.DelegateAllLinks)
     self.connect(self, SIGNAL("urlChanged(const QUrl&)"), self.urlChanged)
     self.connect(self, SIGNAL("linkClicked(const QUrl&)"), self.linkClicked)
     self.addActions()
 def prepare(self, metaData):
     """
     Public method to prepare the disk cache file.
     
     @param metaData meta data for a URL (QNetworkCacheMetaData)
     @return reference to the IO device (QIODevice)
     """
     if QWebSettings.globalSettings().testAttribute(
             QWebSettings.PrivateBrowsingEnabled):
         return None
     
     return QNetworkDiskCache.prepare(self, metaData)
Exemplo n.º 18
0
def _set_global_render_settings(js_disable_cross_domain_access, private_mode):
    from PyQt4.QtWebKit import QWebSecurityOrigin, QWebSettings
    if js_disable_cross_domain_access is False:
        # In order to enable cross domain requests it is necessary to add
        # the http and https to the local scheme, this way all the urls are
        # seen as inside the same security origin.
        for scheme in ['http', 'https']:
            QWebSecurityOrigin.addLocalScheme(scheme)

    settings = QWebSettings.globalSettings()
    settings.setAttribute(QWebSettings.PrivateBrowsingEnabled, private_mode)
    settings.setAttribute(QWebSettings.LocalStorageEnabled, not private_mode)
 def _addHistoryEntry(self, itm):
     """
     Protected method to add a history item.
     
     @param itm reference to the history item to add (HistoryEntry)
     """
     globalSettings = QWebSettings.globalSettings()
     if globalSettings.testAttribute(QWebSettings.PrivateBrowsingEnabled):
         return
     
     self.__history.insert(0, itm)
     self.emit(SIGNAL("entryAdded"), itm)
     if len(self.__history) == 1:
         self.__checkForExpired()
Exemplo n.º 20
0
 def cookiesForUrl(self, url):
     """
     Public method to get the cookies for a URL.
     
     @param url URL to get cookies for (QUrl)
     @return list of cookies (list of QNetworkCookie)
     """
     if not self.__loaded:
         self.load()
     
     globalSettings = QWebSettings.globalSettings()
     if globalSettings.testAttribute(QWebSettings.PrivateBrowsingEnabled):
         return []
     
     return QNetworkCookieJar.cookiesForUrl(self, url)
Exemplo n.º 21
0
 def __init__(self, window):
     QWebView.__init__(self)
     self.window = window
     with open(get_resource_path("scudcloud.js"), "r") as f:
         self.js = f.read()
     QWebSettings.globalSettings().setAttribute(QWebSettings.PluginsEnabled, True)
     QWebSettings.globalSettings().setAttribute(QWebSettings.JavascriptCanAccessClipboard, True)
     QWebSettings.globalSettings().setAttribute(QWebSettings.DeveloperExtrasEnabled, self.window.debug)
     self.page().setLinkDelegationPolicy(QtWebKit.QWebPage.DelegateAllLinks)
     self.connect(self, SIGNAL("urlChanged(const QUrl&)"), self.urlChanged)
     self.connect(self, SIGNAL("linkClicked(const QUrl&)"), self.linkClicked)
     self.addActions()
 def __searchNow(self):
     """
     Private slot to perform the web search.
     """
     searchText = self.__searchEdit.text()
     if searchText.isEmpty():
         return
     
     globalSettings = QWebSettings.globalSettings()
     if not globalSettings.testAttribute(QWebSettings.PrivateBrowsingEnabled):
         self.__recentSearches.removeAll(searchText)
         self.__recentSearches.prepend(searchText)
         if len(self.__recentSearches) > self.__maxSavedSearches:
             self.__recentSearches = self.__recentSearches[:self.__maxSavedSearches]
         self.__setupCompleterMenu()
     
     url = self.__openSearchManager.currentEngine().searchUrl(searchText)
     self.emit(SIGNAL("search"), url)
Exemplo n.º 23
0
    def __init__(self, parent, cybuddy):
        super(ChatWidget, self).__init__()
        self.widget = uic.loadUi('ui/chatwidget.ui')
        self.parent_window = parent
        self.app = parent.app
        self.cybuddy = cybuddy
        self.typingTimer = None
        self.is_ready = False
        self.queue = []
        self.accepted_fts = []  # accepted file transfers
        self.transfer_tasks = {}
        self.webcam_viewer = None

        defaultSettings = QWebSettings.globalSettings()
        defaultSettings.setAttribute(QWebSettings.JavascriptEnabled, True)
        defaultSettings.setAttribute(QWebSettings.PluginsEnabled, True)
        defaultSettings.setAttribute(QWebSettings.DeveloperExtrasEnabled, True)

        ym.register_callback(cb.EMUSSA_CALLBACK_TYPING_NOTIFY, self._typing)
        self.widget.textEdit.keyPressEvent = self._writing_message
        self.widget.sendButton.clicked.connect(self._send_message)
        self.widget.filetransfer_btn.clicked.connect(self._send_file)
        self.widget.myAvatar.setPixmap(self.app.me.avatar.image)

        self.widget.messagesView.setUrl(QUrl('ui/resources/html/chat/index.html'))
        self.widget.messagesView.loadFinished.connect(self._document_ready)
        self.widget.messagesView.linkClicked.connect(self._link_clicked)
        self.widget.messagesView.page().setLinkDelegationPolicy(QWebPage.DelegateAllLinks)
        self.cybuddy.update.connect(self._update_buddy)
        self.cybuddy.update_status.connect(self._update_status)
        self.cybuddy.update_avatar.connect(self._update_avatar)
        self.widget.addUserBtn.clicked.connect(self.add_buddy)

        self._update_buddy()
        self._update_status()
        self._update_avatar()
        if cybuddy.yahoo_id in self.app.buddylist.buddy_items:
            self.widget.addUserBtn.setHidden(True)
            self.widget.ignoreUserBtn.setHidden(True)
Exemplo n.º 24
0
if __name__ == "__main__":
    app = QApplication(["AutoZone Taleo"])

    grid = QGridLayout()
    browser = QWebView()
    urlBar = UrlBar(browser)
    requestsTable = RequestsTable()  # Debug Requests

    networkManager = NetworkManager(requestsTable)
    page = QWebPage()
    page.setNetworkAccessManager(networkManager)
    browser.setPage(page)
    browser.load(QUrl(""))  # Defaul URL
    #browser.load(QUrl(""))
    QWebSettings.globalSettings().setAttribute(QWebSettings.PluginsEnabled,
                                               True)  # Enable Flash
    jsEval = JavaScriptEvaluator(page)  # Allow JS Rendering
    actionBox = ActionInputBox(page)

    grid.addWidget(urlBar, 1, 0)
    #    grid.addWidget(actionBox, 2, 0)
    grid.addWidget(browser, 3, 0)
    #   grid.addWidget(requestsTable, 4, 0)  # good for debugging request data
    #    grid.addWidget(jsEval, 5, 0)

    mainFrame = QWidget()
    mainFrame.setLayout(grid)
    mainFrame.show()

    sys.exit(app.exec_())
Exemplo n.º 25
0
import sys
import json
import ghost

try:
    from PyQt4.QtWebKit import QWebSettings
except ImportError:
    from PySide.QtWebKit import QWebSettings
    

if __name__ == '__main__':
    url = sys.argv[1]
    _ghost = ghost.Ghost(wait_timeout=60)

    QWebSettings.globalSettings().setAttribute(QWebSettings.AutoLoadImages, False)
    QWebSettings.globalSettings().setAttribute(QWebSettings.PluginsEnabled, False)
    page, resources = _ghost.open(url)
    print json.dumps({'url': url, 'headers': page.headers, 'html': unicode(_ghost.main_frame.toHtml())})

Exemplo n.º 26
0
from PyQt4.QtGui import QApplication, QWidget, QVBoxLayout
from PyQt4.QtWebKit import QWebView, QWebSettings
from PyQt4.QtCore import *

from ui_youtube import Ui_MainWindow
import pafy
import sys

QWebSettings.globalSettings().setAttribute(QWebSettings.PluginsEnabled, True)



url = 'https://www.youtube.com/watch?v=IdS3bWxG2a0&list=PLpclVninnGnvmdEPiApiIzt7Fe6GtRq5J'
video = pafy.new(url)

best = video.getbest()
bestvid = best.url
print bestvid

title = video.title

app = QApplication(sys.argv)

win = QWidget()
win.setWindowTitle(title)

layout = QVBoxLayout()
win.setLayout(layout)

# Create and fill a QWebView
view = QWebView()
Exemplo n.º 27
0
"""Minimal Python container app."""
import sys, os
from PyQt4 import QtGui, QtCore
from PyQt4.QtWebKit import QWebView, QWebSettings, QWebInspector
qt = QtCore.Qt

import html

# Enable developer tools inspector (right click menu)
settings = QWebSettings.globalSettings()
settings.setAttribute(QWebSettings.DeveloperExtrasEnabled, True)

def get_resource_path(resource):
    """Resolves the app path when run as a script or frozen."""
    if hasattr(sys, '_MEIPASS'):
        path = sys._MEIPASS
    else:
        path = os.path.dirname(__file__)
    return os.path.join(path, resource)

class MainWindow(QtGui.QMainWindow):
    """Main application window."""

    def __init__(self, headers, data):
        QtGui.QMainWindow.__init__(self)
        self.setWindowTitle("PyQt Cljs Testbed")
        self.setMaximumWidth(500)

        self.table = TableWidget(headers, data)
        self.setCentralWidget(self.table)
Exemplo n.º 28
0
	def __init__(self, urls, parent=None):
		KParts.MainWindow.__init__(self, parent)
		
		QWebSettings.globalSettings().setAttribute(
			QWebSettings.DeveloperExtrasEnabled, True)
		
		self.setWindowIcon(KIcon('text-editor'))
		
		self.kate = KTextEditor.EditorChooser.editor()
		self.editor = self.kate.createDocument(self).createView(self)
		doc = self.editor.document()
		self.editor.setContextMenu(self.editor.defaultContextMenu())
		
		sizegrip = create_grip(self.editor)
		sizegrip.show() #TODO: only show on windowstate change
		
		self.renderer = Renderer(self)
		
		@doc.textChanged.connect
		def _start_markdown(doc=None, old_range=None, new_range=None):
			"""Runs the renderer if it’s not currently rendering"""
			if not self.renderer.isRunning():
				self.renderer.start()
		
		@self.renderer.finished.connect
		def _stop_markdown():
			"""
			Replaces the preview HTML with the newly rendered one
			and restores the scroll position
			"""
			url = self.editor.document().url().resolved(QUrl('.'))
			self.preview.setHtml(self.renderer.html, url) #baseurl für extenes zeug
			self.preview.page().mainFrame().setScrollPosition(self.renderer.scrollpos)
		
		self.editor.document().documentNameChanged.connect(self.refresh_document)
		
		self.guiFactory().addClient(self.editor)
		self.setCentralWidget(self.editor)
		
		self.toolbar = KToolBar(i18n('Markdowner Toolbar'), self)
		self.toolbar.setWindowTitle(self.toolbar.objectName())
		self.preview_button = self.toolbar.addAction(KIcon('document-preview'), i18n('Show Preview'))
		self.preview_button.setCheckable(True)
		
		self.preview = QWebView()
		self.preview.settings().setUserStyleSheetUrl(base64css())
		self.preview.page().setLinkDelegationPolicy(QWebPage.DelegateAllLinks)
		self.preview.linkClicked.connect(self.intercept_link)
		
		with self.setup_dock(self.preview, i18n('Preview'), Qt.RightDockWidgetArea) as dock:
			page = self.preview.page()
			palette = page.palette()
			palette.setBrush(QPalette.Base, Qt.transparent)
			page.setPalette(palette)
			
			self.preview.setAttribute(Qt.WA_TranslucentBackground)
			self.preview.setAttribute(Qt.WA_OpaquePaintEvent, False)
			
			dock.setAllowedAreas(Qt.LeftDockWidgetArea | Qt.RightDockWidgetArea)
			dock.visibilityChanged.connect(self.preview_button.setChecked)
			self.preview_button.triggered.connect(dock.setVisible)
		
		inspector = QWebInspector()
		with self.setup_dock(inspector, i18n('Inspector'), Qt.BottomDockWidgetArea) as dock:
			inspector.setPage(self.preview.page())
			dock.hide()
			inspect_action = self.preview.page().action(QWebPage.InspectElement)
			inspect_action.triggered.connect(dock.show)
		
		if len(urls) != 0:
			self.editor.document().openUrl(urls[0])
		
		#TODO: spellcheck
		self.setAutoSaveSettings()
		self.kate.readConfig(self.autoSaveConfigGroup().config())
Exemplo n.º 29
0
 def __init__(self):
     QDialog.__init__(self)
     # init dlg
     self.ui = Ui_SchedaVulnerabilitaDlg()
     self.ui.setupUi(self)
     # set webView setting
     QWebSettings.globalSettings().setAttribute(QWebSettings.JavascriptEnabled, True)
     QWebSettings.globalSettings().setAttribute(QWebSettings.DeveloperExtrasEnabled, True)
     QWebSettings.globalSettings().setAttribute(QWebSettings.JavascriptCanAccessClipboard, True)
     QWebSettings.globalSettings().setAttribute(QWebSettings.SpatialNavigationEnabled, True)
     QWebSettings.globalSettings().setAttribute(QWebSettings.PrintElementBackgrounds, True)
     QWebSettings.globalSettings().setAttribute(QWebSettings.OfflineStorageDatabaseEnabled, True)
     QWebSettings.globalSettings().setAttribute(QWebSettings.LocalStorageEnabled, True)
     QWebSettings.globalSettings().globalSettings().enablePersistentStorage("/tmp/")
     # relod connection if erased e.g for reloading
     self.ui.webView.page().mainFrame().javaScriptWindowObjectCleared.connect( self.addAutocompleteBridge )
     self.ui.webView.page().mainFrame().loadFinished.connect( self.resetValues )
     self.offline_autocomplete = GeosismaAutocomplete(self.ui.webView)
     #set button event
     self.ui.pushButton.clicked.connect( self.offline_autocomplete.updateScheda )
Exemplo n.º 30
0
    def initAttributes(self):
        self.showMaximized()

        # Initialize the play list.
        self.playlist = []  # A list of links to the file to play.
        self.playlistTmp = [
        ]  # A temporary play list, use to shuffle play list.
        self.repeat = False

        # A timer showing the playing time.
        self.tmrTimer = QtCore.QTimer(self)
        self.tmrTimer.setInterval(
            250)  # This will emit a signal every 1/4 second
        self.tmrTimer.timeout.connect(self.on_tmrTimer_timeout)
        self.tmrTimer.start()

        #Volume control.
        self.sldVolumeSlider.setAudioOutput(self.vdpVideo.audioOutput())
        self.sldSeekSlider.setMediaObject(self.vdpVideo.mediaObject())

        # initialize the current mouse position and time.
        self.mousePos0 = QtGui.QCursor.pos()
        self.mouseT0 = QtCore.QTime.currentTime()

        # The dock widget: show or hide?
        self.dckShown = True
        self.lineEditSearch.setFocus()

        # A list of uploading video.
        self.uploadingList = {}
        self.uploadDialog = UploadDialog(self)
        self.downloadingList = []

        self.feed = None  # The current feed, displayed on the search result page.
        self.entry = None  # The current entry, playing.
        self.currentDirectLink = ""  # Direct link to the current video.
        self.currentVideo = None

        # The dock widget: show or hide?
        self.dckShown = True
        self.lineEditSearch.setFocus()

        # Search thread.
        self.threadPool = []
        self.threadType = [
        ]  # Store the function names that run as threads in self.threadPool.

        # Search box: Enter pressed.
        self.lineEditSearch.returnPressed.connect(
            self.on_btnSearchVideo_clicked)

        # The page showing search result.
        # Enable the flash plugin
        QWebSettings.globalSettings().setAttribute(QWebSettings.PluginsEnabled,
                                                   True)
        self.videoList.page().setLinkDelegationPolicy(
            QWebPage.DelegateAllLinks)
        self.videoList.connect(self.videoList,
                               QtCore.SIGNAL('linkClicked(const QUrl&)'),
                               self.linkClicked)

        # A seperate frame for login.
        self.logged_in = False
        self.yt_service = None

        # Advance search options
        self.advancedSearchDialog = SearchOptionDialog(parent=self)
        self.connect(self.advancedSearchDialog.optionDialogSearchTerm,
                     QtCore.SIGNAL("returnPressed()"), self.advancedSearch)
        self.connect(self.advancedSearchDialog.lineeditUserFeed,
                     QtCore.SIGNAL("returnPressed()"),
                     self.on_lineeditUserFeed_returnPressed)

        self.connect(self.advancedSearchDialog.btnTrending,
                     QtCore.SIGNAL("clicked()"), self.on_btnTrending_clicked)
        self.connect(self.advancedSearchDialog.btnTopRated,
                     QtCore.SIGNAL("clicked()"), self.on_btnTopRated_clicked)
        self.connect(self.advancedSearchDialog.btnRecentlyFeatured,
                     QtCore.SIGNAL("clicked()"),
                     self.on_btnRecentlyFeatured_clicked)
        self.connect(self.advancedSearchDialog.btnTopFavorites,
                     QtCore.SIGNAL("clicked()"),
                     self.on_btnTopFavorites_clicked)
        self.connect(self.advancedSearchDialog.btnMostShared,
                     QtCore.SIGNAL("clicked()"), self.on_btnMostShared_clicked)
        self.connect(self.advancedSearchDialog.btnMostResponded,
                     QtCore.SIGNAL("clicked()"),
                     self.on_btnMostResponded_clicked)
        self.connect(self.advancedSearchDialog.btnMostDiscussed,
                     QtCore.SIGNAL("clicked()"),
                     self.on_btnMostDiscussed_clicked)
        self.connect(self.advancedSearchDialog.btnMostRecent,
                     QtCore.SIGNAL("clicked()"), self.on_btnMostRecent_clicked)
        self.connect(self.advancedSearchDialog.btnMostPopular,
                     QtCore.SIGNAL("clicked()"),
                     self.on_btnMostPopular_clicked)

        # Menu bar actions.
        self.action_Save_playlist.triggered.connect(
            self.on_action_Save_playlist)
        self.action_Load_playlist.triggered.connect(
            self.on_action_Load_playlist)
        self.action_Open_download_folder.triggered.connect(
            self.on_action_Open_download_folder)
        self.action_Quit.triggered.connect(self.on_action_Quit)
        self.action_Guide.triggered.connect(self.on_action_Guide)
        self.action_About.triggered.connect(self.on_action_About)
        self.actionS_earch_option.triggered.connect(
            self.on_actionS_earch_option)

        self.vdpVideo.finished.connect(self.on_btnNext_clicked)

        self.btnLogout.setEnabled(False)

        self.connect(self, QtCore.SIGNAL("IWantToBeNoticed(QString)"),
                     self.showMessage)
Exemplo n.º 31
0
 def setCookiesFromUrl(self, cookieList, url):
     """
     Public method to set cookies for a URL.
     
     @param cookieList list of cookies to set (list of QNetworkCookie)
     @param url url to set cookies for (QUrl)
     @return flag indicating cookies were set (boolean)
     """
     if not self.__loaded:
         self.load()
     
     globalSettings = QWebSettings.globalSettings()
     if globalSettings.testAttribute(QWebSettings.PrivateBrowsingEnabled):
         return False
     
     host = url.host()
     eBlock = self.__isOnDomainList(self.__exceptionsBlock, host)
     eAllow = not eBlock and \
              self.__isOnDomainList(self.__exceptionsAllow, host)
     eAllowSession = not eBlock and \
                     not eAllow and \
                     self.__isOnDomainList(self.__exceptionsAllowForSession, host)
     
     addedCookies = False
     acceptInitially = self.__acceptCookies != self.AcceptNever
     if (acceptInitially and not eBlock) or \
        (not acceptInitially and (eAllow or eAllowSession)):
         # url domain == cookie domain
         soon = QDateTime.currentDateTime()
         soon = soon.addDays(90)
         for cookie in cookieList:
             lst = []
             if not (self.__filterTrackingCookies and \
                     cookie.name().startsWith("__utm")):
                 if eAllowSession:
                     cookie.setExpirationDate(QDateTime())
                 if self.__keepCookies == self.KeepUntilTimeLimit and \
                    not cookie.isSessionCookie and \
                    cookie.expirationDate() > soon:
                     cookie.setExpirationDate(soon)
                 lst.append(cookie)
                 if QNetworkCookieJar.setCookiesFromUrl(self, lst, url):
                     addedCookies = True
                 elif self.__acceptCookies == self.AcceptAlways:
                     # force it in if wanted
                     cookies = self.allCookies()
                     for ocookie in cookies[:]:
                         # does the cookie exist already?
                         if cookie.name() == ocookie.name() and \
                            cookie.domain() == ocookie.domain() and \
                            cookie.path() == ocookie.path():
                             # found a match
                             cookies.remove(ocookie)
                     
                     cookies.append(cookie)
                     self.setAllCookies(cookies)
                     addedCookies = True
     
     if addedCookies:
         self.__saveTimer.changeOccurred()
         self.emit(SIGNAL("cookiesChanged()"))
     
     return addedCookies
Exemplo n.º 32
0
 def initUI(self):
     self.centralWidget = QtGui.QWidget(self)
     '''
     Address Bar
     '''
     self.addbar = QtGui.QLineEdit(self)
     self.addbar.setGeometry(200, 16, 840, 35)
     self.addbar.setStyleSheet("font-size:21px")
     self.addbar.setFont(QtGui.QFont("Times New Roman"))
     self.addbar.returnPressed.connect(self.goClicked)
     self.addbar.cursorPositionAt(QtCore.QPoint(0, 0))
     self.addbar.setFocus()
     self.addbar.setSizePolicy(QtGui.QSizePolicy.MinimumExpanding, True)
     '''
     Progress Bar
     '''
     self.progressbar = QtGui.QProgressBar(self)
     self.progressbar.setMaximumWidth(100)
     '''
     Web Page Action setting
     '''
     self.web = QWebView(loadProgress=self.progressbar.setValue,
                         loadFinished=self.progressbar.hide,
                         loadStarted=self.progressbar.show,
                         titleChanged=self.setWindowTitle)
     self.web.setGeometry(300, 100, 1099, 768)
     self.web.urlChanged.connect(self.goUrlChanged)
     self.web.page().linkHovered.connect(self.LinkHovered)
     self.web.loadStarted.connect(self.pageLoadStarted)
     self.web.loadFinished.connect(self.pageLoadFinished)
     '''
     Back, Forward, Reload and Stop Button
     '''
     self.toolbar = QtGui.QToolBar(self)
     self.toolbar.addAction(self.web.pageAction(QWebPage.Back))
     self.toolbar.addAction(self.web.pageAction(QWebPage.Forward))
     self.toolbar.addAction(self.web.pageAction(QWebPage.Reload))
     self.toolbar.addAction(self.web.pageAction(QWebPage.Stop))
     '''
     Global Web Page Setting
     '''
     self.setting = QWebSettings.globalSettings()
     self.setting.setAttribute(QWebSettings.PluginsEnabled, True)
     self.setting.setAttribute(QWebSettings.AutoLoadImages, True)
     self.setting.setAttribute(QWebSettings.JavaEnabled, True)
     self.setting.setAttribute(QWebSettings.DnsPrefetchEnabled, True)
     self.setting.setAttribute(QWebSettings.WebGLEnabled, True)
     self.setting.setAttribute(QWebSettings.LocalStorageEnabled, True)
     self.setting.setAttribute(QWebSettings.JavascriptEnabled, True)
     self.setting.setAttribute(QWebSettings.JavascriptCanOpenWindows, True)
     self.setting.setAttribute(
         QWebSettings.OfflineWebApplicationCacheEnabled, True)
     self.setting.setAttribute(QWebSettings.ZoomTextOnly, True)
     self.setting.setAttribute(QWebSettings.AcceleratedCompositingEnabled,
                               True)
     self.setting.setAttribute(QWebSettings.SpatialNavigationEnabled, True)
     self.setting.setAttribute(QWebSettings.LinksIncludedInFocusChain, True)
     self.setting.setAttribute(QWebSettings.LocalContentCanAccessFileUrls,
                               True)
     '''
     Main Window Setting
     '''
     self.setGeometry(300, 100, 1099, 768)
     self.setWindowIcon(QtGui.QIcon(""))
     self.setStyleSheet("background-color:")
     self.status = self.statusBar()
     self.status.setSizeGripEnabled(False)
     self.status.addPermanentWidget(self.progressbar)
     self.status.hide()
     self.setCentralWidget(self.centralWidget)
     grid = QtGui.QGridLayout()
     grid.addWidget(self.toolbar, 0, 0, 1, 1)
     grid.addWidget(self.addbar, 0, 1, 1, 1)
     grid.addWidget(self.web, 2, 0, 1, 6)
     self.centralWidget.setLayout(grid)
     '''
     Use system Proxy to load page
     '''
     QNetworkProxyFactory.setUseSystemConfiguration(True)
Exemplo n.º 33
0
 def webSettings(self):
     self.cookiesjar = PersistentCookieJar(self)
     self.zoom = self.readZoom()
     # We don't want Flash (it causes a lot of trouble in some distros)
     QWebSettings.globalSettings().setAttribute(QWebSettings.PluginsEnabled,
                                                False)
     # We don't need Java
     QWebSettings.globalSettings().setAttribute(QWebSettings.JavaEnabled,
                                                False)
     # Enabling Local Storage (now required by Slack)
     QWebSettings.globalSettings().setAttribute(
         QWebSettings.LocalStorageEnabled, True)
     # We need browsing history (required to not limit LocalStorage)
     QWebSettings.globalSettings().setAttribute(
         QWebSettings.PrivateBrowsingEnabled, False)
     # Enabling Cache
     self.diskCache = QNetworkDiskCache(self)
     self.diskCache.setCacheDirectory(self.settings_path)
     # Required for copy and paste clipboard integration
     QWebSettings.globalSettings().setAttribute(
         QWebSettings.JavascriptCanAccessClipboard, True)
     # Enabling Inspeclet only when --debug=True (requires more CPU usage)
     QWebSettings.globalSettings().setAttribute(
         QWebSettings.DeveloperExtrasEnabled, self.debug)
Exemplo n.º 34
0
    def initAttributes(self):
        self.showMaximized()

        # Initialize the play list.
        self.playlist = []  # A list of links to the file to play.
        self.playlistTmp = []  # A temporary play list, use to shuffle play list.
        self.repeat = False
        
        # A timer showing the playing time.
        self.tmrTimer = QtCore.QTimer(self)
        self.tmrTimer.setInterval(250) # This will emit a signal every 1/4 second
        self.tmrTimer.timeout.connect(self.on_tmrTimer_timeout)
        self.tmrTimer.start()
        
        #Volume control.
        self.sldVolumeSlider.setAudioOutput(self.vdpVideo.audioOutput())
        self.sldSeekSlider.setMediaObject(self.vdpVideo.mediaObject())        
        
        
        # initialize the current mouse position and time.
        self.mousePos0 = QtGui.QCursor.pos()
        self.mouseT0 = QtCore.QTime.currentTime()
        
        # The dock widget: show or hide?
        self.dckShown = True
        self.lineEditSearch.setFocus()   
        
        
        # A list of uploading video.
        self.uploadingList = {}
        self.uploadDialog = UploadDialog(self)
        self.downloadingList = []

        self.feed = None  # The current feed, displayed on the search result page.
        self.entry = None  # The current entry, playing.
        self.currentDirectLink = "" # Direct link to the current video.
        self.currentVideo = None
        
        
        # The dock widget: show or hide?
        self.dckShown = True
        self.lineEditSearch.setFocus()   
        
        # Search thread.
        self.threadPool = []
        self.threadType = []  # Store the function names that run as threads in self.threadPool.
        
        # Search box: Enter pressed.
        self.lineEditSearch.returnPressed.connect(self.on_btnSearchVideo_clicked)
        
        # The page showing search result.
        # Enable the flash plugin
        QWebSettings.globalSettings().setAttribute(QWebSettings.PluginsEnabled, True)
        self.videoList.page().setLinkDelegationPolicy(QWebPage.DelegateAllLinks)
        self.videoList.connect(self.videoList, QtCore.SIGNAL('linkClicked(const QUrl&)'), self.linkClicked)

        # A seperate frame for login.
        self.logged_in = False
        self.yt_service = None
        
        # Advance search options
        self.advancedSearchDialog = SearchOptionDialog(parent=self)
        self.connect(self.advancedSearchDialog.optionDialogSearchTerm, QtCore.SIGNAL("returnPressed()"), self.advancedSearch)
        self.connect(self.advancedSearchDialog.lineeditUserFeed, QtCore.SIGNAL("returnPressed()"), self.on_lineeditUserFeed_returnPressed)
        
        self.connect(self.advancedSearchDialog.btnTrending , QtCore.SIGNAL("clicked()"), self.on_btnTrending_clicked)
        self.connect(self.advancedSearchDialog.btnTopRated , QtCore.SIGNAL("clicked()"), self.on_btnTopRated_clicked)
        self.connect(self.advancedSearchDialog.btnRecentlyFeatured , QtCore.SIGNAL("clicked()"), self.on_btnRecentlyFeatured_clicked)
        self.connect(self.advancedSearchDialog.btnTopFavorites , QtCore.SIGNAL("clicked()"), self.on_btnTopFavorites_clicked)
        self.connect(self.advancedSearchDialog.btnMostShared , QtCore.SIGNAL("clicked()"), self.on_btnMostShared_clicked)
        self.connect(self.advancedSearchDialog.btnMostResponded , QtCore.SIGNAL("clicked()"), self.on_btnMostResponded_clicked)
        self.connect(self.advancedSearchDialog.btnMostDiscussed , QtCore.SIGNAL("clicked()"), self.on_btnMostDiscussed_clicked)
        self.connect(self.advancedSearchDialog.btnMostRecent , QtCore.SIGNAL("clicked()"), self.on_btnMostRecent_clicked)
        self.connect(self.advancedSearchDialog.btnMostPopular , QtCore.SIGNAL("clicked()"), self.on_btnMostPopular_clicked)        
    
        # Menu bar actions.
        self.action_Save_playlist.triggered.connect(self.on_action_Save_playlist)
        self.action_Load_playlist.triggered.connect(self.on_action_Load_playlist)
        self.action_Open_download_folder.triggered.connect(self.on_action_Open_download_folder)
        self.action_Quit.triggered.connect(self.on_action_Quit)
        self.action_Guide.triggered.connect(self.on_action_Guide)
        self.action_About.triggered.connect(self.on_action_About)
        self.actionS_earch_option.triggered.connect(self.on_actionS_earch_option)
        
        self.vdpVideo.finished.connect(self.on_btnNext_clicked)
        
        self.btnLogout.setEnabled(False)
        
        self.connect(self, QtCore.SIGNAL("IWantToBeNoticed(QString)"), self.showMessage) 
Exemplo n.º 35
0
from PyQt4.QtNetwork import QNetworkRequest
from twisted.internet import defer

qWebSettings = {
    QWebSettings.JavascriptEnabled : True,
    QWebSettings.PluginsEnabled : False,
    QWebSettings.PrivateBrowsingEnabled : True,
    QWebSettings.LocalStorageEnabled : True,
    #QWebSettings.JavascriptCanOpenWindows : True,
    #QWebSettings.FrameFlatteningEnabled :  True,
    #QWebSettings.DeveloperExtrasEnabled :  True,
}


for key, value in qWebSettings.iteritems():
    QWebSettings.globalSettings().setAttribute(key, value)

class RenderError(Exception):
    pass


class HtmlRender(QWebPage):

    def __init__(self, url, baseurl=None):
        QWebPage.__init__(self)  
        self.url = url
        self.webview = QWebView()
        self.webview.setPage(self)
        #self.webview.show()
  
        self.deferred = defer.Deferred(self.cancel)
Exemplo n.º 36
0
 def __init__(self, teamName, safetyDict=None, iface=None, parent=None):
     QDockWidget.__init__(self, parent)
     # init internal safety
     self.currentSafety = safetyDict
     self.teamName = teamName
     self.iface = iface
     # init gui
     self.setupUi()
     # set webView setting
     QWebSettings.globalSettings().setAttribute(
         QWebSettings.JavascriptEnabled, True)
     QWebSettings.globalSettings().setAttribute(
         QWebSettings.DeveloperExtrasEnabled, True)
     QWebSettings.globalSettings().setAttribute(
         QWebSettings.JavascriptCanAccessClipboard, True)
     QWebSettings.globalSettings().setAttribute(
         QWebSettings.SpatialNavigationEnabled, True)
     QWebSettings.globalSettings().setAttribute(
         QWebSettings.PrintElementBackgrounds, True)
     QWebSettings.globalSettings().setAttribute(
         QWebSettings.OfflineStorageDatabaseEnabled, True)
     QWebSettings.globalSettings().setAttribute(
         QWebSettings.LocalStorageEnabled, True)
     QWebSettings.globalSettings().globalSettings().enablePersistentStorage(
         "/tmp/")
     # relod connection if erased e.g for reloading
     self.webView.page().mainFrame().javaScriptWindowObjectCleared.connect(
         self.addSafetyFormBridge)
     self.webView.page().mainFrame().loadFinished.connect(
         self.initSafetyValues)
     # Python to JS bridge definition and signal connection
     self.safetyFormBridge = SafetyFormBridge(self)
     self.safetyFormBridge.saveSafetyDone.connect(self.notifySafetyModified)
Exemplo n.º 37
0
def mainPyQt4Youtube():
    # 必要なモジュールのimport
    from PyQt4.QtCore import QUrl
    from PyQt4.QtGui import QApplication
    from PyQt4.QtWebKit import QWebView, QWebSettings
    from PyQt4.QtNetwork import QNetworkProxyFactory

    url = 'https://www.youtube.com/?hl=ja&gl=JP'

    app = QApplication(sys.argv)

    # Youtube動画を読み込むための設定
    QNetworkProxyFactory.setUseSystemConfiguration(True)
    QWebSettings.globalSettings().setAttribute(QWebSettings.PluginsEnabled, True)
    QWebSettings.globalSettings().setAttribute(QWebSettings.DnsPrefetchEnabled, True)
    QWebSettings.globalSettings().setAttribute(QWebSettings.JavascriptEnabled, True)
    QWebSettings.globalSettings().setAttribute(QWebSettings.OfflineStorageDatabaseEnabled, True)
    QWebSettings.globalSettings().setAttribute(QWebSettings.AutoLoadImages, True)
    QWebSettings.globalSettings().setAttribute(QWebSettings.LocalStorageEnabled, True)
    QWebSettings.globalSettings().setAttribute(QWebSettings.PrivateBrowsingEnabled, True)
    QWebSettings.globalSettings().setAttribute(QWebSettings.DeveloperExtrasEnabled, True)

    # QWebViewによるWebページ表示
    browser = QWebView()
    browser.load(QUrl(url))
    browser.setEnabled(True)
    browser.show()
    sys.exit(app.exec_())
Exemplo n.º 38
0
 def webSettings(self):
     self.cookiesjar = PersistentCookieJar(self)
     self.zoom = self.readZoom()
     # Required by Youtube videos (HTML5 video support only on Qt5)
     QWebSettings.globalSettings().setAttribute(QWebSettings.PluginsEnabled, self.plugins)
     # We don't want Java
     QWebSettings.globalSettings().setAttribute(QWebSettings.JavaEnabled, False)
     # Enabling Local Storage (now required by Slack)
     QWebSettings.globalSettings().setAttribute(QWebSettings.LocalStorageEnabled, True)
     # We need browsing history (required to not limit LocalStorage)
     QWebSettings.globalSettings().setAttribute(QWebSettings.PrivateBrowsingEnabled, False)
     # Enabling Cache
     self.diskCache = QNetworkDiskCache(self)
     self.diskCache.setCacheDirectory(self.settings_path)
     # Required for copy and paste clipboard integration
     QWebSettings.globalSettings().setAttribute(QWebSettings.JavascriptCanAccessClipboard, True)
     # Enabling Inspeclet only when --debug=True (requires more CPU usage)
     QWebSettings.globalSettings().setAttribute(QWebSettings.DeveloperExtrasEnabled, self.debug)
Exemplo n.º 39
0
    def initUI(self):
        self.centralWidget = QtGui.QWidget(self)

        '''
        Address Bar
        '''
        self.addbar = QtGui.QLineEdit(self)
        self.addbar.setGeometry(200, 16, 840, 35)
        self.addbar.setStyleSheet("font-size:21px")
        self.addbar.setFont(QtGui.QFont("Times New Roman"))
        self.addbar.returnPressed.connect(self.goClicked)
        self.addbar.cursorPositionAt(QtCore.QPoint(0, 0))
        self.addbar.setFocus()
        self.addbar.setSizePolicy(QtGui.QSizePolicy.MinimumExpanding, True)

        '''
        Progress Bar
        '''
        self.progressbar = QtGui.QProgressBar(self)
        self.progressbar.setMaximumWidth(100)

        '''
        Web Page Action setting
        '''
        self.web = QWebView(loadProgress=self.progressbar.setValue,
                            loadFinished=self.progressbar.hide, loadStarted=
                            self.progressbar.show, titleChanged=self.
                            setWindowTitle)
        self.web.setGeometry(300, 100, 1099, 768)
        self.web.urlChanged.connect(self.goUrlChanged)
        self.web.page().linkHovered.connect(self.LinkHovered)
        self.web.loadStarted.connect(self.pageLoadStarted)
        self.web.loadFinished.connect(self.pageLoadFinished)

        '''
        Back, Forward, Reload and Stop Button
        '''
        self.toolbar = QtGui.QToolBar(self)
        self.toolbar.addAction(self.web.pageAction(QWebPage.Back))
        self.toolbar.addAction(self.web.pageAction(QWebPage.Forward))
        self.toolbar.addAction(self.web.pageAction(QWebPage.Reload))
        self.toolbar.addAction(self.web.pageAction(QWebPage.Stop))

        '''
        Global Web Page Setting
        '''
        self.setting = QWebSettings.globalSettings()
        self.setting.setAttribute(QWebSettings.PluginsEnabled, True)
        self.setting.setAttribute(QWebSettings.AutoLoadImages, True)
        self.setting.setAttribute(QWebSettings.JavaEnabled, True)
        self.setting.setAttribute(QWebSettings.DnsPrefetchEnabled, True)
        self.setting.setAttribute(QWebSettings.WebGLEnabled, True)
        self.setting.setAttribute(QWebSettings.LocalStorageEnabled, True)
        self.setting.setAttribute(QWebSettings.JavascriptEnabled, True)
        self.setting.setAttribute(QWebSettings.JavascriptCanOpenWindows, True)
        self.setting.setAttribute(QWebSettings.
                                  OfflineWebApplicationCacheEnabled, True)
        self.setting.setAttribute(QWebSettings.ZoomTextOnly, True)
        self.setting.setAttribute(QWebSettings.AcceleratedCompositingEnabled,
                                  True)
        self.setting.setAttribute(QWebSettings.SpatialNavigationEnabled, True)
        self.setting.setAttribute(QWebSettings.LinksIncludedInFocusChain, True)
        self.setting.setAttribute(QWebSettings.LocalContentCanAccessFileUrls,
                                  True)

        '''
        Main Window Setting
        '''
        self.setGeometry(300, 100, 1099, 768)
        self.setWindowIcon(QtGui.QIcon(""))
        self.setStyleSheet("background-color:")
        self.status = self.statusBar()
        self.status.setSizeGripEnabled(False)
        self.status.addPermanentWidget(self.progressbar)
        self.status.hide()
        self.setCentralWidget(self.centralWidget)
        grid = QtGui.QGridLayout()
        grid.addWidget(self.toolbar, 0, 0, 1, 1)
        grid.addWidget(self.addbar, 0, 1, 1, 1)
        grid.addWidget(self.web, 2, 0, 1, 6)
        self.centralWidget.setLayout(grid)

        '''
        Use system Proxy to load page
        '''
        QNetworkProxyFactory.setUseSystemConfiguration(True)
Exemplo n.º 40
0
def mainPyQt4Youtube():
    # 必要なモジュールのimport
    from PyQt4.QtCore import QUrl
    from PyQt4.QtGui import QApplication
    from PyQt4.QtWebKit import QWebView, QWebSettings
    from PyQt4.QtNetwork import QNetworkProxyFactory

    url = "https://www.youtube.com/?hl=ja&gl=JP"

    app = QApplication(sys.argv)

    # Youtube動画を読み込むための設定
    QNetworkProxyFactory.setUseSystemConfiguration(True)
    QWebSettings.globalSettings().setAttribute(QWebSettings.PluginsEnabled, True)
    QWebSettings.globalSettings().setAttribute(QWebSettings.DnsPrefetchEnabled, True)
    QWebSettings.globalSettings().setAttribute(QWebSettings.JavascriptEnabled, True)
    QWebSettings.globalSettings().setAttribute(QWebSettings.OfflineStorageDatabaseEnabled, True)
    QWebSettings.globalSettings().setAttribute(QWebSettings.AutoLoadImages, True)
    QWebSettings.globalSettings().setAttribute(QWebSettings.LocalStorageEnabled, True)
    QWebSettings.globalSettings().setAttribute(QWebSettings.PrivateBrowsingEnabled, True)
    QWebSettings.globalSettings().setAttribute(QWebSettings.DeveloperExtrasEnabled, True)

    # QWebViewによるWebページ表示
    browser = QWebView()
    browser.load(QUrl(url))
    browser.setEnabled(True)
    browser.show()
    sys.exit(app.exec_())
Exemplo n.º 41
0
        return (self._normalize_url(url1) == self._normalize_url(url2))

    def _normalize_url(self, url):
        return urltools.normalize(url)

    def _handle_mouse_move(self, pos):
        hit_result = self._ui.web_view.page().mainFrame().hitTestContent(pos)

        if not hit_result.isNull():
            element = hit_result.enclosingBlockElement()

            if not element.isNull():
                self.highlight_element(element)

            else:
                self.highlight_element(None)

        else:
            self.highlight_element(None)

if __name__ == "__main__":
    app = QtGui.QApplication(sys.argv)

    QWebSettings.globalSettings() \
            .setAttribute(QWebSettings.DeveloperExtrasEnabled, True)

    main = Browser()
    main.show()

    sys.exit(app.exec_())