1 """
2 Pyjamas UI BuilderWidget: takes a PyJsGlade builder spec
3 and creates a widget.
4
5 Copyright (C) 2010 Luke Kenneth Casson Leighton <lkcl@lkcl.net>
6
7 Create a BuilderWidget as follows::
8
9 from pyjamas.builder.Builder import Builder
10 from pyjamas.ui.BuilderWidget import BuilderWidget
11
12 either::
13
14 class ApplicationEventReceivingClassWhatever:
15
16 def onSomeRandomClickThing(self, sender):
17 print "some random widget was clicked, it was this one:", sender
18
19 app = ApplicationEventReceivingClassWhatever()
20 b = Builder()
21 xml = "<?xml .... ?><pyjsglade> .... </pyjsglade>"
22 bw = BuilderWidget(Builder=b,
23 EventReceiver=app,
24 BuilderText=xml_file,
25 InstanceName="WidgetListedInXmlFile")
26
27 or::
28
29 app = ApplicationEventReceivingClassWhatever()
30 xml = "<?xml .... ?><pyjsglade> .... </pyjsglade>"
31 b = Builder(xml)
32 bw = BuilderWidget(Builder=b,
33 EventReceiver=app,
34 InstanceName="WidgetListedInXmlFile")
35
36 or::
37
38 class BuilderWidgetWithIntegratedEventHandling(BuilderWidget):
39 def onSomeRandomClickThing(self, sender):
40 print "some random widget was clicked, it was this one:", sender
41
42 b = Builder(xml)
43 bw = BuilderWidgetWithIntegratedEventHandling(Builder=b,
44 InstanceName="WidgetListedInXmlFile")
45
46 or::
47
48 b = Builder()
49 bw = BuilderWidgetWithIntegratedEventHandling(Builder=b,
50 BuilderText=xml_file,
51 InstanceName="WidgetListedInXmlFile")
52
53 """
54
55 from pyjamas.ui.Composite import Composite
56
57
104