I am having a difficult time understanding the Pyjamas/GWT event handling system. I am currently using the latest 0.8 Pyjamas in order to test. I am not sure of what the best event handling structure would be as I have never done GUI programming.
I haven't had much luck with the documentation I've found thus far. Does anyone know of a good reference for Pyjamas or GWT?
My main difficulty comes from understanding where listeners such as onClick, onMouseleave, etc are coming from? How are they triggered? Where are they defined? Do I define them?
What is the layered structure for the event handling system?
I know these are very general questions but I'm really just looking for a point in the right direction.
Thank you and I appreciate any help given.
I would suggest you study source in examples folder. Start with this http://pyjs.org/book/output/Bookreader.html#Getting%20Started
There are some links which has been helpful for me: http://gwt.google.com/samples/Showcase/Showcase.html
Also in examples folder there is a great example called showcase
which gives you all API and some helpful code samples
/localhost/somedir/showcase/output/Showcase.html
since API is similar you can always check them books (especially helpful for understanding callback etc..) :
for Django and Pyjamas http://www.derekschaefer.net/2011/02/08/pyjamas-django-pure-win/
However i agree there is a great need for better introduction tutorials beyond the hello world example. I'm struggling with it myself. Good luck
ps. I've created small callback example that seems to work. I would be greatfull if people correct me here and edit this example to be of more use for people. All im trying to do here is to have navigation with 2 pages (represented by 2 classes: Intro and Outro )
import pyjd from pyjamas.ui.VerticalPanel import VerticalPanel from pyjamas.ui.RootPanel import RootPanel from pyjamas.ui.SimplePanel import SimplePanel from pyjamas.ui.DockPanel import DockPanel from pyjamas.ui.Hyperlink import Hyperlink from pyjamas.ui.Button import Button from pyjamas.ui.HTML import HTML from pyjamas import Window class Site(SimplePanel): def onModuleLoad(self): SimplePanel.__init__(self) self.panel = DockPanel() self.intro = Intro() self.outro = Outro() self.index = HTML('index') self.curPage = self.index vp=VerticalPanel() vp.add(self.index) self.link1 = Hyperlink('menu item 1') self.link2 = Hyperlink('menu item 2') self.link1.addClickListener(getattr(self, 'onLINK1')) self.link2.addClickListener(getattr(self, 'onLINK2')) self.panel.add(self.link1, DockPanel.WEST) self.panel.add(self.link2, DockPanel.WEST) self.panel.add(self.index, DockPanel.CENTER) RootPanel().add(self.panel) def onLINK1(self): self.panel.remove(self.curPage, DockPanel.CENTER) self.panel.add(self.intro, DockPanel.CENTER) self.curPage = self.intro def onLINK2(self): self.panel.remove(self.curPage, DockPanel.CENTER) self.panel.add(self.outro, DockPanel.CENTER) self.curPage = self.outro class Intro(SimplePanel): def __init__(self): SimplePanel.__init__(self) self.vp = VerticalPanel() self.html = HTML('This is intro') self.button = Button('click me', self) self.vp.add(self.html) self.vp.add(self.button) self.setWidget(self.vp) def onClick(self): Window.alert('onClick Intro') class Outro(SimplePanel): def __init__(self): SimplePanel.__init__(self) self.vp = VerticalPanel() self.html = HTML('This is outro') #we can do it this way self.button1 = Button('click me1', getattr(self, 'onBUTTON1')) self.button2 = Button('click me2') #or set up listener self.button2.addClickListener(getattr(self,'onBUTTON2')) self.vp.add(self.html) self.vp.add(self.button1) self.vp.add(self.button2) self.setWidget(self.vp) def onBUTTON1(self): Window.alert('hello from button1') def onBUTTON2(self): Window.alert('hello from button2') if __name__ == '__main__': pyjd.setup('./Site.html') app = Site() app.onModuleLoad() pyjd.run()