Script execution

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Script execution

ioprst0904

Why can't the script run completely? Marked the comment "no".

And the SVG is not displayed on the page.

I need through Python to determine the size of the svg-element "text".


import wx 
import wx.html2 

html_string = """
<!DOCTYPE htm>
<html>
    <head>
       <title>Hello World!</title>
    </head>
    <body>
        <svg viewBox="0 0 192 192" xmlns="http://www.w3.org/2000/svg" id="svg" height="100%" width="100%">
          <rect transform="translate(64,128)" width="27" height="64" stroke-width=".5" fill="#ff0" stroke="#000" id="rect"/>
          <text font-family="monospace" font-size="16" transform="translate(64,141)" id="tsvg">Test Text</text>
        </svg>
        <script type="text/javascript">
            var text = document.getElementById('tsvg');
            alert(text); // ok
            var tw = text.getComputedTextLength();
            alert(tw); // no
            var box = text.getBBox();
            var w = box.width;
            var h = box.height;
            alert(w+" "+ h); // no
        </script>
    </body>
</html>
"""

class MyBrowser(wx.Dialog): 
  def __init__(self, *args, **kwds): 
    wx.Dialog.__init__(self, *args, **kwds) 
    sizer = wx.BoxSizer(wx.VERTICAL) 
    self.browser = wx.html2.WebView.New(self) 
    sizer.Add(self.browser, 1, wx.EXPAND, 10) 
    self.SetSizer(sizer) 
    self.SetSize((700, 700)) 

if __name__ == '__main__': 
  app = wx.App() 
  dialog = MyBrowser(None, -1) 
  dialog.browser.SetPage(html_string, '')
  dialog.Show() 
  app.MainLoop() 



--
You received this message because you are subscribed to the Google Groups "wxPython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Script execution

Tim Roberts

Why can't the script run completely? Marked the comment "no".

And the SVG is not displayed on the page.

I need through Python to determine the size of the svg-element "text".

Because wx.html2 on Windows uses Internet Explorer in "compatibility mode", which simulates IE 7.0.  IE 7.0 does not support the <svg> tag.

-- 
Tim Roberts, [hidden email]
Providenza & Boekelheide, Inc.

--
You received this message because you are subscribed to the Google Groups "wxPython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

RE: Script execution

GadgetSteve

 

 

From: [hidden email] <[hidden email]> On Behalf Of Tim Roberts
Sent: 29 January 2019 02:20
To: [hidden email]
Subject: Re: [wxPython-users] Script execution

 

Why can't the script run completely? Marked the comment "no".

And the SVG is not displayed on the page.

I need through Python to determine the size of the svg-element "text".

Because wx.html2 on Windows uses Internet Explorer in "compatibility mode", which simulates IE 7.0.  IE 7.0 does not support the <svg> tag.

[Steve Barnes]

Is there a way to override the mode?

-- 
Tim Roberts, [hidden email]
Providenza & Boekelheide, Inc.

--
You received this message because you are subscribed to the Google Groups "wxPython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "wxPython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Script execution

Niki Spahiev-2
On 29.01.19 г. 7:47 ч., Steve Barnes wrote:
> Because wx.html2 on Windows uses Internet Explorer in "compatibility mode", which simulates IE 7.0.  IE 7.0 does not support the <svg> tag.
>
> [Steve Barnes]
>
> Is there a way to override the mode?

Use registry:

Root: HKLM;
SubKey: SOFTWARE\Microsoft\Internet
Explorer\Main\FeatureControl\FEATURE_BROWSER_EMULATION;
ValueName: "%(EXE)s";
ValueType: dword;
ValueData: 11000

HTH
Niki

--
You received this message because you are subscribed to the Google Groups "wxPython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Script execution

ioprst0904
In reply to this post by ioprst0904
Solution: library "cefpython3".
Allows you to insert your browser (chromium) in wxPython 

--
You received this message because you are subscribed to the Google Groups "wxPython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.