初日
仕事終了後、東京駅で待ち合わせ。東海道線で移動。
近況などの情報交換をする。やること決めてなかたので考える。
旅館着いてすぐに温泉。みなは会議室でプログラミング中。
やること確定してなかったのでDjangoのソースを見直す。
3時くらいに寝る。
二日目
8時起き。朝ごはん。
以前から気になってたGWTっぽいPyjamasを触る。サンプル豊富。ドキュメント少ない。
買出しに行く。バナナ全種。
買出し完了後にプログラミングとPyjamasのドキュメント再読。買出しで汗かいたので温泉。
そしてPyjamasのプログラミング。
大盛り上がりのジャンケン大会でオライリーのシールもらう。そしてオライリーさんありがとうございます。
jsdo.itでこの前コードを少し書いたからそれを移植。
Java使いでGWT触ってたことがある方がいたので捕まえて教えてもらう。ありがとうございます!
import pyjd # dummy in pyjs from pyjamas import Window from pyjamas.ui.HorizontalPanel import HorizontalPanel from pyjamas.ui.RootPanel import RootPanel from pyjamas.Canvas import Color from pyjamas.Canvas.GWTCanvas import GWTCanvas from pyjamas.ui.ClickListener import ClickHandler from pyjamas.ui.MouseListener import MouseHandler class ExtGWTCanvas(GWTCanvas, ClickHandler, MouseHandler): def __init__(self, **kwargs): GWTCanvas.__init__(self, **kwargs) ClickHandler.__init__(self) MouseHandler.__init__(self) styles = [ { 'x': 0, 'y': 0, 'color': 'rgb(0, 0, 0)' }, { 'x': 21, 'y': 0, 'color': 'rgb(153, 153, 153)' }, { 'x': 42, 'y': 0, 'color': 'rgb(153, 0, 0)' }, { 'x': 63, 'y': 0, 'color': 'rgb(153, 153, 0)' }, { 'x': 84, 'y': 0, 'color': 'rgb(0, 153, 0)' }, { 'x': 105, 'y': 0, 'color': 'rgb(0, 153, 153)' }, { 'x': 126, 'y': 0, 'color': 'rgb(0, 0, 153)' }, { 'x': 147, 'y': 0, 'color':'rgb(153, 0, 153)' }, { 'x': 168, 'y': 0, 'color': 'rgb(153, 153, 68)' }, { 'x': 189, 'y': 0, 'color': 'rgb(0, 68, 68)' }, { 'x': 210, 'y': 0, 'color': 'rgb(0, 153, 255)' }, { 'x': 231, 'y': 0, 'color': 'rgb(0, 68, 153)' }, { 'x': 252, 'y': 0, 'color': 'rgb(153, 0, 255)' }, { 'x': 273, 'y': 0, 'color': 'rgb(153, 68, 0)' }, # 二列目 { 'x': 0, 'y': 21, 'color': 'rgb(255, 255, 255)' }, { 'x': 21, 'y': 21, 'color': 'rgb(204, 204, 204)' }, { 'x': 42, 'y': 21, 'color':'rgb(255, 0, 0)' }, { 'x': 63, 'y': 21, 'color': 'rgb(255, 255, 0)' }, { 'x': 84, 'y': 21, 'color': 'rgb(0, 255, 0)' }, { 'x': 105, 'y': 21, 'color': 'rgb(0, 255, 255)' }, { 'x': 126, 'y':21, 'color':'rgb(0, 0, 255)' }, { 'x': 147, 'y': 21, 'color': 'rgb(255, 0, 255)' }, { 'x': 168, 'y': 21, 'color': 'rgb(255, 255, 153)' }, { 'x': 189, 'y': 21, 'color': 'rgb(0, 255, 153)' }, { 'x': 210, 'y': 21, 'color': 'rgb(0, 68, 153)' }, { 'x': 231, 'y': 21, 'color': 'rgb(153, 153, 255)' }, { 'x': 252, 'y': 21, 'color': 'rgb(255, 0, 153)' }, { 'x': 273, 'y': 21, 'color': 'rgb(255, 153, 68)' } ] width = 20; height = 20; class Paletee(object): def onModuleLoad(self): self.layout = HorizontalPanel() # Each demo will set their own dimensions, so it doesn't matter # what we initialize the canvas to. canvas_context = ExtGWTCanvas(coordX=400, coordY=400, pixelX=400, pixelY=400) canvas_context.addStyleName("gwt-canvas") # カラーパレットの色 canvas_context.beginPath(); # 全体を灰色にする canvas_context.setFillStyle(Color.Color('rgb(221, 221, 221)')); canvas_context.fillRect(0, 0, 300, 300); # 白色線の枠を設ける canvas_context.setFillStyle(Color.Color('rgb(253, 253, 253)')); canvas_context.fillRect(48, 48, 204, 204); # 灰色線の枠を設ける canvas_context.setFillStyle(Color.Color('rgb(225, 225, 225)')); canvas_context.fillRect(49, 49, 202, 202); # 初期色である黒色を設定する canvas_context.setFillStyle(Color.Color('rgb(0, 0, 0)')); canvas_context.fillRect(50, 50, 200, 200); canvas_context.closePath(); RootPanel().add(canvas_context) # カラーパレットの選択色を描画 canvas_context.beginPath() for style in styles: canvas_context.setFillStyle(style.get('color')) canvas_context.fillRect(style.get('x')+3, style.get('y')+3, width, height) canvas_context.closePath() # クリックイベントの付与 canvas_context.addMouseListener(selectColorClickLisner(canvas_context)) class selectColorClickLisner(object): # カラーパレットの選択 def __init__(self, canvas_context): self.canvas_context = canvas_context def onMouseMove(self, sender, x, y): pass def onMouseDown(self, sender, x, y): for style in styles: if style.get('x') < x and (x < style.get('x') + width) and style.get('y') < y and y < (style.get('y') + height): self.canvas_context.beginPath() self.canvas_context.setFillStyle(style.get('color')) self.canvas_context.fillRect(50, 50, 200, 200) self.canvas_context.closePath() else: pass def onMouseUp(self, sender, x, y): pass def onMouseEnter(self, sender): pass def onMouseLeave(self, sender): pass if __name__ == "__main__": pyjd.setup("./public/Paletee.html") app = Paletee() app.onModuleLoad() pyjd.run()
JavaのインターフェースがPythonにはないので、気づくの遅れていた。無念。
Pyjamas自体はクラスレベルのドキュメントが少ないのでコードリーディングしないとだめ。
2時くらいには寝る。
追記
詳細を付け足すかも。
あー。日本代表はワールドカップで負けた。