~divmod-dev/divmod.org/trunk

« back to all changes in this revision

Viewing changes to Nevow/examples/xul/xul_nevow.py

  • Committer: Jean-Paul Calderone
  • Date: 2014-06-29 20:33:04 UTC
  • mfrom: (2749.1.1 remove-epsilon-1325289)
  • Revision ID: exarkun@twistedmatrix.com-20140629203304-gdkmbwl1suei4m97
mergeĀ lp:~exarkun/divmod.org/remove-epsilon-1325289

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
from twisted.python import util
2
 
from nevow import rend, loaders, inevow, livepage
3
 
 
4
 
 
5
 
getValue = livepage.js('getValue')
6
 
changeLabel = livepage.js('changeLabel')
7
 
 
8
 
 
9
 
def onCommand(client, text):
10
 
    client.sendScript(changeLabel(text))
11
 
 
12
 
 
13
 
class XulApp(livepage.LivePage):
14
 
    addSlash = True
15
 
    docFactory = loaders.xmlfile(util.sibpath(__file__, 'xul_example.xul'))
16
 
 
17
 
    def locateChild(self, ctx, segments):
18
 
        inevow.IRequest(ctx).setHeader("Content-Type", "application/vnd.mozilla.xul+xml; charset=UTF-8")
19
 
        return rend.Page.locateChild(self, ctx, segments)
20
 
 
21
 
    def render_btn(self, ctx, data):
22
 
        return ctx.tag(oncommand=livepage.server.handle('onCommand', getValue('some-text')))
23
 
 
24
 
    def handle_onCommand(self, ctx, text):
25
 
        return changeLabel(text)
26
 
 
27
 
 
28
 
def createResource():
29
 
    return XulApp()
30