2007-06-06
■[Python]IronPythonでDnD
IronPythonを少しづつはじめたいとおもっている今日この頃。
実はC#とあんまし変わらないので生産性はあがってないんじゃなかろうか?
C#だと静的チェックがかなり入るし、補完が効くのでその分有利に見えちゃうな。
DnDしたファイルのファイルパスがListBoxに表示されるサンプル
Form.py
import System from System.Windows.Forms import * from System.ComponentModel import * from System.Drawing import * from clr import * class WindowsApplication6: # namespace class Form1(System.Windows.Forms.Form): """type(_listBox1) == System.Windows.Forms.ListBox""" __slots__ = ['_listBox1'] def __init__(self): self.InitializeComponent() @accepts(Self(), bool) @returns(None) def Dispose(self, disposing): super(type(self), self).Dispose(disposing) @returns(None) def InitializeComponent(self): self._listBox1 = System.Windows.Forms.ListBox() self.SuspendLayout() # # listBox1 # self._listBox1.AllowDrop = True self._listBox1.FormattingEnabled = True self._listBox1.ItemHeight = 12 self._listBox1.Location = System.Drawing.Point(12, 19) self._listBox1.Name = 'listBox1' self._listBox1.Size = System.Drawing.Size(413, 208) self._listBox1.TabIndex = 0 self._listBox1.DragEnter += self._drag_enter self._listBox1.DragDrop += self._drag_drop # # Form1 # self.AllowDrop = True self.ClientSize = System.Drawing.Size(709, 416) self.Controls.Add(self._listBox1) self.Name = 'Form1' self.Text = 'Form1' self.ResumeLayout(False) @accepts(Self(), System.Object, System.Windows.Forms.DragEventArgs) @returns(None) def _drag_enter(self, sender, e): if e.Data.GetDataPresent(DataFormats.FileDrop): e.Effect = DragDropEffects.All else: e.Effect = DragDropEffects.None @accepts(Self(), System.Object, System.Windows.Forms.DragEventArgs) @returns(None) def _drag_drop(self, sender, e): data = e.Data.GetData(DataFormats.FileDrop, False) for s in data: print self._listBox1.Items.Add(s)
デコレーターの嵐になるのは仕方ない。
VS2005に組み込んでるけどなんかイマイチ。
IronPythonはMicrosoftに染まりすぎてるのでなんだか使いにくい印象を覚えるな。
もう少し評価しないと。
うくく。
トラックバック - http://d.hatena.ne.jp/mopemope/20070606/p2
リンク元
- 12 http://d.hatena.ne.jp/higayasuo/
- 8 http://reader.livedoor.com/reader/
- 4 http://d.hatena.ne.jp/s2committer/
- 4 http://www.google.com/
- 4 http://www.google.com/reader/view/
- 3 http://d.hatena.ne.jp/shot6/
- 3 http://www.google.co.jp/ig?hl=ja
- 2 http://a.hatena.ne.jp/mshimura/
- 2 http://d.hatena.ne.jp/keyworddiary/Python
- 2 http://duogate.excite.co.jp/search.gw?search=php+Excel読み込み&target=combined&c=web&lk=duogatessr_jp&lang=jp

