kivy-garden / garden.cefpython

CEFPython Kivy widget
MIT License
65 stars 31 forks source link

Query string #4

Open blkslimer opened 10 years ago

blkslimer commented 10 years ago

Hi,
Using query string inside browser start_url not working. There is some other way to pass parameter inside url?

class CefBrowserApp(App): def build(self): return CefBrowser(start_url='http://kivy.org?par1=val1&par2=val2')

Thanks

hnb2 commented 10 years ago

I just tried in Linux 64 bits with start_url equal to a URL with parameter and It is working. On which platform did you encounter the problem ? Is it working without param ?

blkslimer commented 10 years ago

I have the problem with Windows 7 x64. Without parameters everything works fine. Below is the start browser log:

cefpython: ------------------------------------------------------------ cefpython: Initialize() called cefpython: CefExecuteProcess(): exitCode = -1 cefpython: CefInitialize() ... ... ... ... ... ... cefpython: CreateBrowserSync() called cefpython: CefBrowser::CreateBrowserSync() cefpython: GetPyBrowser(): creating new PyBrowser, browserId=1 cefpython: BrowserProcessHandler_OnBeforeChildProcessLaunch() [0129/182610:ERROR_REPORT:render_widget_host_view_osr.cc(268)] Check failed: false. cefpython: CefBrowser::CreateBrowserSync() succeeded cefpython: SendProcessMessage(): message=DoJavascriptBindings, arguments size=1 request_keyboard() [INFO ] [GL ] BGRA texture support is available cefpython: Browser: OnProcessMessageReceived(): OnContextCreated cefpython: V8ContextHandler_OnContextCreated() _fix_select_boxes() OnLoadingStateChange(): isLoading = False

Let me know if you need some other test.

Thank you

cztomczak commented 10 years ago

I've tested loading url with hash in cefclient on Win7 64 and it works fine.

The logs you've pasted miss the crucial part about the url being loaded.

How did you end up with the conclusion that the hash in the url is not working? What exactly is not working? You did not specify. Most probably it is just your javascript not working.

blkslimer commented 10 years ago

I need a HTML parser that given a HTML string to render it. For example i need to display a string like "

hi, this is your info< /i> < /b>
". Therefore I would like to ask if there is a method with garden.cefpython that you pass an html string instead of start_url?

For now i want to use an empty page and pass the string as parameter. This is the html test page:

TEST

so there is no javascript inside. I've done the following tests:

  1. start_url= with no parameters and it works fine
  2. cefclient with and without parameters and works fine
  3. start_url= with parameters and I see only a blank page instead of red html page above. Below all the debug log: [0130/082225:ERROR_REPORT:v8_impl.cc(75)] Check failed: contextmap.empty(). cefpython: ------------------------------------------------------------ cefpython: Initialize() called cefpython: CefExecuteProcess(): exitCode = -1 cefpython: CefInitialize() cefpython: App_OnBeforeCommandLineProcessing_BrowserProcess() cefpython_app: Command line: "C:\Kivy171\Python\python.exe" -u --browser-subprocess-path="D:\cefpython\libs\win32.py2\subprocess.exe" --lang=en-US --log-file=debug.log --log-severity=info --enable-release-dcheck --resources-dir-path="D:\cefpython\libs\win32.py2" --locales-dir-path="D:\cefpython\libs\win32.py2\locales" --no-sandbox "D:\Development\HTMLtest\src\main.py" cefpython: CreateBrowserSync() called cefpython: navigateUrl: ///D:/testHMLString.html%3FFirstName%3Ddd cefpython: CefBrowser::CreateBrowserSync() cefpython: GetPyBrowser(): creating new PyBrowser, browserId=1 cefpython: BrowserProcessHandler_OnBeforeChildProcessLaunch() [0130/082332:ERROR_REPORT:render_widget_host_view_osr.cc(268)] Check failed: false. cefpython: CefBrowser::CreateBrowserSync() succeeded cefpython: SendProcessMessage(): message=DoJavascriptBindings, arguments size=1 cefpython_app: Command line: "D:\cefpython\libs\win32.py2\subprocess.exe" --type=renderer --no-sandbox --lang=en-US --lang=en-US --locales-dir-path="D:\cefpython\libs\win32.py2\locales" --log-file=debug.log --log-severity=info --enable-release-dcheck --resources-dir-path="D:\cefpython\libs\win32.py2" --channel="4632.0.234592054\979786714" /prefetch:673131151 cefpython_app: Renderer: OnProcessMessageReceived(): DoJavascriptBindings cefpython_app: Renderer: OnContextCreated() cefpython_app: Renderer: DoJavascriptBindingsForFrame(): bindings are set cefpython_app: Renderer: DoJavascriptBindingsForFrame(): bindings are set cefpython_app: Browser: OnProcessMessageReceived(): OnContextCreated cefpython: V8ContextHandler_OnContextCreated() _fix_select_boxes() OnLoadingStateChange(): isLoading = False
hnb2 commented 10 years ago

Why don't you just call an external HTML file ? You can host it on a local web server or just call the file:/// protocol. I tried under Ubuntu 13.10 64 bits, it is working. If you need to render things dynamically, it is a different story.

cztomczak commented 10 years ago

Now from the logs I see what the problem is. Local file:// urls are encoded with pathname2url() to support unicode (chinese) characters, and it encodes the hash by accident. Created issue 114 in cefpython: https://code.google.com/p/cefpython/issues/detail?id=114

The solution is to load a "http" url, hashes in that case will work fine.

Or you can load a html string instead of the url. Load "about:blank" url in the browser and later call browser.GetMainFrame().LoadString(myhtml).

gustavklopp commented 9 years ago

Sorry for the dumb question, but how do you call browser.GetMainFrame().LoadString(myhtml) ?

from kivy.garden.cefpython import CefBrowser, cefpython
from kivy.app import App

class CefBrowserApp(App):
    def build(self):
        cefbrowser =CefBrowser(start_url='about:blank')
        myhtml = "<html><head></head><body>Hello world</body></html>" 
        cefbrowser.browser.GetMainFrame().LoadString(myhtml)
        return cefbrowser 

CefBrowserApp().run()

cefpython.Shutdown()

and the result: AttributeError: 'CefBrowser' object has no attribute 'browser'' Thanks!