IronPython 2.0 RTW + Silverlight 2.0
15-Apr-15 : Please ignore -- obsolete technologies
Following on from the β2 sample…
Changes made as follows:
- web page page, silverlight object type : type="application/x-silverlight-2"
- web page, fallback download location : "http://go.microsoft.com/fwlink/?LinkID=124807"
- AppManifest :
RuntimeVersion="2.0.31005.0"
- AppManifest : add
<AssemblyPart Source="Microsoft.Scripting.ExtensionAttribute.dll" />
- AppManifest : remove
<AssemblyPart Name="System.Windows.Controls.Extended" Source="System.Windows.Controls.Extended.dll" />
- app.py -- remove the line
clr.AddReference('System.Windows.Controls.Extended, Version=2.0.5.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35')
- Delete all earlier assemblies and use all the assemblies from C:\Program Files\IronPython 2.0\Silverlight\bin.
Or, from scratch, with the embedding paged base around C:\Program Files\IronPython 2.0\Silverlight\script\templates\python\index.html
...
app.py
import clr | |
from System.Windows import Application, Thickness | |
from System.Windows.Controls import ( | |
Button, Canvas, Orientation, | |
StackPanel, TextBox #WatermarkedTextBox | |
) | |
xaml = Application.Current.LoadRootVisual(Canvas(), "app.xaml") | |
textblock = xaml.FindName('textblock') | |
panel = StackPanel() | |
panel.Margin = Thickness(50) | |
panel.Orientation = Orientation.Horizontal | |
button = Button() | |
button.Content = 'Push Me' | |
button.FontSize = 18 | |
button.Margin = Thickness(10) | |
waterbox = TextBox() #WatermarkedTextBox() | |
waterbox.FontSize = 18 | |
waterbox.Margin = Thickness(10) | |
waterbox.Width = 200 | |
#waterbox.Watermark = 'Type Something Here' | |
def onClick(s, e): | |
textblock.Text = waterbox.Text | |
button.Click += onClick | |
panel.Children.Add(button) | |
panel.Children.Add(waterbox) | |
xaml.Children.Add(panel) |
app.xaml
<Canvas | |
x:Class="System.Windows.Controls.Canvas" | |
xmlns="http://schemas.microsoft.com/client/2007" | |
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | |
x:Name="parentCanvas"> | |
<TextBlock x:Name="textblock" FontSize="18" Canvas.Top="10" Canvas.Left="50">Stuff Goes Here</TextBlock> | |
</Canvas> |
AppManifest.xaml
<Deployment xmlns="http://schemas.microsoft.com/client/2007/deployment" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" RuntimeVersion="2.0.31005.0" EntryPointAssembly="Microsoft.Scripting.Silverlight" EntryPointType="Microsoft.Scripting.Silverlight.DynamicApplication"> | |
<Deployment.Parts> | |
<!-- Add additional assemblies here --> | |
<AssemblyPart Source="Microsoft.Scripting.dll" /> | |
<AssemblyPart Source="Microsoft.Scripting.Core.dll" /> | |
<AssemblyPart Source="Microsoft.Scripting.ExtensionAttribute.dll" /> | |
<AssemblyPart Source="IronPython.dll" /> | |
<AssemblyPart Source="IronPython.Modules.dll" /> | |
<AssemblyPart Name="Microsoft.Scripting.Silverlight" Source="Microsoft.Scripting.Silverlight.dll" /> | |
</Deployment.Parts> | |
</Deployment> |
The XAP file is now down to 935kb, which considerably closes the gap with Jython 2.2.1's 670k but is still noticeably larger than a minimal Jython 2.1 applet:
274467 Aug 13 21:48 applet.jar 956662 Dec 13 17:50 app.xap 2266 Dec 13 17:53 index.html 2071 Aug 13 22:02 jython.html
However, now both products are at a stable release, it starts to make sense to actually use the technology.
No comments :
Post a Comment