All pastes #176842 Raw Edit

Blocks and templates

public python v1 · immutable
#176842 ·published 2006-09-20 00:05 UTC
rendered paste body
# I have the following class:class BlockHider (ControlBlocks.StaticText):    blockToHide = schema.One(Block.Block, doc=        """        The block to hide/show when clicked        """)    def instantiateWidget (self):        import pdb;pdb.set_trace()        # add a "-"        originalTitle = self.title        self.title = u'-%s' % self.title        widget = super(BlockHider, self).instantiateWidget()        widget.Bind(wx.EVT_LEFT_DOWN, self.onLeftClick)        self.title = originalTitle        return widget    def onLeftClick(self, event):        import pdb;pdb.set_trace()        if self.blockToHide is not None:            self.blockToHide.isShown = not self.blockToHide.isShown            self.SetLabel(_(u'%s%s') % (self.blockToHide.isShown and "-" or "+", self.title))            self.blockToHide.synchronizeWidget()            event.Skip()# and I have a funtion:def makeHider(parcel, blockToHide, label=u'', borderTop=5, border=None,              width=-1, textAlignmentEnum=None, **kwds):    blocks = schema.ns("osaf.framework.blocks", parcel.itsView)    border = border or RectType(borderTop, 0, 0, 0)    textAlignmentEnum = textAlignmentEnum or 'Right'    return BlockHider.template(uniqueName(parcel, 'Label'),                               title=label,                               characterStyle=blocks.LabelStyle,                               textAlignmentEnum=textAlignmentEnum,                               stretchFactor=0.0,                               minimumSize=SizeType(width, -1),                               border=border,                               blockToHide=blockToHide, **kwds)# and I call it thusly:    showHideArea = \        makeArea(parcel, 'ShowHideArea',            childrenBlocks=[                makeLabel(parcel, _(u'')),                makeSpacer(parcel, width=8),                makeHider(parcel, ccArea, label='cc'),                makeSpacer(parcel, width=8),                makeHider(parcel, bccArea, label='bcc')],            position=0.113).install(parcel)