Using the new wx.html2 WebView

Hi all,

I'm trying to use the new wx.html2.WebView that has been implemented
in the wxPython 2.9.3.1. However I'm running into an issue on OSX.

I'm trying to access the cookies on a page via the RunScript API and
keep getting None.

cookie = self.wv.RunScript("document.cookie")

where self.wv is a WebView object from wx.html2. Any suggestions as
to why this always returns None? Am I just using RunScript
incorrectly? Any help would be appreciated.

Thanks!

For anyone interested, here is a hacky way of doing it that I figured
out :confused:

        prev_title = self.wv.GetCurrentTitle()
        self.wv.RunScript("document.title = document.cookie")
        cookies = self.wv.GetCurrentTitle()
        self.wv.RunScript("document.title = %s" % prev_title)

Is there a better way of retrieving the cookies?

···

On Jan 11, 5:09 pm, Rish <rishsha...@gmail.com> wrote:

Hi all,

I'm trying to use the new wx.html2.WebView that has been implemented
in the wxPython 2.9.3.1. However I'm running into an issue on OSX.

I'm trying to access the cookies on a page via the RunScript API and
keep getting None.

cookie = self.wv.RunScript("document.cookie")

where self.wv is a WebView object from wx.html2. Any suggestions as
to why this always returns None? Am I just using RunScript
incorrectly? Any help would be appreciated.

Thanks!

Hi Rish,

For anyone interested, here is a hacky way of doing it that I figured
out :confused:

       prev_title = self.wv.GetCurrentTitle()
       self.wv.RunScript("document.title = document.cookie")
       cookies = self.wv.GetCurrentTitle()
       self.wv.RunScript("document.title = %s" % prev_title)

Is there a better way of retrieving the cookies?

document.cookie is not really a string, but an object that can behave like a string. Have you tried RunScript("document.cookie.toString()")?

Regards,

Kevin

···

On Jan 11, 2012, at 6:09 PM, Rish wrote:

On Jan 11, 5:09 pm, Rish <rishsha...@gmail.com> wrote:

Hi all,

I'm trying to use the new wx.html2.WebView that has been implemented
in the wxPython 2.9.3.1. However I'm running into an issue on OSX.

I'm trying to access the cookies on a page via the RunScript API and
keep getting None.

cookie = self.wv.RunScript("document.cookie")

where self.wv is a WebView object from wx.html2. Any suggestions as
to why this always returns None? Am I just using RunScript
incorrectly? Any help would be appreciated.

Thanks!

--
To unsubscribe, send email to wxPython-users+unsubscribe@googlegroups.com
or visit http://groups.google.com/group/wxPython-users?hl=en

Hi Kevin, thanks for the reply.

That does not work for me either (at least on OSX).

It seems I found another bug regarding this class on OSX. This class
(wx.html2.WebView) cannot be used as a child of wx.Dialog since it
seems the call ShowModal of the dialog interferes with the event loop
WebView uses (such that LoadURL never will actually load a URL). I
got around this by using Show() instead and having to set an event on
a thread other than the Main thread such that the Main thread only did
UI work and the rest of code continued execution off the Main thread
after the event was set on a call to Close of the dialog. Not very
intuitive or easy to get around.

Overall the attempt at making this work cross platform is nice, but I
wouldn't expect most programmers to jump through these hoops and use
it (I have to admit I was very excited to try it).

-Rishi

···

On Jan 11, 8:11 pm, Kevin Ollivier <kevin-li...@theolliviers.com> wrote:

Hi Rish,

On Jan 11, 2012, at 6:09 PM, Rish wrote:

> For anyone interested, here is a hacky way of doing it that I figured
> out :confused:

> prev_title = self.wv.GetCurrentTitle()
> self.wv.RunScript("document.title = document.cookie")
> cookies = self.wv.GetCurrentTitle()
> self.wv.RunScript("document.title = %s" % prev_title)

> Is there a better way of retrieving the cookies?

document.cookie is not really a string, but an object that can behave like a string. Have you tried RunScript("document.cookie.toString()")?

Regards,

Kevin

> On Jan 11, 5:09 pm, Rish <rishsha...@gmail.com> wrote:
>> Hi all,

>> I'm trying to use the new wx.html2.WebView that has been implemented
>> in the wxPython 2.9.3.1. However I'm running into an issue on OSX.

>> I'm trying to access the cookies on a page via the RunScript API and
>> keep getting None.

>> cookie = self.wv.RunScript("document.cookie")

>> where self.wv is a WebView object from wx.html2. Any suggestions as
>> to why this always returns None? Am I just using RunScript
>> incorrectly? Any help would be appreciated.

>> Thanks!

> --
> To unsubscribe, send email to wxPython-users+unsubscribe@googlegroups.com
> or visithttp://groups.google.com/group/wxPython-users?hl=en

The C++ RunScript method doesn't return a value. You can create a ticket at trac.wxwidgets.org requesting that it be changed to do so.

···

On 1/11/12 5:09 PM, Rish wrote:

Hi all,

I'm trying to use the new wx.html2.WebView that has been implemented
in the wxPython 2.9.3.1. However I'm running into an issue on OSX.

I'm trying to access the cookies on a page via the RunScript API and
keep getting None.

cookie = self.wv.RunScript("document.cookie")

where self.wv is a WebView object from wx.html2. Any suggestions as
to why this always returns None? Am I just using RunScript
incorrectly?

--
Robin Dunn
Software Craftsman