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


Python SimplePanel.remove方法代码示例

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


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

示例1: Game

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

#.........这里部分代码省略.........
            self.counter.addClickListener(RemainingMineHandler(self))
        else:
            self.counter.setStyleName('digit counter')
            self.counter._clickListeners = []
        
        if next_value < 0:
            template = '-00'
            next_value = abs(next_value)
        else:
            template = '000'
        value = str(next_value)
        value = template[:-len(value)] + value
        self.counter.setText(value)
    
    def onTimer(self, target):
        if not self.started or self.first_click:
            return
        Timer(1000, self)
        self.time += 1
        if self.time <= 999:
            str_time = str(self.time)
            str_time = '000'[:-len(str_time)] + str_time
            self.timer.setText(str_time)
        else:
            self.started = False
            self.face.setStyleName('faceclock')
    
    def sample(self, population, k):
        # pyjamas doesn't support random.sample but random.choice
        seq = list(population)
        s = []
        for i in xrange(k):
            pick = random.choice(seq)
            seq.remove(pick)
            s.append(pick)
        return s
    
    def generate_bombs(self):
        # generate 1 extra mine so that if user's first click is bomb, move that
        bombs = self.sample(xrange(self.squares), self.no_of_bomb+1)
        row, column = self.row, self.column
        for i,bomb in enumerate(bombs):
            x = bomb // column
            y = bomb % column
            mine = self.grid.getCell(x, y)
            if i == 0:
                self.extra_mine = mine
                continue
            #DOM.setInnerHTML(mine.getElement(),'b');mine.addStyleName('debug')
            self.bombed_cells.append(mine)
            mine.count = -1
            for one in self.get_neighbors(mine):
                if one.count != -1:
                    one.count += 1
    
    def move_to_extra_mine(self, to_be_moved):
        to_be_moved.count = 0
        self.bombed_cells.remove(to_be_moved)
        for one in self.get_neighbors(to_be_moved):
            if one.count == -1:
                to_be_moved.count += 1
            else:
                one.count -= 1
        
        self.extra_mine.count = -1
        self.bombed_cells.append(self.extra_mine)
开发者ID:anandology,项目名称:pyjamas,代码行数:70,代码来源:minesweeper.py

示例2: onModuleLoad

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

#.........这里部分代码省略.........
                item = TreeItem(demo['title'])
            DOM.setStyleAttribute(item.getElement(), "cursor", "pointer")
            DOM.setAttribute(item.itemTable, "cellPadding", "0")
            DOM.setAttribute(item.itemTable, "cellSpacing", "1")
            item.setUserObject(demo)
            section.addItem(item)

        # Open the branches of the tree.

        for section in sections.keys():
            sections[section].setState(True, fireEvents=False)


    def onTreeItemSelected(self, item):
        """ Respond to the user selecting an item in our tree.
        """
        demo = item.getUserObject()
        if demo is None:
            self.showDemo(None)
        else:
            self.showDemo(demo['name'])


    def onTreeItemStateChanged(self, item):
        """ Respond to the user opening or closing a branch of the tree.
        """
        pass # Nothing to do.


    def showDemo(self, name):
        """ Show the demonstration with the given name.
        """
        if self._curContents is not None:
            self._rightPanel.remove(self._curContents)
            self._curContents = None

        demo = None
        for d in self._demos:
            if d['name'] == name:
                demo = d
                break

        if demo is not None:
            exampleID = HTMLPanel.createUniqueId()

            html = []
            html.append('<div style="padding:20px">')
            html.append('<b>' + demo['title'] + '</b>')
            html.append('<p/>')
            html.append(self.docToHTML(demo['doc']))
            html.append('<p/>')
            html.append('<hr/>')
            html.append('<b>Working Example</b>')
            html.append('<p/>')
            html.append('<div style="padding-left:20px">')
            html.append('<span id="' + exampleID + '"></span>')
            html.append('</div>')
            html.append('<p/>')
            html.append('<hr/>')
            html.append('<b>Source Code</b>')
            html.append('<p/>')
            html.append(self.srcToHTML(demo['src']))
            html.append('</div>')

            panel = HTMLPanel("\n".join(html))
            panel.add(demo['example'], exampleID)
开发者ID:Afey,项目名称:pyjs,代码行数:70,代码来源:Showcase.py

示例3: DialogBox

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

#.........这里部分代码省略.........
            self.centerBox()

    def show(self):
        super(DialogBox, self).show()
        if self.centered:
            self.centerBox()

    @classmethod
    def _getProps(self):
        return PopupPanel._getProps() + self._props

    def onEventPreview(self, event):
        # preventDefault on mousedown events, outside of the
        # dialog, to stop text-selection on dragging
        type = DOM.eventGetType(event)
        if type == 'mousedown':
            target = DOM.eventGetTarget(event)
            elem = self.caption.getElement()
            event_targets_popup = target and DOM.isOrHasChild(elem, target)
            if event_targets_popup:
                DOM.eventPreventDefault(event)
        return PopupPanel.onEventPreview(self, event)

    def getHTML(self):
        return self.caption.getHTML()

    def getText(self):
        return self.caption.getText()

    def setHTML(self, html):
        self.caption.setHTML(html)

    def setText(self, text):
        self.caption.setText(text)

    def onMouseDown(self, sender, x, y):
        self.dragging = True
        GlassWidget.show(self.caption)
        self.dragStartX = x
        self.dragStartY = y

    def onMouseEnter(self, sender):
        pass

    def onMouseLeave(self, sender):
        pass

    def onMouseMove(self, sender, x, y):
        if not self.dragging:
            return
        absX = x + self.getAbsoluteLeft()
        absY = y + self.getAbsoluteTop()
        self.setPopupPosition(absX - self.dragStartX,
                              absY - self.dragStartY)

    def onMouseUp(self, sender, x, y):
        self.endDragging()

    def onMouseGlassEnter(self, sender):
        pass

    def onMouseGlassLeave(self, sender):
        self.endDragging()

    def endDragging(self):
        if not self.dragging:
            return
        self.dragging = False
        GlassWidget.hide()

    def remove(self, widget):
        if self.child != widget:
            return False

        self.panel.remove(widget)
        self.child = None
        return True

    def doAttachChildren(self):
        PopupPanel.doAttachChildren(self)
        self.caption.onAttach()

    def doDetachChildren(self):
        PopupPanel.doDetachChildren(self)
        self.caption.onDetach()

    def setWidget(self, widget):
        if self.child is not None:
            if not self.generate_gwt15:
                self.panel.remove(self.child)
            else:
                self.dialog_content.remove(self.child)

        if widget is not None:
            if not self.generate_gwt15:
                self.panel.setWidget(1, 0, widget)
            else:
                self.dialog_content.setWidget(widget)

        self.child = widget
开发者ID:Afey,项目名称:pyjs,代码行数:104,代码来源:DialogBox.py


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