<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<style type="text/css" style="display:none"><!-- p { margin-top: 0px; margin-bottom: 0px; }--></style>
</head>
<body dir="ltr" style="font-size:12pt;color:#000000;background-color:#FFFFFF;font-family:Calibri,Arial,Helvetica,sans-serif;">
<p>​Hi Aron,<br>
</p>
<p><br>
</p>
<p>Thanks for your explanation. It's clear now.<br>
</p>
<p><br>
</p>
<p><br>
</p>
<p>Regards,<br>
</p>
<p><br>
</p>
<p>Zhuangming Shen<br>
</p>
<div style="color: rgb(33, 33, 33);">
<hr tabindex="-1" style="display:inline-block; width:98%">
<div id="divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" color="#000000" style="font-size:11pt"><b>From:</b> Aron Helser <aron.helser@kitware.com><br>
<b>Sent:</b> Wednesday, March 21, 2018 1:34 AM<br>
<b>To:</b> 沈庄明<br>
<b>Cc:</b> VTK Users<br>
<b>Subject:</b> Re: [vtkusers] Json object error caused by websocket.py</font>
<div> </div>
</div>
<div>
<div dir="ltr"><span style="color:rgb(0,0,0); font-family:Calibri,Arial,Helvetica,sans-serif; font-size:16px; font-style:normal; font-weight:400; letter-spacing:normal; text-align:start; text-indent:0px; text-transform:none; white-space:normal; word-spacing:0px; background-color:rgb(255,255,255); float:none; display:inline">Zhuangming<span> ,</span></span><br>
<div><span style="color:rgb(0,0,0); font-family:Calibri,Arial,Helvetica,sans-serif; font-size:16px; font-style:normal; font-weight:400; letter-spacing:normal; text-align:start; text-indent:0px; text-transform:none; white-space:normal; word-spacing:0px; background-color:rgb(255,255,255); float:none; display:inline"><span>Regarding
 your original problem, I've found in the documentation that Python 3.6 supports json.loads() of 'bytes' type objects natively. That's the version I've been testing with.</span></span></div>
<div><span style="text-align:start; text-indent:0px; background-color:rgb(255,255,255); float:none; display:inline"><font color="#000000" face="Calibri, Arial, Helvetica, sans-serif"><span style="font-size:16px"><a href="https://docs.python.org/3.6/library/json.html">https://docs.python.org/3.6/library/json.html</a></span></font><br>
</span></div>
<div><span style="text-align:start; text-indent:0px; background-color:rgb(255,255,255); float:none; display:inline"><font color="#000000" face="Calibri, Arial, Helvetica, sans-serif"><span style="font-size:16px"><br>
</span></font></span></div>
<div><span style="text-align:start; text-indent:0px; background-color:rgb(255,255,255); float:none; display:inline"><font color="#000000" face="Calibri, Arial, Helvetica, sans-serif"><span style="font-size:16px">So your suggested fix is a good one, limited
 to python v3.4 and v3.5. I'll see if I can get it in.</span></font></span></div>
<div><span style="text-align:start; text-indent:0px; background-color:rgb(255,255,255); float:none; display:inline"><font color="#000000" face="Calibri, Arial, Helvetica, sans-serif"><span style="font-size:16px">Aron</span></font></span></div>
</div>
<div class="gmail_extra"><br>
<div class="gmail_quote">On Tue, Mar 20, 2018 at 10:26 AM, Aron Helser <span dir="ltr">
<<a href="mailto:aron.helser@kitware.com" target="_blank">aron.helser@kitware.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex; border-left:1px #ccc solid; padding-left:1ex">
<div dir="ltr">Thanks for the feedback! I've updated the wiki. </div>
<div class="HOEnZb">
<div class="h5">
<div class="gmail_extra"><br>
<div class="gmail_quote">On Tue, Mar 20, 2018 at 4:51 AM, 沈庄明 <span dir="ltr"><<a href="mailto:zhuangming.shen@sphic.org.cn" target="_blank">zhuangming.shen@sphic.org.cn</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex; border-left:1px #ccc solid; padding-left:1ex">
<div dir="ltr" style="font-size:12pt; color:#000000; background-color:#ffffff; font-family:Calibri,Arial,Helvetica,sans-serif">
<p>​​Hi Aron,<br>
</p>
<p><br>
</p>
<p>In the RemoteRenderer example <a href="https://www.vtk.org/Wiki/VTK/Examples/Python/Web/RemoteRenderer" target="_blank">
https://www.vtk.org/Wiki/VTK/E<wbr>xamples/Python/Web/RemoteRende<wbr>rer</a>. If this code runs under VTK 8.1.0, I think <br>
</p>
<p><br>
</p>
<pre style="margin-top:0px; margin-bottom:0px; padding:0px; border:none; outline:0px; font-family:"Source Code Pro",Monaco,Menlo,Consolas,monospace; font-size:0.95em; vertical-align:baseline; color:rgb(77,77,76); background:none rgb(238,238,238); line-height:22px"><span class="m_-1016416938808124893m_-3241598052586815198line" style="margin:0px; padding:0px; border:0px; outline:0px; font-weight:inherit; font-style:inherit; font-family:inherit; font-size:14.25px; vertical-align:baseline; height:22px">self.Application.GetObjectIdMa<wbr>p().SetActiveObject(<span class="m_-1016416938808124893m_-3241598052586815198string" style="margin:0px; padding:0px; border:0px; outline:0px; font-weight:inherit; font-style:inherit; font-family:inherit; vertical-align:baseline; color:rgb(113,140,0)">"VIEW"</span>, renderWindow)</span></pre>
<p><br>
</p>
<p>should be changed to<br>
</p>
<p><br>
</p>
<pre style="margin-top:0px; margin-bottom:0px; padding:0px; border:none; outline:0px; font-family:"Source Code Pro",Monaco,Menlo,Consolas,monospace; font-size:0.95em; vertical-align:baseline; color:rgb(77,77,76); background:none rgb(238,238,238); line-height:22px"><span class="m_-1016416938808124893m_-3241598052586815198line" style="margin:0px; padding:0px; border:0px; outline:0px; font-weight:inherit; font-style:inherit; font-family:inherit; font-size:14.25px; vertical-align:baseline; height:22px">self.initApplication().GetObje<wbr>ctIdMap().SetActiveObject(<span class="m_-1016416938808124893m_-3241598052586815198string" style="margin:0px; padding:0px; border:0px; outline:0px; font-weight:inherit; font-style:inherit; font-family:inherit; vertical-align:baseline; color:rgb(113,140,0)">"<wbr>VIEW"</span>, renderWindow)</span></pre>
<p><br>
</p>
<p>otherwise, an error will occur<br>
</p>
<p><br>
</p>
<p>AttributeError: '_WebCone' object has no attribute 'Application'​<br>
</p>
<p><br>
</p>
<p><br>
</p>
<p>Regards,<br>
</p>
<p><br>
</p>
<p>Zhuangming Shen<br>
</p>
<div style="color:rgb(33,33,33)">
<hr style="display:inline-block; width:98%">
<div id="m_-1016416938808124893m_-3241598052586815198divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" color="#000000" style="font-size:11pt"><b>From:</b> Aron Helser <<a href="mailto:aron.helser@kitware.com" target="_blank">aron.helser@kitware.com</a>><span><br>
<b>Sent:</b> Sunday, March 18, 2018 5:03 AM<br>
<b>To:</b> 沈庄明; VTK Users<br>
</span>
<div>
<div class="m_-1016416938808124893h5"><b>Subject:</b> Re: [vtkusers] Json object error caused by websocket.py</div>
</div>
</font>
<div> </div>
</div>
<div>
<div class="m_-1016416938808124893h5">
<div>
<div dir="ltr">Were you referring to this VTK web example? <a href="https://www.vtk.org/Wiki/VTK/Examples/Python/Web/RemoteRenderer" title="https://www.vtk.org/Wiki/VTK/Examples/Python/Web/RemoteRenderer
Ctrl+Click or tap to follow the link" target="_blank">https://www.vtk.org/W<wbr>iki/VTK/Examples/Python/Web/Re<wbr>moteRenderer</a>
<div>This has been updated on the ParaViewWeb examples page for wslink: <a href="https://kitware.github.io/paraviewweb/examples/RemoteRenderer.html" target="_blank">https://kitware.github<wbr>.io/paraviewweb/examples/<wbr>RemoteRenderer.html</a></div>
<div>As you can see it is very similar.</div>
<div><br>
</div>
<div>Hope that helps,</div>
<div>Aron</div>
</div>
<div class="gmail_extra"><br>
<div class="gmail_quote">On Thu, Mar 15, 2018 at 9:30 PM, Aron Helser <span dir="ltr">
<<a href="mailto:aron.helser@kitware.com" target="_blank">aron.helser@kitware.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex; border-left:1px #ccc solid; padding-left:1ex">
<div dir="ltr">Hi  <span style="color:rgb(0,0,0); font-family:Calibri,Arial,Helvetica,sans-serif; font-size:16px; font-style:normal; font-weight:400; letter-spacing:normal; text-align:start; text-indent:0px; text-transform:none; white-space:normal; word-spacing:0px; background-color:rgb(255,255,255); float:none; display:inline">
Zhuangming,</span>
<div><span style="color:rgb(0,0,0); font-family:Calibri,Arial,Helvetica,sans-serif; font-size:16px; font-style:normal; font-weight:400; letter-spacing:normal; text-align:start; text-indent:0px; text-transform:none; white-space:normal; word-spacing:0px; background-color:rgb(255,255,255); float:none; display:inline">(adding
 back the list)</span></div>
<div><span style="color:rgb(0,0,0); font-family:Calibri,Arial,Helvetica,sans-serif; font-size:16px; font-style:normal; font-weight:400; letter-spacing:normal; text-align:start; text-indent:0px; text-transform:none; white-space:normal; word-spacing:0px; background-color:rgb(255,255,255); float:none; display:inline"><br>
</span></div>
<div><span style="color:rgb(0,0,0); font-family:Calibri,Arial,Helvetica,sans-serif; font-size:16px; font-style:normal; font-weight:400; letter-spacing:normal; text-align:start; text-indent:0px; text-transform:none; white-space:normal; word-spacing:0px; background-color:rgb(255,255,255); float:none; display:inline">We
 have tested wslink and vtk with python 3.5 and 3.6. They may use some features that require 3.5, but I'm not sure if there would be any issues with 3.4.</span></div>
<div><span style="color:rgb(0,0,0); font-family:Calibri,Arial,Helvetica,sans-serif; font-size:16px; font-style:normal; font-weight:400; letter-spacing:normal; text-align:start; text-indent:0px; text-transform:none; white-space:normal; word-spacing:0px; background-color:rgb(255,255,255); float:none; display:inline"><br>
</span></div>
<div><span style="color:rgb(0,0,0); font-family:Calibri,Arial,Helvetica,sans-serif; font-size:16px; font-style:normal; font-weight:400; letter-spacing:normal; text-align:start; text-indent:0px; text-transform:none; white-space:normal; word-spacing:0px; background-color:rgb(255,255,255); float:none; display:inline">Which
 vtkweb example are you following? It is likely to be very similar with wslink - we designed it to require very few changes from the previous implementation.</span></div>
<div><span style="color:rgb(0,0,0); font-family:Calibri,Arial,Helvetica,sans-serif; font-size:16px; font-style:normal; font-weight:400; letter-spacing:normal; text-align:start; text-indent:0px; text-transform:none; white-space:normal; word-spacing:0px; background-color:rgb(255,255,255); float:none; display:inline"><br>
</span></div>
<div><span style="color:rgb(0,0,0); font-family:Calibri,Arial,Helvetica,sans-serif; font-size:16px; font-style:normal; font-weight:400; letter-spacing:normal; text-align:start; text-indent:0px; text-transform:none; white-space:normal; word-spacing:0px; background-color:rgb(255,255,255); float:none; display:inline">Regards,</span></div>
<div><span style="color:rgb(0,0,0); font-family:Calibri,Arial,Helvetica,sans-serif; font-size:16px; font-style:normal; font-weight:400; letter-spacing:normal; text-align:start; text-indent:0px; text-transform:none; white-space:normal; word-spacing:0px; background-color:rgb(255,255,255); float:none; display:inline">Aron</span></div>
</div>
<div class="m_-1016416938808124893m_-3241598052586815198HOEnZb">
<div class="m_-1016416938808124893m_-3241598052586815198h5">
<div class="gmail_extra"><br>
<div class="gmail_quote">On Thu, Mar 15, 2018 at 4:50 AM, 沈庄明 <span dir="ltr"><<a href="mailto:zhuangming.shen@sphic.org.cn" target="_blank">zhuangming.shen@sphic.org.cn</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex; border-left:1px #ccc solid; padding-left:1ex">
<div dir="ltr" style="font-size:12pt; color:#000000; background-color:#ffffff; font-family:Calibri,Arial,Helvetica,sans-serif">
<p>​Hi Aron,<br>
</p>
<p><br>
</p>
<p>Sorry for interrupting you again. I'm learning how to use wslink in my project. My project is coded using previous vtkweb framework, and learn a lot from its simple example to display a cone on the browse. Now I would like to use wslink, which can support
 python 3.x, to replace the old framework. I am not sure if you could provide me a similar simple example. Then I could learn by myself how to do that. Thanks in advance.</p>
<p><br>
</p>
<p><br>
</p>
<p>Regards,</p>
<p><br>
</p>
<p>Zhuangming Shen <br>
</p>
<div style="color:rgb(33,33,33)"><span>
<hr style="display:inline-block; width:98%">
<div id="m_-1016416938808124893m_-3241598052586815198m_1446384026898214988m_-302481707849636061divRplyFwdMsg" dir="ltr">
<font face="Calibri, sans-serif" color="#000000" style="font-size:11pt"><b>From:</b> Aron Helser <<a href="mailto:aron.helser@kitware.com" target="_blank">aron.helser@kitware.com</a>><br>
<b>Sent:</b> Wednesday, March 14, 2018 11:51 PM<br>
<b>To:</b> 沈庄明<br>
<b>Subject:</b> Re: [vtkusers] Json object error caused by websocket.py</font>
<div> </div>
</div>
</span>
<div>
<div class="m_-1016416938808124893m_-3241598052586815198m_1446384026898214988h5">
<div>
<div dir="ltr">Thanks for the report - we've tested with Python 3.6, but I'm not sure there's automated testing for this code. 
<div>If you'd like to report a bug, that'd be great.</div>
<div><br>
</div>
<div>Thanks!</div>
<div>Aron</div>
</div>
<div class="gmail_extra"><br>
<div class="gmail_quote">On Wed, Mar 14, 2018 at 4:11 AM, 沈庄明 <span dir="ltr"><<a href="mailto:zhuangming.shen@sphic.org.cn" target="_blank">zhuangming.shen@sphic.org.cn</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex; border-left:1px #ccc solid; padding-left:1ex">
<div dir="ltr" style="font-size:12pt; color:#000000; background-color:#ffffff; font-family:Calibri,Arial,Helvetica,sans-serif">
<p>Hi all,<br>
</p>
<p><br>
</p>
<p>I found there probably be a bug around Line 250 in <VTK_build>/Wrapping/Python<wbr>/wslink/websocket.py. If this code is run using python 3.x, this will cause an error "json object must be str not 'bytes' " when use json.loads. To avoid this error, I think the
 code can be modified by<br>
</p>
<p>​<br>
</p>
<p><img name="m_-1016416938808124893_m_-3241598052586815198_m_1446384026898214988_m_-302481707849636061_m_-9215194516427442813_null" title="pastedImage.png" src="cid:b10da89b-5d6c-40ac-898d-8db128fb6001"><br>
</p>
<p><br>
</p>
<p><br>
</p>
<p>Regards,<br>
</p>
<p><br>
</p>
<p>Zhuangming Shen<br>
</p>
</div>
<br>
______________________________<wbr>_________________<br>
Powered by <a href="http://www.kitware.com" rel="noreferrer" target="_blank">www.kitware.com</a><br>
<br>
Visit other Kitware open-source projects at <a href="http://www.kitware.com/opensource/opensource.html" rel="noreferrer" target="_blank">
http://www.kitware.com/opensou<wbr>rce/opensource.html</a><br>
<br>
Please keep messages on-topic and check the VTK FAQ at: <a href="http://www.vtk.org/Wiki/VTK_FAQ" rel="noreferrer" target="_blank">
http://www.vtk.org/Wiki/VTK_FA<wbr>Q</a><br>
<br>
Search the list archives at: <a href="http://markmail.org/search/?q=vtkusers" rel="noreferrer" target="_blank">
http://markmail.org/search/?q=<wbr>vtkusers</a><br>
<br>
Follow this link to subscribe/unsubscribe:<br>
<a href="https://vtk.org/mailman/listinfo/vtkusers" rel="noreferrer" target="_blank">https://vtk.org/mailman/listin<wbr>fo/vtkusers</a><br>
<br>
</blockquote>
</div>
<br>
</div>
</div>
</div>
</div>
</div>
</div>
</blockquote>
</div>
<br>
</div>
</div>
</div>
</blockquote>
</div>
<br>
</div>
</div>
</div>
</div>
</div>
</div>
</blockquote>
</div>
<br>
</div>
</div>
</div>
</blockquote>
</div>
<br>
</div>
</div>
</div>
</body>
</html>