2008-01-01から1ヶ月間の記事一覧

ButtonMenu_Forms.py

Windows Forms アプリケーションとして、IronPython で実現した事例を紹介します。 # -*- coding: utf-8 -*- #=============================================================================== # Copyright (C) 2000-2008, 小泉ひよ子とタマゴ倶楽部 # # …

《参考文献》

C# Design Patterns 22. The Command Pattern.

RedButton.cs

class RedButton(Button, Command): def Execute(self): c = self.Parent c.BackColor = Color.Red self.BackColor = Color.LightGray System.Windows.Forms.Button を拡張しています。

FileExit.cs

class FileExit(MenuItem, Command): def __init__(self, frm): self.Text = "Exit" # base("Exit") self.form = frm System.Windows.Forms.MenuItem を拡張しています。 base() に代えて、プロパティー .Text を設定しています。 def Execute(self): self.f…

C#.use(better, IronPython="GoF") 《記事一覧》 Bridge〈Windows Forms〉Strategy -- pay a tribute to "C# Design Patterns" by James William Cooper 《著》小粒ちゃん《監修》小泉ひよ子とタマゴ倶楽部第1版♪2008/01/15 ● 改訂♪2008/10/08

~/home_Jython/apple_/swingBeans/swingTimer2.py

|INDEX| Python.use(better, Java) #Jython How to Use Buttons, Check Boxes, and Radio Buttons (The Java™ Tutorials > Creating a GUI With JFC/Swing > Using Swing Components) ¶ 》作業中です《 #! /usr/bin/env python # coding: utf-8 ## -------…

《参考文献》

C# Design Patterns 24. The Iterator Pattern.

__main__

if __name__ == "__main__": form = SimpleIterator_Forms() form.Text = form.__class__.__name__ Application.Run(form) 50free.txt

Form1.cs

class SimpleIterator_Forms(Form): def __init__(self, **args): self.InitializeComponent() self.init() def init(self): kids = KidData("50free.txt") for kd in kids: self.lsKids.Items.Add(kd.frname+" "+kd.lname) def InitializeComponent(self): …

KidData.cs

class KidData: # IEnumerator def __init__(self, filename): self.kids = [] # ArrayList fl = csFile(filename) for line in fl.file().readlines(): kd = Kid(line) self.kids.append(kd) else: fl.close() self.index = 0 ArrayList に代えて、list を…

Kid.cs

class Kid: def __init__(self, line): hash = {} # Hashtable for name, value in zip( ["lnum", "frname", "lname", "age", "club", "time"], tuple(line.split()), ): setattr(self, name, value) Hashtable に代えて、dict を利用しています。 StringTok…

SimpleIterator_Forms.py

Windows Forms アプリケーションとして、IronPython で実現した事例を紹介します。 # -*- coding: utf-8 -*- #=============================================================================== # Copyright (C) 2000-2008, 小泉ひよ子とタマゴ倶楽部 # # …

C#.use(better, IronPython=”GoF”) # Iterator〈Forms〉

C#.use(better, IronPython="GoF") 《記事一覧》 Iterator〈Windows Forms〉SimpleIterator -- pay a tribute to "C# Design Patterns" by James William Cooper 《著》小粒ちゃん《監修》小泉ひよ子とタマゴ倶楽部第1版♪2008/01/15 ● 改訂♪2008/10/19

__main__

if __name__ == "__main__": form = ButtonMenu_Form() form.Text = form.__class__.__name__ Application.Run(form)

Form1.cs

class ButtonMenu_Form(Form): def __init__(self, **args): self.InitializeComponent() self.init() def init(self): main = MainMenu() self.Menu = main evh = self.commandClick self.btRed.Click += evh file = MenuItem("File") main.MenuItems.Add(f…

FileOpen.cs

class FileOpen(MenuItem, Command): def __init__(self): self.Text = "Open" # base("Open") System.Windows.Forms.MenuItem を拡張しています。 base() に代えて、プロパティー .Text に値を設定しています。 def Execute(self): fd = OpenFileDialog() f…

Command.cs

class Command: # interface Command def Execute(self): raise NotImplementedError("Execute") interface に代えて、例外 NotImplementedError を生成しています。

ButtonMenu_Forms.py

Windows Forms アプリケーションとして、IronPython で実現した事例を紹介します。 # -*- coding: utf-8 -*- #=============================================================================== # Copyright (C) 2000-2008, 小泉ひよ子とタマゴ倶楽部 # # …

《参考文献》

C# Design Patterns 22. The Command Pattern.

RedButton.cs

class RedButton(Button, Command): def Execute(self): c = self.Parent c.BackColor = Color.Red self.BackColor = Color.LightGray System.Windows.Forms.Button を拡張しています。

FileExit.cs

class FileExit(MenuItem, Command): def __init__(self, frm): self.Text = "Exit" # base("Exit") self.form = frm System.Windows.Forms.MenuItem を拡張しています。 base() に代えて、プロパティー .Text に値を設定しています。 def Execute(self): se…

C#.use(better, IronPython=”GoF”) # Command〈Forms〉

C#.use(better, IronPython="GoF") 《記事一覧》 Command〈Windows Forms〉ButtonMenu -- pay a tribute to "C# Design Patterns" by James William Cooper 《著》小粒ちゃん《監修》小泉ひよ子とタマゴ倶楽部第1版♪2008/01/15 ● 改訂♪2008/10/03

__main__

if __name__ == "__main__": form = SimpleComposite_Form() form.Text = form.__class__.__name__ Application.Run(form)

Form1.cs

class SimpleComposite_Form(Form): def init(self): self.rand = Random() self.buildEmployeeList() self.buildTree() def buildEmployeeList(self): self.prez = Employee("CEO", 200000) marketVP = Employee("Marketing VP", 100000) self.prez.add(mar…

Employee.cs

class Employee: def __init__(self, nm, salry): self.subordinates = [] # ArrayList self.name = nm self.salary = salry ArrayList に代えて、list を利用しています。 def getSalary(self): return self.salary def getName(self): return self.name de…

EmpNode.cs

class EmpNode(TreeNode): TreeNode を拡張しています。 def __init__(self, aemp): self.Text = aemp.name # base(aemp.getName ()) self.emp = aemp def getEmployee(self): return self.emp base() に代えて、プロパティー .Text を設定しています。

SimpleComposite_Forms.py

Windows Forms アプリケーションとして、IronPython で実現した事例を紹介します。 # -*- coding: utf-8 -*- #=============================================================================== # Copyright (C) 2000-2008, 小泉ひよ子とタマゴ倶楽部 # # …

《参考文献》

C# Design Patterns 16. The Composite Pattern.

C#.use(better, IronPython=”GoF”) # Composite〈Forms〉

C#.use(better, IronPython="GoF") 《記事一覧》 Composite〈Windows Forms〉SimpleComposite -- pay a tribute to "C# Design Patterns" by James William Cooper 《著》小粒ちゃん《監修》小泉ひよ子とタマゴ倶楽部第1版♪2008/01/15 ● 改訂♪2008/10/01

__main__

if __name__ == "__main__": form = BasicBridge_Form() form.Text = form.__class__.__name__ Application.Run(form)