[IronPython] Silverlight - animation from code

Michael Foord fuzzyman at voidspace.org.uk
Fri Mar 21 00:25:36 CET 2008


Jimmy Schementi wrote:
> Yep, got it working too (http://jimmy.schementi.com/silverlight/font-grow.zip). This is against the IronPython bits from http://dynamicsilverlight.net/get/.
>
> However, I have reproduced what you're talking about in dlrconsole (http://dynamicsilverlight.net/see/dlrconsole), which uses the older ironpython bits shipped in the Silverlight SDK. If you type Michael's code in there, it prints "Starting" but the font size never changes (note: the "root" referenced in Michael's code is the same as "canvas" in dlrconsole, so simply do "root = canvas" before typing in the code ... and sorry that there's no copy/paste! I guess that should be fixed =P)
>
> Michael, which set of bits are you using?
>   

I'm actually using the binaries that Dino gave me - which if anything 
should be more up to date than the ones from dynamicsilverlight.net. 
Perhaps it is something to do with the environment as I was testing it 
in my 'webide' which is a fairly similar environment to the DLRConsole. 
I've just got into London and will try it as a standalone script when I 
get home.

Thanks for trying this for me - and great to meet you Harry.

Michael

> ~Jimmy
>
>   
>> -----Original Message-----
>> From: users-bounces at lists.ironpython.com [mailto:users-
>> bounces at lists.ironpython.com] On Behalf Of Michael Foord
>> Sent: Thursday, March 20, 2008 12:31 AM
>> To: Discussion of IronPython
>> Subject: Re: [IronPython] Silverlight - animation from code
>>
>> Srivatsn Narayanan wrote:
>>     
>>> It worked for me. The text became bigger onmouseover. I did a
>>>       
>> root=Application.Current.LoadRootVisual(Canvas(), "app.xaml") with the
>> xaml having nothing but a Canvas[jimmysch] from
>>     
>> Odd - doesn't work for me. Hopefully I'll get the 'web ide' up soon so
>> that other people can poke it for me.
>>
>> Michael
>>
>>     
>>> -----Original Message-----
>>> From: users-bounces at lists.ironpython.com [mailto:users-
>>>       
>> bounces at lists.ironpython.com] On Behalf Of Michael Foord
>>     
>>> Sent: Wednesday, March 19, 2008 11:43 PM
>>> To: Discussion of IronPython
>>> Subject: [IronPython] Silverlight - animation from code
>>>
>>> Any idea why the following code does nothing? (root is the
>>>       
>> application
>>     
>>> root visual - the textblock becomes visible and 'starting' is
>>> printed
>>>       
>> at
>>     
>>> the right time - but the fint size doesn't change as I would expect
>>>       
>> from
>>     
>>> the Silverlight docs.)
>>>
>>> from System import TimeSpan
>>> from System.Windows import Duration
>>> from System.Windows.Controls import TextBlock from
>>> System.Windows.Media.Animation import (
>>>     DoubleAnimation, Storyboard
>>> )
>>>
>>> root.Children.Clear()
>>> root.Resources.Clear()
>>>
>>> t = TextBlock()
>>> t.FontSize = 20
>>> t.Text = 'Something Blue'
>>> root.Children.Add(t)
>>>
>>> sb = Storyboard()
>>> duration = Duration(TimeSpan.FromSeconds(2)) a = DoubleAnimation()
>>> a.Duration = duration sb.Duration = duration
>>> sb.Children.Add(a)
>>>
>>> Storyboard.SetTarget(a, t)
>>> Storyboard.SetTargetProperty(a, 'FontSize') a.From = 20 a.To = 40
>>>
>>> def anim(s, e):
>>>     print 'Starting'
>>>     sb.Begin()
>>>
>>> t.MouseEnter += anim
>>>
>>> root.Resources.Add(sb)
>>>
>>>
>>>
>>> _______________________________________________
>>> Users mailing list
>>> Users at lists.ironpython.com
>>> http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
>>> _______________________________________________
>>> Users mailing list
>>> Users at lists.ironpython.com
>>> http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
>>>
>>>       
>> _______________________________________________
>> Users mailing list
>> Users at lists.ironpython.com
>> http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
>>     
> _______________________________________________
> Users mailing list
> Users at lists.ironpython.com
> http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
>   




More information about the Ironpython-users mailing list