コード例 #1
0
    def testQVariantListProperty(self):
        class Obj(object):
            list = ["foo", "bar", "baz"]

        obj = Obj()

        wrapper_dict = {}
        for name in ["list"]:
            getter = lambda arg=None, name=name: getattr(obj, name)
            wrapper_dict[name] = Property("QVariantList", getter)
        wrapper = type("PyObj", (QObject,), wrapper_dict)

        view = QWebView()
        frame = view.page().mainFrame()
        frame.addToJavaScriptWindowObject("py_obj", wrapper())

        html = """
        <html><body>
        <script type="text/javascript">
        document.write(py_obj.list)
        </script>
        </body></html>
        """
        view.setHtml(html)
        view.show()
        self.app.exec_()
コード例 #2
0
    def testQVariantListProperty(self):
        class Obj(object):
            list = ['foo', 'bar', 'baz']

        obj = Obj()

        wrapper_dict = {}
        for name in ['list']:
            getter = lambda arg=None, name=name: getattr(obj, name)
            wrapper_dict[name] = Property('QVariantList', getter)
        wrapper = type('PyObj', (QObject, ), wrapper_dict)

        view = QWebView()
        frame = view.page().mainFrame()
        frame.addToJavaScriptWindowObject('py_obj', wrapper())

        html = '''
        <html><body>
        <script type="text/javascript">
        document.write(py_obj.list)
        </script>
        </body></html>
        '''
        view.setHtml(html)
        view.show()
        self.app.exec_()
コード例 #3
0
ファイル: bug_959.py プロジェクト: hz658832/PySide2
def createWebView( nIndex ):
    global functionID
    global currentWebView

    functionID = nIndex
    currentWebView = QWebView()
    currentWebView._jsfuncs = JSFuncs()
    currentWebView.page().mainFrame().addToJavaScriptWindowObject("jsfuncs", currentWebView._jsfuncs)
    QObject.connect( currentWebView, QtCore.SIGNAL('loadFinished( bool )'), onLoadFinished )
    currentWebView.load(PAGE_DATA % FUNCTIONS_LIST[ nIndex ])
    currentWebView.show()
コード例 #4
0
ファイル: bug_959.py プロジェクト: BadSingleton/pyside2
def createWebView( nIndex ):
    global functionID
    global currentWebView

    functionID = nIndex
    currentWebView = QWebView()
    currentWebView._jsfuncs = JSFuncs()
    currentWebView.page().mainFrame().addToJavaScriptWindowObject("jsfuncs", currentWebView._jsfuncs)
    QObject.connect( currentWebView, QtCore.SIGNAL('loadFinished( bool )'), onLoadFinished )
    currentWebView.load(PAGE_DATA % FUNCTIONS_LIST[ nIndex ])
    currentWebView.show()
コード例 #5
0
    def testPlugin(self):
        view = QWebView()
        fac = PluginFactory()
        view.page().setPluginFactory(fac)
        QWebSettings.globalSettings().setAttribute(QWebSettings.PluginsEnabled, True)

        view.load(QUrl(os.path.join(os.path.abspath(os.path.dirname(__file__)), 'qmlplugin', 'index.html')))

        view.resize(840, 600)
        view.show()

        QTimer.singleShot(500, self.app.quit)

        self.app.exec_()
コード例 #6
0
def main():

    app = QApplication([])

    view = QWebView()
    fac = PluginFactory()
    view.page().setPluginFactory(fac)
    QWebSettings.globalSettings().setAttribute(QWebSettings.PluginsEnabled,
                                               True)

    view.load(QUrl(sys.argv[1]))

    view.resize(840, 600)
    view.show()

    return app.exec_()
コード例 #7
0
ファイル: qml_plugin_test.py プロジェクト: zhoub/pyside2
    def testPlugin(self):
        view = QWebView()
        fac = PluginFactory()
        view.page().setPluginFactory(fac)
        QWebSettings.globalSettings().setAttribute(QWebSettings.PluginsEnabled,
                                                   True)

        view.load(
            QUrl(
                os.path.join(os.path.abspath(os.path.dirname(__file__)),
                             'qmlplugin', 'index.html')))

        view.resize(840, 600)
        view.show()

        QTimer.singleShot(500, self.app.quit)

        self.app.exec_()