[IronPython] IronPython and WPF .. too cool
Greg Kerr
arkman3112 at gmail.com
Tue Oct 18 20:38:19 CEST 2005
Don't know if anyone wants to see it, or if everyone's way past it, but here
is a simple WPF app in IronPython:
import sys
sys.LoadAssemblyByName( "WindowsBase")
sys.LoadAssemblyByName( "PresentationCore")
sys.LoadAssemblyByName( "PresentationFramework")
sys.LoadAssemblyByName( "UIAutomationProvider")
sys.LoadAssemblyByName( "UIAutomationTypes")
from System import *
from System.Windows import *
from System.Windows.Controls import *
from System.Windows.Media import *
from System.Windows.Media.Animation import *
class MyApp (Application):
def __init__( self):
pass
def OnStartup( self, evt):
mainWindow = Window();
rootPanel = StackPanel();
rootPanel.Background = SolidColorBrush( Colors.Green);
txtElement = TextBlock()
txtElement.Margin = Thickness( 10)
txtElement.Text = "A TextBlock"
txtElement.FontSize = 24
txtElement.Foreground = SolidColorBrush( Colors.White)
mainWindow.Content = rootPanel
mainWindow.Title = "WPF Window from IronPython"
rootPanel.Children.Add( txtElement)
opacityAnim = DoubleAnimation( 0.0,
Duration(TimeSpan.FromMilliseconds(1000)))
opacityAnim.AutoReverse = True
opacityAnim.RepeatBehavior = RepeatBehavior.Forever
txtElement.BeginAnimation(Control.OpacityProperty, opacityAnim)
mainWindow.Show()
app = MyApp()
app.Run()
More information about the Ironpython-users
mailing list