Package pyjamas :: Package ui :: Module BuilderWidget
[hide private]
[frames] | no frames]

Module BuilderWidget

source code

Pyjamas UI BuilderWidget: takes a PyJsGlade builder spec and creates a widget.

Copyright (C) 2010 Luke Kenneth Casson Leighton <lkcl@lkcl.net>

Create a BuilderWidget as follows:

   from pyjamas.builder.Builder import Builder
   from pyjamas.ui.BuilderWidget import BuilderWidget

either:

   class ApplicationEventReceivingClassWhatever:

       def onSomeRandomClickThing(self, sender):
           print "some random widget was clicked, it was this one:", sender

       app = ApplicationEventReceivingClassWhatever()
       b = Builder()
       xml = "<?xml .... ?><pyjsglade> .... </pyjsglade>"
       bw = BuilderWidget(Builder=b,
                          EventReceiver=app,
                          BuilderText=xml_file,
                          InstanceName="WidgetListedInXmlFile")

or:

   app = ApplicationEventReceivingClassWhatever()
   xml = "<?xml .... ?><pyjsglade> .... </pyjsglade>"
   b = Builder(xml)
   bw = BuilderWidget(Builder=b,
                      EventReceiver=app,
                      InstanceName="WidgetListedInXmlFile")

or:

   class BuilderWidgetWithIntegratedEventHandling(BuilderWidget):
       def onSomeRandomClickThing(self, sender):
           print "some random widget was clicked, it was this one:", sender

       b = Builder(xml)
       bw = BuilderWidgetWithIntegratedEventHandling(Builder=b,
                          InstanceName="WidgetListedInXmlFile")

or:

   b = Builder()
   bw = BuilderWidgetWithIntegratedEventHandling(Builder=b,
                      BuilderText=xml_file,
                      InstanceName="WidgetListedInXmlFile")
Classes [hide private]
  BuilderWidget