《付録》exHoneyComb3.py

# -*- coding: utf-8 -*-
#===============================================================================
#    Copyright (C) 2000-2008, 小泉ひよ子とタマゴ倶楽部
#
# Change History: WPF examples
#    2008/01/25, IronPython 1.1.1 (download)
#    2008/08/22, IronPython 1.1.2 (download)
#    2008/03/16, ver.2.0, WPF
#    2008/00/00, ver.2.1, IronPython 1.1.2 
# Change History: Games
#    1988/05, Smalltalk
#    2004/09, Java
#    2005/02, C#
#    2005/03, Jython
#===============================================================================
from _ant import *
from System.Windows import *
from System.Windows.Input import Key

from HoneyCenter import *
## --------------------               
class ExWindow(Window):
    def __init__(self, Content=None, **args):
        self.InitializeComponent(Content)
        self.init()

    def InitializeComponent(self, Content):
        self.Content = LoadXaml(Content)
        
    def init(self):
        target = "canvas",
        self._Controls(target)

        self._honey = Honey(self)
        self.KeyDown += self._honey.keyDown

    def _Controls(self, target):
        controls = xaml_controls(self)
        for e in target:
            setattr(self, e, controls[e])
    
    def addShape(self, shape):
        self.canvas.Children.Add(shape)

## --------------------               
if __name__ == "__main__":
    import sys
    xaml = sys.argv[1]
    win = ExWindow(
        Title=__file__,
        Width=298, Height=286,
        Content=xaml,
        )
    Application().Run(win)

## --------------------