# -*- coding: utf-8 -*-
#===============================================================================
# Copyright (C) 2000-2008, 小泉ひよ子とタマゴ倶楽部
#
# 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
#===============================================================================
from _ant import *
from System import *
from System.Windows import *
from System.Windows.Controls import *
from System.Windows.Media import *
from System.Windows.Media.Imaging import *
## --------------------
class Team:
def __iter__(self):
for e in self.teams():
yield e
def teams(self):
return [
"GER", "ECU", "POL", "CRC", # Group A
"ENG", "SWE", "PAR", "TRI", # Group B
"ARG", "NED", "CIV", "SCG", # Group C
"POR", "MEX", "ANG", "IRN", # Group D
"ITA", "GHA", "CZE", "USA", # Group E
"BRA", "AUS", "CRO", "JPN", # Group F
"SUI", "FRA", "KOR", "TOG", # Group G
"ESP", "UKR", "TUN", "KSA", # Group H
]
## --------------------
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 = "tabControl",
self._Controls(target)
for e in Team():
item = TabItem(
Header=e,
)
self.tabControl.Items.Add(item)
brush = ImageBrush(
ImageSource=BitmapImage(Uri("image/%s.gif"%e, UriKind.Relative))
)
item.Content = Canvas(
Width=50,
Height=50,
Background=brush,
)
self.tabControl.SelectionChanged += self.selectionChanged
def _Controls(self, target):
controls = xaml_controls(self)
for e in target:
setattr(self, e, controls[e])
def selectionChanged(self, sender, e):
s = sender.SelectedItem
print s.Header
## --------------------
if __name__ == "__main__":
xaml = __file__.replace(".py",".xaml")
win = ExWindow(
Title=xaml,
Width=300, Height=210,
Content=xaml,
)
Application().Run(win)
## --------------------