Archive@2007/12
Twitter Updates for 2007-12-27
- PILの使い方がやっとわかってきた #
Powered by Twitter Tools.
- Posted at:
- 2007/12/27 23:59:59
- 0 Comments
- 0 TrackBacks
- Tags:
- Trackback:
- http://blog.monospace.jp/2007/12/27/twitter-updates-for-2007-12-27/trackback/
Twitter Updates for 2007-12-26
- こくきんから電話あった。創業資金なんていくらかわからんわー。税金ちゃんと払ってるんだから貸してくれてもいいじゃんか。 #
- 信用金庫に電話してみた。くそー金借りる立場はつらいわ。つーか金貸してやってんじゃんかよー。 #
- iTunesStoreのギフトが今日ずっと買えません。「メールで送ってびっくりさせよう」ってさせれねーじゃんか。 #
- djangoのadminを改造して遊ぼうというひとり勉強会企画がある #
- @aodag それやりたいっすね #
Powered by Twitter Tools.
- Posted at:
- 2007/12/26 23:59:59
- 0 Comments
- 0 TrackBacks
- Tags:
- Trackback:
- http://blog.monospace.jp/2007/12/26/twitter-updates-for-2007-12-26/trackback/
Twitter Updates for 2007-12-25
- @aodag おもしろそうw #
- ちょっとPyObjCを書く #
- やっぱりなんかおかしいみたいだな。(PyObjC)QuartzまわりがXCode上で微妙という話。http://tinyurl.com/292s5f #
- ついでだしXcode使うのをやめてみよう。InterfaceBuilderは使うけど。 #
Powered by Twitter Tools.
- Posted at:
- 2007/12/25 23:59:59
- 0 Comments
- 0 TrackBacks
- Tags:
- Trackback:
- http://blog.monospace.jp/2007/12/25/twitter-updates-for-2007-12-25/trackback/
Twitter Updates for 2007-12-24
- 今日は働きますよ #
- ぬうーsafari2.0.4でうごかねーじゃん。非対応かな・・・http://dev.jquery.com/view/trunk/ui/current/tests/droppable.html #
- おー!activeClassとhoverClassの指定をやめたら動いた。 #
Powered by Twitter Tools.
- Posted at:
- 2007/12/24 23:59:59
- 0 Comments
- 0 TrackBacks
- Tags:
- Trackback:
- http://blog.monospace.jp/2007/12/24/twitter-updates-for-2007-12-24/trackback/
Twitter Updates for 2007-12-23
- 結局24時間経ってもパーティション変更おわらなかったので、外付けHDDを買ってきました。Firewire800初体験。 #
- 外付けHDDにTigerをインストールしたけど、ソフトウェアアップデートするとsafariが3になるのでできない・・・一個前までのアップデートとかしたい #
- Tigerを10.4.10にできたー。safari2.0.4だー。 #
Powered by Twitter Tools.
- Posted at:
- 2007/12/23 23:59:59
- 0 Comments
- 0 TrackBacks
- Tags:
- Trackback:
- http://blog.monospace.jp/2007/12/23/twitter-updates-for-2007-12-23/trackback/
Twitter Updates for 2007-12-22
- safari2が必要になったのでパーティション追加中。Leopardは便利だ。 #
- iDisk関係の何かが無駄に28GBも使ってたことが判明したので消してその領域を使うのです。 #
- QtにWebkit統合かあ。ちょっと気になる。 #
- パーティション変更まだおわらない #
Powered by Twitter Tools.
- Posted at:
- 2007/12/22 23:59:59
- 0 Comments
- 0 TrackBacks
- Tags:
- Trackback:
- http://blog.monospace.jp/2007/12/22/twitter-updates-for-2007-12-22/trackback/
PyObjCでCocoa探索 NSString編
昨日の続きでCocoaセミナーの移植しようと思ったんだけど、 明日(といってももう今日か)デザイン案提出の仕事があったんで遅くなってしまいました。 明日は忘年会だしなー。やるのはあさってかなー。 Twitter Updateに負けないようにブログをかかねばというのが課せられた義務なので、 一人勉強会シリーズとして、IPythonを使って、PyObjCでCocoaフレームワークのクラス探索していきます。 内容的に自信のないことばっか書くと思うので突っ込み頂けるとうれしいです。 まずはNSString。Cocoaにおける文字列型です。 from Foundation import NSStringで読み込めますが、 実は、from Cocoa import *って書くとCocoaに必要なもの全部読み込んでくれます。 [Python] >>> NSString <objective-c class NSString at 0xa01f7c4c> >>> NSString.alloc() #クラスをインスタンス化 <NSPlaceholderString objective-c instance 0x3b2950> #NSStringじゃないクラスができてる。 #これはNSStringがクラスクラスタなので、実際の作業は小人クラスたちが行っているってことらしいです。 >>> str = NSString.alloc().initWithString_('Hello') #イニシャライザ(コンストラクタ的な)はallocするついでに呼べます。 >>> str u'Hello' #ユニコード文字列ができてます。 >>> str.__class__ #クラスの確認 <type 'objc.pyobjc_unicode'> #NSString型じゃないっぽい? >>> str.isEqualTo_('Hello') #試しにNSStringのメソッド呼んでみる True #あ、ちゃんと呼べた。(あれー昨日呼べなかった気がしたけどw) >>> str.length() 5 #なんか問題なさそう。 >>> str[0:2] #Python的にスライスしてみる u'He' #いけた。 >>> str.upper() #Pythonの文字列型のメソッドを呼ぶ u'HELLO' #いける。万能オブジェクトじゃん。 >>> str = NSString.stringWithString_('Hello.jpg') #AutoreleasePoolに入れてインスタンス作成だけど、Pythonではどうなるかわかんない。 >>> str.pathExtension() #NSStringの拡張子を取り出すメソッド u'jpg' #ちなみにこれも<type 'objc.pyobjc_unicode'> [/Python] よく調べてみるとNSString型はPythonの文字列型が持ってない便利なメソッドを持ってたりするんで、 積極的に使う理由はあるかもですね。 次回は順当にNSArrayあたりでも。さて寝る。- Posted at:
- 2007/12/21 04:28:03
- 0 Comments
- 0 TrackBacks
- Tags:
- Trackback:
- http://blog.monospace.jp/2007/12/21/pyobjc-cocoa-nsstring/trackback/
Twitter Updates for 2007-12-20
Powered by Twitter Tools.
- Posted at:
- 2007/12/20 23:59:59
- 0 Comments
- 0 TrackBacks
- Tags:
- Trackback:
- http://blog.monospace.jp/2007/12/20/twitter-updates-for-2007-12-20/trackback/
Cocoaセミナーグラフィックス編@Apple Inc
Cocoaセミナーグラフィックス編 http://developer.apple.com/jp/briefing/cocoa.html というわけで東京にいってきました。 アップル社のなかのアップルマークが撮りたかったけど、携帯充電がギリギリで仕方なくあきらめました。 帰り際に仕事の電話かかってきたから多分正解でした。 セミナー中は、となりのVoluntasさんと二人してPyObjCで書こう大会を開いてたり、XcodeのエディタをつかわずにVimで書いたり。 アウトローな一面をかいま見せていました。まあ前日に今回の内容はやってあったので復習的な感じで楽しんでました。 で、結局PyObjCはCocoaな部分というかGUIな部分というか、必要になるまでObjC的なこと書かなくていいじゃんって結論になった(※1)んですけど、せっかくだからってことで、今回の資料を徹底的にObjCなPyObjCに移植してみました。Pythonの組み込み型はほぼ使ってません。 ※1 NSStringとかNSArrayとかNSDictionaryとかObjCなオブジェクトがPyObjCにはちゃんとあるんですが、これをPythonの組み込み型で代用できてしまうので使う必要ないねって話。ディレクトリあさるのもos.walkしたらいいしって。ちなみにそういうバージョンはすでにVoluntasさんが公開してます。 では、無駄な努力の結晶をどうぞ。変数名がCamelCaseなのは今回の仕様です。 あとメソッド名がやたら長いのとたまに_で終わってるメソッドがあるのはPyObjCの仕様です。 ちなみにInterfaceBuilderでの作業はObjC版とまったく一緒です。 Cocoaセミナーグラフィックス編 資料 http://developer.apple.com/jp/documentation/Cocoa/Seminar/CocoaGraphics/CocoaGraphics.zip [python] #BrowserView.py from objc import YES, NO, NULL, nil from Foundation import * from AppKit import * WIDTH = 200.0 HEIGHT = 200.0 MARGIN = 20.0 class BrowserView(NSView): def initWithFrame_(self, frame): self = super(BrowserView, self).initWithFrame_(frame) if self: self.clickPoint = NSPoint() self.images = NSMutableArray.array() dirPath = NSString.stringWithString_('/Library/Desktop Pictures') subPaths = NSFileManager.defaultManager().subpathsOfDirectoryAtPath_error_(dirPath, NULL) for subPath in subPaths[0]: if subPath.nsstring().pathExtension().isEqualTo_('jpg'): path = dirPath.nsstring().stringByAppendingPathComponent_(subPath) image = NSImage.alloc().initWithContentsOfFile_(path) imageInfo = NSDictionary.dictionaryWithObjectsAndKeys_( path, NSString.stringWithString_('path'), image, NSString.stringWithString_('image'), nil) self.images.addObject_(imageInfo) if self.images.count() >= 10: break return self def isFlipped(self): return YES def mouseDown_(self, event): self.clickPoint = self.convertPoint_fromView_(event.locationInWindow(), nil) self.setNeedsDisplay_(YES) def drawRect_(self, rect): srcRect = NSRect() dstRect = NSRect() dstRect.origin.x = MARGIN dstRect.origin.y = MARGIN dstRect.size.width = WIDTH dstRect.size.height = HEIGHT for imageInfo in self.images: image = imageInfo.objectForKey_(NSString.stringWithString_('image')) srcRect.origin = NSZeroPoint srcRect.size = image.size() if srcRect.size.width > srcRect.size.height: dstRect.size.width = WIDTH dstRect.size.height = (srcRect.size.height / srcRect.size.width) * HEIGHT else: dstRect.size.width = (srcRect.size.width / srcRect.size.height) * HEIGHT dstRect.size.height = HEIGHT image.drawInRect_fromRect_operation_fraction_( dstRect, srcRect, NSCompositeCopy, 1.0) title = imageInfo.objectForKey_(NSString.stringWithString_('path')).lastPathComponent() attrs = NSDictionary.dictionaryWithObjectsAndKeys_( NSFont.systemFontOfSize_(12.0), NSFontAttributeName, NSColor.blackColor(), NSForegroundColorAttributeName, nil) attrStr = NSAttributedString.alloc().initWithString_attributes_(title, attrs) point = NSPoint() point.x = NSMinX(dstRect) point.y = NSMaxY(dstRect) attrStr.drawAtPoint_(point) if NSPointInRect(self.clickPoint, dstRect): NSColor.redColor().set() focusRect = NSInsetRect(dstRect, -1.0, -1.0) bezierPath = NSBezierPath.bezierPathWithRect_(focusRect) bezierPath.setLineWidth_(2.0) bezierPath.stroke() dstRect.origin.x += WIDTH + MARGIN if NSMaxX(dstRect) > rect.size.width: dstRect.origin.x = MARGIN dstRect.origin.y += HEIGHT + MARGIN [/python]- Posted at:
- 2007/12/20 04:29:55
- 0 Comments
- 0 TrackBacks
- Tags:
- Trackback:
- http://blog.monospace.jp/2007/12/20/cocoa-seminar-graphics/trackback/
Twitter Updates for 2007-12-19
- 新幹線で東京へ #
- アップルにきたです。Cocoaセミナーはじまるお #
- 当然ですが、マック率100%。しかもLeopard #
- 名古屋に戻って参りました。盛り上がってるうちにObjCやろーっと #
- LOST (シーズン3)のDVDレンタルは12月19日から開始。頼むから早く積もり積もった謎を教えてください。 #
- 何が始まるのか期待。ドメイン取得は1年前かー。http://pyobjc.org/ #
Powered by Twitter Tools.
- Posted at:
- 2007/12/19 23:59:59
- 0 Comments
- 0 TrackBacks
- Tags:
- Trackback:
- http://blog.monospace.jp/2007/12/19/twitter-updates-for-2007-12-19/trackback/