1.2.3. slotButton

Last page update: November 23, 2011

Note

slotButton features:

1.2.3.1. definition

GnrDomSrc_dojo_11.slotButton(label=None, **kwargs)

Return a slotButton. A slotbutton is a button with some preset attributes to create rapidly a button with an icon (set through the iconClass attribute) and with a label that works only as a tooltip: for example you can use a slotButton when you handle a toolbar or a palette

Parameters:
  • label – the button’s tooltip (or its label, if no iconClass is set)
  • kwargs
    • action: allow to execute a javascript callback. For more information, check the action section
    • iconClass: the button icon. For more information, check the iconClass section
    • showLabel: boolean. If True, show the button label
    • value: specify the path of the widget’s value. For more information, check the datapath page

1.2.3.2. examples

1.2.3.2.1. simple example

  • slotButton [basic]

  • Description: This is the standard usage of the slotButton: the label works only as the slotbutton’s tooltip (so the button will not have a real label). Use the action attribute to perform an action through Javascript

    Note

    example elements’ list:

  • Code:

    # -*- coding: UTF-8 -*-
    """slotButtons"""
    
    class GnrCustomWebPage(object):
        py_requires = "gnrcomponents/testhandler:TestHandlerBase"
    
        def test_1_basic(self, pane):
            """slotButton, standard button"""
            fb = pane.formbuilder(cols=3)
            fb.slotButton('I\'m the label, but I work as a tooltip', iconClass="icnBuilding", action='alert("Hello!")',colspan=2)
            fb.div('This is the standard usage of a slotButton: the label works as a tooltip')
    

1.2.3.2.2. buttons and slotButton example

  • slotButton [differences]

  • Description: we show here how to obtain the same button using the button and the slotButton

    Note

    example elements’ list:

  • Code:

    # -*- coding: UTF-8 -*-
    """slotButtons"""
    
    class GnrCustomWebPage(object):
        py_requires = "gnrcomponents/testhandler:TestHandlerBase"
    
        def test_2_buttons(self, pane):
            """simple button and slotButton"""
            action = 'alert("you clicked me")'
            iconclass = 'iconbox info'
    
            fb = pane.formbuilder(cols=4)
            fb.div('In this example every button (and slotButton) has the \"label\" attribute set to \"click\";', colspan=4)
            fb.div("""also, every button (and every slotButton) has the following \"action\" attribute:
                      action = alert("you clicked me")""", colspan=4)
    
            fb.div('N.', font_size='1.2em', font_weight='bold')
            fb.div('widget', font_size='1.2em', font_weight='bold')
            fb.div('attributes', font_size='1.2em', font_weight='bold')
            fb.div('comment', font_size='1.2em', font_weight='bold')
    
            fb.div('1)')
            fb.button('click', action=action)
            fb.div('[No attributes]')
            fb.div('Standard way to build an iconless button')
    
            fb.div('2)')
            fb.button('click', iconClass=iconclass, action=action)
            fb.div('[iconClass: iconbox info]')
            fb.div('Standard way to build an icon button')
    
            fb.div('3)')
            fb.slotButton('click', iconClass=iconclass, action=action)
            fb.div('[iconClass: iconbox info]')
            fb.div('Standard way to build a slotButton')
    
            fb.div('4)')
            fb.slotButton('click', showLabel=True, iconClass=iconclass, action=action)
            fb.div('[showLabel=True; iconClass: iconbox info]')
            fb.div('Unusual way to build a slotButton: you can use the button of the example n.2')
    
            fb.div('5)')
            fb.slotButton('click', action=action)
            fb.div('[No attributes]')
            fb.div('This is a WRONG way to build a slotButton: if you need something like this, use the button of the example n.1')
    
            fb.div('6)')
            fb.button('click', iconClass=iconclass, showLabel=False, action=action)
            fb.div('[iconClass: iconbox info; showLabel: False]')
            fb.div('This is the way to set a button with the features of a basic slotButton (like the example n.3)')
    

Table Of Contents

Previous topic

1.2.2. DropDownButton

Next topic

1.2.4. ToggleButton

This Page