当前位置: 首页>>代码示例>>Python>>正文


Python SimplePanel.removeStyleName方法代码示例

本文整理汇总了Python中pyjamas.ui.SimplePanel.SimplePanel.removeStyleName方法的典型用法代码示例。如果您正苦于以下问题:Python SimplePanel.removeStyleName方法的具体用法?Python SimplePanel.removeStyleName怎么用?Python SimplePanel.removeStyleName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pyjamas.ui.SimplePanel.SimplePanel的用法示例。


在下文中一共展示了SimplePanel.removeStyleName方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: Param

# 需要导入模块: from pyjamas.ui.SimplePanel import SimplePanel [as 别名]
# 或者: from pyjamas.ui.SimplePanel.SimplePanel import removeStyleName [as 别名]
class Param(object):
    def __init__(self, container, kind, group, draw=True):
        self.container = container
        self.kind = kind
        self.group = group
        self.panel = SimplePanel(StyleName='aur-search-advanced-param')
        self.isInverted = False
        # assigned by parent, visual use only
        self.op = None
        if draw: self.draw()

    def draw(self):
        paramPanel = HorizontalPanel(Width='100%', VerticalAlignment='middle')
        options = self.drawOptions()
        label = Label(self.kind['item'], StyleName='aur-search-advanced-param-title')
        delSelf = Image(url='/ico/cross.png', Title='Delete this parameter')
        delSelf.addStyleName('aur-search-advanced-delete')
        if self.kind['allowsInverse']:
            invertSelf = Image(url='/ico/exclamation.png', Title='Invert this parameter')
            invertSelf.addClickListener(getattr(self, 'invertSelf'))
        else:
            invertSelf = Image(url='/ico/bullet_white.png', StyleName='aur-search-advanced-placeholder')
        self.container.add(self.panel)
        self.panel.setWidget(paramPanel)
        paramPanel.add(delSelf)
        paramPanel.add(label)
        paramPanel.add(options)
        paramPanel.add(invertSelf)
        paramPanel.setCellWidth(delSelf, '1px')
        paramPanel.setCellWidth(options, '1px')
        paramPanel.setCellWidth(invertSelf, '1px')
        delSelf.addClickListener(getattr(self, 'delSelf'))

    def drawOptions(self):
        widget = self.kind['widget']()
        if isinstance(widget, ListBox):
            for x in self.kind['params']:
                widget.addItem(x[0], x[1])
        elif isinstance(widget, TextBox):
            pass
        elif isinstance(widget, CheckBox):
            if self.kind['params'][0]:
                widget.setChecked(True)
        elif isinstance(widget, DateField):
            pass
        return widget

    def delSelf(self, sender):
        self.group.delParam(self)

    def invertSelf(self, sender):
        if self.isInverted:
            self.isInverted = False
            self.panel.removeStyleName('aur-search-advanced-param-inverted')
            self.op.setText(self.group.operator)
        else:
            self.isInverted = True
            self.panel.addStyleName('aur-search-advanced-param-inverted')
            self.op.setText(self.group.operator + ' not')
开发者ID:anthonyrisinger,项目名称:aur-pyjs,代码行数:61,代码来源:Search.py

示例2: ParamGroup

# 需要导入模块: from pyjamas.ui.SimplePanel import SimplePanel [as 别名]
# 或者: from pyjamas.ui.SimplePanel.SimplePanel import removeStyleName [as 别名]

#.........这里部分代码省略.........
        header.setCellWidth(addGroup, '1px')
        header.setCellWidth(addGroupFull, '1px')
        header.setCellWidth(invertSelf, '1px')
        for x in self.kind:
            params.addItem(x['item'], x['index'])
        cont.add(self.listPanel)
        self.listPanel.add(self.paramPanel)
        self.listPanel.add(self.childPanel)
        addParam.addClickListener(getattr(self, 'addParam'))
        addGroup.addClickListener(getattr(self, 'addGroup'))
        addGroupFull.addClickListener(getattr(self, 'addGroupFull'))
        invertSelf.addClickListener(getattr(self, 'invertSelf'))

    def addGroup(self, sender):
        self.listPanel.setVisible(True)
        op = Label(self.operator, Title='Invert group operator', StyleName='aur-search-advanced-group-op', Visible=False)
        op.addClickListener(getattr(self, 'invertOperator'))
        if len(self.children) > 0 or len(self.parameters) > 0: op.setVisible(True)
        self.childPanel.add(op)
        self.childPanel.setCellHorizontalAlignment(op, 'right')
        g = ParamGroup(self.childPanel, self.kind, self, self.level+1)
        g.op = op
        self.children.append(g)

    def addGroupFull(self, sender):
        # this is a little hacky, but it's so fast you don't see it
        self.addGroup(None)
        group = self.children[len(self.children)-1]
        for x in range(group.paramChooser.getItemCount()):
            group.paramChooser.setSelectedIndex(x)
            group.addParam(None)
        group.paramChooser.setSelectedIndex(0)

    def addParam(self, sender):
        self.listPanel.setVisible(True)
        op = Label(self.operator, Title='Invert group operator', StyleName='aur-search-advanced-param-op', Visible=False)
        op.addClickListener(getattr(self, 'invertOperator'))
        if len(self.parameters) > 0: op.setVisible(True)
        self.paramPanel.add(op)
        self.paramPanel.setCellHorizontalAlignment(op, 'right')
        k = self.kind[self.paramChooser.getSelectedValues()[0]]
        p = Param(self.paramPanel, k, self)
        p.op = op
        self.parameters.append(p)
        if len(self.children) > 0:
            self.children[0].op.setVisible(True)

    def addParamFull(self, sender):
        # this is a little hacky, but it's so fast you don't see it
        old = self.paramChooser.getSelectedIndex()
        for x in range(self.paramChooser.getItemCount()):
            self.paramChooser.setSelectedIndex(x)
            self.addParam(None)
        self.paramChooser.setSelectedIndex(old)

    def delGroup(self, child):
        self.children.remove(child)
        self.childPanel.remove(child.op)
        self.childPanel.remove(child.panel)
        lp = len(self.parameters)
        lc = len(self.children)
        if lp == 0 and lc > 0:
            self.children[0].op.setVisible(False)
        if lp == 0 and lc == 0:
            self.listPanel.setVisible(False)

    def delParam(self, param):
        self.parameters.remove(param)
        self.paramPanel.remove(param.op)
        self.paramPanel.remove(param.panel)
        lp = len(self.parameters)
        lc = len(self.children)
        if lp > 0:
            self.parameters[0].op.setVisible(False)
        if lp == 0 and lc > 0:
            self.children[0].op.setVisible(False)
        if lp == 0 and lc == 0:
            self.listPanel.setVisible(False)

    def delSelf(self, sender):
        self.parent.delGroup(self)

    def invertSelf(self, sender):
        if self.isInverted:
            self.isInverted = False
            self.panel.removeStyleName('aur-search-advanced-group-inverted')
            self.op.setText(self.operator)
        else:
            self.isInverted = True
            self.panel.addStyleName('aur-search-advanced-group-inverted')
            self.op.setText(self.operator + ' not')

    def invertOperator(self, sender):
        self.operator = 'or' if self.operator == 'and' else 'and'
        for x in self.parameters:
            suffix = ' not' if x.isInverted else ''
            x.op.setText(self.operator + suffix)
        for x in self.children:
            suffix = ' not' if x.isInverted else ''
            x.op.setText(self.operator + suffix)
开发者ID:anthonyrisinger,项目名称:aur-pyjs,代码行数:104,代码来源:Search.py


注:本文中的pyjamas.ui.SimplePanel.SimplePanel.removeStyleName方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。