[Ironpython-users] Using Silverlight 5 in IronPython

sepatan at sibmail.com sepatan at sibmail.com
Fri Mar 22 05:03:37 CET 2013


> Hello I am wondering if it is possible to import the json module into a
> Silverlight 5 application. Would I need to compile it into a xap?
>
> If so how can I do this I am having no luck running a XAP file in Chiron
>
> Can I do this the other way
>
> <script type="text/python">
> import json
>
> ... Doesn't work either not sure what I am doing wrong
>
> Thank you for any advice
>
> *cheers
> _______________________________________________
> Ironpython-users mailing list
> Ironpython-users at python.org
> http://mail.python.org/mailman/listinfo/ironpython-users
>

=================================================================
Explain long. I can offer an option as I have done. Here is a working
example:
file x.html -->
<html>
<head>
<!-
.........................................
-->
	<script type="text/javascript" src="/static/registr_UI.js"></script>
	<script type="application/x-zip-compressed"
src="/static/biblg.zip"></script>
	<title>Silverlight Application</title>
<!-
.........................................
-->
</head>
<body>
<!-
.........................................
-->
<script type="application/python" class="*">
import biblg.reggood
</script>
<!-
.........................................
-->
<table width="100%" border="1" cellpadding="5"
style="border-collapse:collapse">
	<tr height="70px">
		<td id="my_cell_1" width="200pt"  onClick="DlrFn1(this,null);">cell
table 1</td>
		<td id="my_cell_2" width="200pt">cell table 2</td>
		<td id="my_cell_3" width="200pt">cell table 3</td>
		<td id="my_cell_4" width="200pt">cell table 4</td>
		<td id="my_cell_5" width="200pt"  OnMouseMove='DlrFn2(event,null);'>cell
table 5</td>
	</tr>
	<tr height="80px">
		<td id="my_cell_6">cell table 1</td>
		<td id="my_cell_7" rowspan="3"><DIV CLASS="lnk">service</DIV> <DIV
CLASS="lnk"><A HREF="prices.html">price</A></DIV>2</td>
		<td id="my_cell_8" colspan="2">cell table 3</td>
		<td id="my_cell_9">cell table 5</td>
	</tr>
	<tr height="30px">
		<td id="my_cell_10" rowspan="2">cell table 1</td>
		<td id="my_cell_12">cell table 4</td>
		<td id="my_cell_13">cell table 5</td>
		<td id="my_cell_17">cell table 5</td>
	</tr>
	<tr height="80px">
		<td id="my_cell_15">cell table 2</td>
		<td id="my_cell_18" colspan="2">cell table 4</td>
	</tr>
	<tr height="60px">
		<td id="my_cell_19" colspan="2">cell table 1</td>
		<td id="my_cell_11">cell table 2</td>
		<td id="my_cell_21">cell table 3</td>
		<td id="my_cell_22">cell table 4</td>
	</tr>
	<tr height="100px">
		<td id="my_cell_23">cell table 1</td>
		<td id="my_cell_24">cell table 2</td>
		<td id="my_cell_25">cell table 3</td>
		<td id="my_cell_26">cell table 4</td>
		<td id="my_cell_27">cell table 5</td>
	</tr>
</table>
<!-
.........................................
-->

<!-- Content end-->

<span>
  <object data="data:application/x-silverlight," height="1"
id="silverlightDlrObject_DOMOnly" type="application/x-silverlight"
width="1">
	  <param name="source" value="/static/dlr.xap" />
	  <param name="enableHtmlAccess" value="true" />
  </object>
</span>

</body>
</html>
====================================================
biblg.zip -> __init__.py , evgood.py , reggood.py
====================================================
registr_UI.js -->
function registerDlrFn1(fn)
{
    DlrFn1 = fn;
}
function registerDlrFn2(fn)
{
    DlrFn2 = fn;
}
function registerDlrFn3(fn)
{
    DlrFn3 = fn;
}
===============================================
__init__.py -->
# kkkk
pass
===============================================
evgood.py -->
# -*- coding: utf-8 -*-
from System.Windows.Browser import HtmlPage

def ctl_sbutton1_onclick(s,e):
	HtmlPage.Window.Alert(str(s.Id))

def ctl_sbutton2_onclick(s,*e):
	HtmlPage.Document.my_cell_9.innerHTML=str(s.screenX)

def ctl_sbutton3_onclick(s,e):
	HtmlPage.Window.Alert("ctl_sbutton3_onclick")
===============================================
reggood.py -->
# -*- coding: utf-8 -*-
from System import EventHandler
from System.Windows.Browser import HtmlPage, HtmlEventArgs
import biblg.evgood as event

HtmlPage.Document.say_hello.AttachEvent('onclick',
EventHandler[HtmlEventArgs](event.ctl_sbutton1_onclick))
# another option
HtmlPage.Window.Invoke("registerDlrFn1",
EventHandler[HtmlEventArgs](event.ctl_sbutton1_onclick))
HtmlPage.Window.Invoke("registerDlrFn2",
EventHandler[HtmlEventArgs](event.ctl_sbutton2_onclick))
HtmlPage.Window.Invoke("registerDlrFn3",
EventHandler[HtmlEventArgs](event.ctl_sbutton3_onclick))
===============================================



More information about the Ironpython-users mailing list