2. childname

Last page update: November 08, 2011

Note

validity - the childname attribute is supported by every element

2.1. description

With childname you can avoid to use the nodeId attribute; its features are:

  • it allows to identify uniquely the object to which you attach the childname
  • if you give a childname to an element and you attach to this element some other elements (with a proper childname), then these elements can be retrieved with a path that is a concatenation of all the childnames

2.2. examples

2.2.1. TableHandler example

In the TableHandler component (that has a childname called th) you have in the View class a frameGrid with the childname equal to view. So, you can reach the frameGrid through:

th.view

Check the TableHandler: paths section for a complete explanation of the TableHandler paths

2.2.2. layout widgets example

An example of childname applied to some layout widgets:

class GnrCustomWebPage(object):
    def main(self,root,**kwargs):
        tc = root.tabContainer(height='100px')
        for k in range(6):
            tc.borderContainer(title='pane %i' %k, childname='tab_%i' %k)
        for k in range(3):
            bc = tc.getAttach('tab_%i' %k)
            bc.contentPane(region='top',childname='top',height='30px',background='red')
            bc.contentPane(region='center',childname='center',background='gray')
        tc.tab_2.center.div('Here I am')
        tc.tab_3.div('Hello!')

2.2.3. slotBar example

 1   class GnrCustomWebPage(object):
 2       def main(self,root,**kwargs):
 3           top = root.div().slotToolbar(slotbarCode='top_0',slots='dummy,*,foo,boo,goo')
 4           fb = top.dummy.formbuilder(cols=3, fld_width='13em', lbl_color='teal')
 5           fb.textbox(lbl='Name')
 6           fb.textbox(lbl='Surname')
 7           fb.dateTextbox(lbl='Date')
 8           top.foo.slotButton('Save', iconClass='iconbox save', action="alert('Saved data')")
 9           top.boo.slotButton('Delete', iconClass='iconbox trash', action="alert('Deleted data')")
10           top.goo.slotButton('New document', iconClass='iconbox document', action="alert('Starting new document...')")
  • Line 1 and 2 include the creation of the GnrCustomWebPage class and the main method
  • In line 3 we create a slotToolbar. We use the mandatory slots attribute with some childnames we choose (“dummy”, “foo”, “boo” and “goo”). The * character is a special character
  • In line 4 we create a formbuilder (it allows to keep order in the following fields)
  • In line 5, 6 we set two TextBoxes, in line 7 we create a DateTextbox
  • In line 8, 9 and 10 we use the slots attribute, that allows to attach elements using the childname. We have attached three slotButtons

This is the result:

../../_images/childname_slotbar.png

Table Of Contents

Previous topic

1. action

Next topic

3. datapath

This Page