Freigeben über


Why Pythalon?

Looking at the last point on its own grounds, you may think:  "Okay, you can program Avalon in Python.  So what?  I'm a C#/VB/C++ programmer...I need to learn Python why??"

The reason Pythalon is so fun is that it is interactive.  The programs in the previous listings are just Avalon apps written in a different language, but here's the console output from an interactive session using those programs:

import SnowFlake

p = SnowFlake.drawFlake(RootElement, 4)

p
<System.Windows.Shapes.Path object at 0x025BB5FF>

p.Fill
#FF00FFFF

p.Fill = Brushes.Red

p.Fill
#FFFF0000

t = ScaleTransform(2.0, 1.5)

t
scale(2 1.5)

p.RenderTransform = t

The visuals will have to wait...but the idea is, you can explore the Avalon OM interactively.  Play with it even more than you can with a live Xaml editor like AvPad.  Btw -- Python is a highly reflective language naturally.  The builtin dir() method lets you inspect any object (and classes are objects).  So for example:

p
<System.Windows.Shapes.Path object at 0x025BB5FF>

dir(p)
['ActualHeight', 'ActualWidth', 'AddHandler', 'AddToEventRoute', 'AllowDrop', 'AnimationEffects', 'Arrange', 'BeginInit', 'BringIntoView', 'CaptureMouse', 'CaptureStylus', 'CheckAccess', 'ClearValue', 'Clip', 'ClipToBounds', 'CommandBindings', 'ContextMenu', 'ContextMenuClosing', 'ContextMenuOpening', 'CultureInfo', 'Cursor', 'Data', 'DataContext', 'DataContextChanged', 'DataProperty', 'DependencyObjectType', 'DesiredSize', 'DetachFromDispatcher', 'Dispatcher', 'DragEnter', 'DragLeave', 'DragOver', 'Drop', 'EndInit', 'EnsureVisuals', 'Equals', 'Fill', 'FillRule', 'FillRuleProperty', 'FindName', 'FindResource', 'FindStoryboardClock', 'FlowDirection', 'Focus', 'FocusVisualStyle', 'Focusable', 'ForceCursor', 'GeometryTransform', 'GetAnimationBaseValue', 'GetAnimationClocks', 'GetBindingExpression', 'GetHashCode', 'GetLocalValueEnumerator', 'GetRoutedEventsWithHandlers', 'GetType', 'GetValue', 'GetValueBase', 'GiveFeedback', 'GotFocus', 'GotFocusTarget', 'GotMouseCapture', 'GotStylusCapture', 'HasAnimatedProperties', 'Height', 'HorizontalAlignment', 'Initialized', 'InputBindings', 'InputHitTest', 'InputScope', 'InvalidateArrange', 'InvalidateMeasure', 'InvalidateProperty', 'IsArrangeValid', 'IsEnabled', 'IsEnabledChanged', 'IsFocusTarget', 'IsFocusWithin', 'IsFocusWithinChanged', 'IsFocused', 'IsFocusedChanged', 'IsInitialized', 'IsInputMethodEnabled', 'IsLoaded', 'IsMeasureValid', 'IsMouseCaptured', 'IsMouseCapturedChanged', 'IsMouseDirectlyOver', 'IsMouseDirectlyOverChanged', 'IsMouseOver', 'IsStylusCaptured', 'IsStylusCapturedChanged', 'IsStylusDirectlyOver', 'IsStylusDirectlyOverChanged', 'IsStylusOver', 'IsVisible', 'IsVisibleChanged', 'KeyDown', 'KeyUp', 'LayoutTransform', 'LayoutUpdated', 'Loaded', 'LostFocus', 'LostFocusTarget', 'LostMouseCapture', 'LostStylusCapture', 'Margin', 'MaxHeight', 'MaxWidth', 'Measure', 'MinHeight', 'MinWidth', 'MouseEnter', 'MouseLeave', 'MouseLeftButtonDown', 'MouseLeftButtonUp', 'MouseMove', 'MouseRightButtonDown', 'MouseRightButtonUp', 'MouseWheel', 'Name', 'Opacity', 'OpacityMask', 'Parent', 'PersistId', 'PersistentAnimations', 'PreviewDragEnter', 'PreviewDragLeave', 'PreviewDragOver', 'PreviewDrop', 'PreviewGiveFeedback', 'PreviewGotFocus', 'PreviewKeyDown', 'PreviewKeyUp', 'PreviewLostFocus', 'PreviewMouseLeftButtonDown', 'PreviewMouseLeftButtonUp', 'PreviewMouseMove', 'PreviewMouseRightButtonDown', 'PreviewMouseRightButtonUp', 'PreviewMouseWheel', 'PreviewQueryContinueDrag', 'PreviewStylusButtonDown', 'PreviewStylusButtonUp', 'PreviewStylusDown', 'PreviewStylusInAirMove', 'PreviewStylusInRange', 'PreviewStylusMove', 'PreviewStylusOutOfRange', 'PreviewStylusSystemGesture', 'PreviewStylusUp', 'PreviewTextInput', 'QueryContinueDrag', 'QueryCursor', 'RaiseEvent', 'ReadLocalValue', 'ReleaseMouseCapture', 'ReleaseStylusCapture', 'RemoveHandler', 'RenderSize', 'RenderTransform', 'RenderedGeometry', 'RequestBringIntoView', 'Resources', 'SetBinding', 'SetPersistId', 'SetResourceReference', 'SetValue', 'SetValueBase', 'SizeChanged', 'SourceUpdated', 'Storyboards', 'Stretch', 'Stroke', 'StrokeDashArray', 'StrokeDashCap', 'StrokeDashOffset', 'StrokeEndLineCap', 'StrokeLineJoin', 'StrokeMiterLimit', 'StrokeStartLineCap', 'StrokeThickness', 'Style', 'StylusButtonDown', 'StylusButtonUp', 'StylusDown', 'StylusEnter', 'StylusInAirMove', 'StylusInRange', 'StylusLeave', 'StylusMove', 'StylusOutOfRange', 'StylusSystemGesture', 'StylusUp', 'Tag', 'TargetUpdated', 'TemplatedParent', 'TextInput', 'ThemeStyleKey', 'ToString', 'ToolTip', 'ToolTipClosing', 'ToolTipOpening', 'TranslatePoint', 'TraverseFocus', 'Triggers', 'Unloaded', 'UpdateLayout', 'VerifyAccess', 'VerticalAlignment', 'Visibility', 'Width', '__new__']

It's not Reflector, but it is pretty cool.