Sunday, December 14, 2008

IronPython - SIlverLight

Here is the adapted version of ScottGu sample


from System.Windows import Application
from System.Windows.Controls import UserControl

class App:

root = None

def MyButton_Click(self,s,e):
App.root.MyButton.Content = "Pushed"
App.root.Message.Text = "MyButton has been pushed"

def __init__(self):
App.root = Application.Current.LoadRootVisual(UserControl(), "app.xaml")
App.root.Message.Text = "Welcome to Python and Silverlight!"
App.root.MyButton.Content = "Push Me"
App.root.MyButton.Click += self.MyButton_Click

App()





The xaml code

<UserControl x:Class="System.Windows.Controls.UserControl"
xmlns="http://schemas.microsoft.com/client/2007"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">

<Grid x:Name="layout_root" Background="White">
<TextBlock x:Name="Message" FontSize="55" />
<Button x:Name="MyButton" Content="Push Me" Width="100" Height="50" />
<Grid>

</UserControl>

Silverlight 2 and app.xap

Found of Python, i was in search of running xap files from the filesytem without success
Until I read this post :
http://groups.google.co.il/group/ironpy/browse_thread/thread/b6459831ed03af57

"""
Srivatsn Narayanan
l'original | Signaler ce message | Rechercher les messages de cet auteur
I was running into the same issue but you can specifically ask Chiron to zip the app folder by doing:
Chiron /d:app /z:app.xap. The /z switch adds the dlr assemblies as well. This xap runs from cassini.
"""

Thanks Srivatsn