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


Python Label.addClickListener方法代码示例

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


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

示例1: addGroup

# 需要导入模块: from pyjamas.ui.Label import Label [as 别名]
# 或者: from pyjamas.ui.Label.Label import addClickListener [as 别名]
 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)
开发者ID:anthonyrisinger,项目名称:aur-pyjs,代码行数:12,代码来源:Search.py

示例2: addParam

# 需要导入模块: from pyjamas.ui.Label import Label [as 别名]
# 或者: from pyjamas.ui.Label.Label import addClickListener [as 别名]
 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)
开发者ID:anthonyrisinger,项目名称:aur-pyjs,代码行数:15,代码来源:Search.py

示例3: onModuleLoad

# 需要导入模块: from pyjamas.ui.Label import Label [as 别名]
# 或者: from pyjamas.ui.Label.Label import addClickListener [as 别名]
class Client:
    def onModuleLoad(self):
        # Window.setTitle("CBC Test Stand")
        StyleSheetCssFile("styleSheet.css")

        self.TEXT_WAITING = "Waiting for response..."
        self.TEXT_ERROR = "Server Error"

        self.status = Label()

        # This is the remote service
        self.I2CPanel = I2CPanel()
        self.SCurveRunPanel = SCurveRunPanel()
        self.OccupancyCheckPanel = OccupancyCheckPanel()
        self.CalibrateChannelTrimsPanel = CalibrateChannelTrimsPanel()

        # mainPanel will have all of the working stuff in it
        self.mainPanel = DockPanel()
        # self.mainPanel.setSpacing(10)
        titleBar = HorizontalPanel()
        titleBar.add(HTML(r"CBC Test Stand (v1.1)", StyleName="titleStyle"))
        self.stopTakingDataButton = Button("Stop taking data")
        self.stopTakingDataButton.addClickListener(self)
        self.dataTakingPercentage = HTML("0%")
        self.dataTakingStatus = HTML("Initiating...")
        titleBar.add(self.dataTakingPercentage)
        titleBar.add(self.dataTakingStatus)
        titleBar.add(self.stopTakingDataButton)
        titleBar.setCellHorizontalAlignment(self.dataTakingStatus, HasHorizontalAlignment.ALIGN_RIGHT)
        titleBar.setCellHorizontalAlignment(self.dataTakingPercentage, HasHorizontalAlignment.ALIGN_RIGHT)
        titleBar.setCellHorizontalAlignment(self.stopTakingDataButton, HasHorizontalAlignment.ALIGN_RIGHT)
        titleBar.setWidth("100%")
        self.mainPanel.add(titleBar, DockPanel.NORTH)
        selectionPanel = VerticalPanel()

        # Register to get updates about the status of data taking, so that
        # I can update the information in the title bar
        self.dataRunManager = DataRunManager.instance()
        self.dataRunManager.registerEventHandler(self)

        self.activePanelButton = None
        self.activePanel = None

        self.registersButton = Label("I2C Registers", StyleName="areaStyle")
        self.occupanciesButton = Label("Test Occupancies", StyleName="areaStyle")
        self.scurveButton = Label("S-Curve Run", StyleName="areaStyle")
        self.calibrateTrimsButton = Label("Calibrate Trims", StyleName="areaStyle")

        self.registersButton.addClickListener(self)
        self.occupanciesButton.addClickListener(self)
        self.scurveButton.addClickListener(self)
        self.calibrateTrimsButton.addClickListener(self)

        selectionPanel.add(self.registersButton)
        selectionPanel.add(self.occupanciesButton)
        selectionPanel.add(self.scurveButton)
        selectionPanel.add(self.calibrateTrimsButton)

        self.mainPanel.add(selectionPanel, DockPanel.WEST)

        self.mainPanel.add(self.status, DockPanel.SOUTH)
        RootPanel().add(self.mainPanel)

        self.setNewMainPanel(self.registersButton)

    def onDataTakingEvent(self, eventCode, details):
        """
		Method that receives updates from DataRunManager
		"""
        if eventCode == DataRunManager.DataTakingStartedEvent:
            self.stopTakingDataButton.setEnabled(True)
            self.dataTakingPercentage.setText("0%")
            self.dataTakingStatus.setText("Starting run...")
        elif eventCode == DataRunManager.DataTakingFinishedEvent:
            self.stopTakingDataButton.setEnabled(False)
            self.dataTakingPercentage.setText("")
            self.dataTakingStatus.setText("Not taking data")
        elif eventCode == DataRunManager.DataTakingStatusEvent:
            self.stopTakingDataButton.setEnabled(True)
            self.dataTakingPercentage.setText("%3d%%" % int(details["fractionComplete"] * 100 + 0.5))
            self.dataTakingStatus.setText(details["statusString"])

    def onClick(self, sender):
        # (data, response_class): if the latter is 'self', then
        # the response is handled by the self.onRemoteResponse() method
        try:
            if sender == self.stopTakingDataButton:
                self.dataRunManager.stopTakingData()
            else:
                # I don't have any other buttons so it must be a panel change
                self.setNewMainPanel(sender)

        except Exception as error:
            self.status.setText("Client exception was thrown: '" + str(error.__class__) + "'='" + str(error) + "'")

    def setNewMainPanel(self, panelButton):
        if panelButton == self.activePanelButton:
            return  # already the active panel so no need to do anything

        # Remove the "selected" style from the current button
#.........这里部分代码省略.........
开发者ID:BristolHEP-CBC-Testing,项目名称:cbcanalysis,代码行数:103,代码来源:index.py

示例4: Game

# 需要导入模块: from pyjamas.ui.Label import Label [as 别名]
# 或者: from pyjamas.ui.Label.Label import addClickListener [as 别名]
class Game(VerticalPanel):
    def __init__(self, row, column=0):
        super(Game, self).__init__(StyleName='game')
        self.sinkEvents(Event.ONCONTEXTMENU)  # to disable right click
        
        self.row = row
        self.column = column or row
        self.level = 1
        self.toppers = [[], [], []]  # storage for top scorers for 3 levels.
        self.remote = DataService()
        self.remote_handler = RemoteHandler(self)
        self.remote.get_scores(self.remote_handler)
        
        # contents of Game
        menubar = MineMenuBar(self)
        score_board = HorizontalPanel(StyleName='score-board')
        self.grid_panel = SimplePanel(StyleName='grid-panel')
        
        self.add(menubar)
        self.add(score_board)
        self.add(self.grid_panel)
        
        # contents of score_board
        self.counter = Label('000', StyleName='digit counter')
        self.face = Smiley(self)
        self.timer = Label('000', StyleName='digit timer')
        
        for one in (self.counter, self.face, self.timer):
            score_board.add(one)
        score_board.setCellWidth(self.face, '100%')
        
        self.create_grid()
        self.start()
    
    def onBrowserEvent(self, event):
        # prevent right click context menu as well as all the other events.
        DOM.eventPreventDefault(event)
    
    def create_grid(self):
        # contents of self.grid_panel
        self.grid = CustomGrid(self, self.row, self.column)
        self.grid_panel.add(self.grid)
    
    def start(self, no_of_bomb=0):
        self.time = -1
        self.started = True
        self.first_click = True
        
        self.bombed_cells = []
        self.flagged_cells = []
        self.to_be_released = []  # cells to be released after being pressed
        self.count_opened_cells = 0
        self.no_of_click = 0
        
        self.squares = self.row * self.column
        self.no_of_bomb = no_of_bomb or int((self.squares * 10) / 64)
        self.no_of_safe_zones = self.squares - self.no_of_bomb
        
        self.set_counter()
        self.timer.setText('000')
        
        self.generate_bombs()
        self.face.setStyleName('facesmile')
    
    def get_all_cells(self):
        for i in xrange(self.row):
            for j in xrange(self.column):
                one = self.grid.getCell(i, j)
                yield one
    
    def get_neighbors(self, cell):
        x = cell.x
        y = cell.y
        row, column = self.row, self.column
        for i in xrange(x-1, x+2):
            if 0 <= i < row:
                for j in xrange(y-1, y+2):
                    if 0 <= j < column:
                        if (i,j) != (x, y):
                            one = self.grid.getCell(i, j)
                            yield one
    
    def set_counter(self):
        next_value = self.no_of_bomb - len(self.flagged_cells)
        
        if next_value == 0 and self.started:
            self.counter.setStyleName('digit counter-blue')
            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)
#.........这里部分代码省略.........
开发者ID:anandology,项目名称:pyjamas,代码行数:103,代码来源:minesweeper.py

示例5: TemplatePanel

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

#.........这里部分代码省略.........
            #console.log("Passing node with name %s", node.nodeName)
            if node.nodeName == "META":
                name = node.getAttribute("name")
                content = node.getAttribute("content")
                console.log("Found meta %o name %s content %s",
                            node, name, content)
                self.metaTags[name] = content
                self.metaTagList.append(node)
            elif node.nodeName == "BODY":
                self.body = node
            elif node.nodeName == "TITLE":
                self.title = DOM.getInnerText(node)
            elif node.nodeName == "FORM":
                self.forms.append(node)

            nodeId = DOM.getAttribute(node, "id")
            if nodeId:
                self.elementsById[nodeId] = node
                DOM.setAttribute(node, "id", self.id + ":" + node.id)
            nodeHref = DOM.getAttribute(node, "href")
            if nodeHref:
                self.links.append(node)

        self.loaded = True
        if self.attached:
            self.attachWidgets()
            self.widgetsAttached = True

        if self.allowEdit:
            self.editor = None
            self.editButton = Label("edit "+unescape(self.templateName))
            self.editButton.addStyleName("link")
            self.editButton.addStyleName("ContentPanelEditLink")
            self.editButton.addClickListener(EventDelegate("onClick", self,
                                             self.onEditContentClick))
            ComplexPanel.insert(self, self.editButton, self.getElement(),
                                len(self.children))

        self.notifyLoadListeners()

    def onError(self, html, statusCode):
        if statusCode == 404 and self.allowEdit:
            self.editor = None
            self.originalText = ""
            DOM.setInnerHTML(self.getElement(), '')
            self.editButton = Label("create "+unescape(self.templateName))
            self.editButton.addStyleName("link")
            self.editButton.addStyleName("ContentPanelEditLink")
            self.editButton.addClickListener(EventDelegate("onClick", self,
                                             self.onEditContentClick))
            ComplexPanel.insert(self, self.editButton, self.getElement(),
                                len(self.children))
            return

        # Show the page we got in an iframe, which will hopefully show
        # the error better than we can.
        # DOM.setInnerHTML(self.getElement(), '<iframe src="'+self.getTemplatePath(self.templateName)+'"/>')

    def onTimeout(self, text):
        self.onError("Page loading timed out: "+text)

    def getElementsById(self):
        """Return a dict mapping an id to an element with that id
        inside the template; useful for post-processing."""
        return self.elementsById
开发者ID:Afey,项目名称:pyjs,代码行数:69,代码来源:TemplatePanel.py

示例6: labelbutton

# 需要导入模块: from pyjamas.ui.Label import Label [as 别名]
# 或者: from pyjamas.ui.Label.Label import addClickListener [as 别名]
def labelbutton(x,y):
    z = Label(x)
    z.addClickListener(y)
    return z
开发者ID:haskellpostgresprogrammer,项目名称:python_files,代码行数:6,代码来源:mywidgets.py

示例7: onClick

# 需要导入模块: from pyjamas.ui.Label import Label [as 别名]
# 或者: from pyjamas.ui.Label.Label import addClickListener [as 别名]
from pyjamas.ui.Label import Label
from pyjamas.ui.Image import Image
from pyjamas.ui.HorizontalPanel import HorizontalPanel


def onClick(sender):
    Window.alert('Make service request using %s'%sender.getID())
    
if __name__ == '__main__':
    pyjd.setup("public/Anchor.html")
    # EXAMPLE 1
    a1 = Anchor(Widget = HTML('Test 1: Anchor to external site using HTML widget.'), Href='http://pyjs.org', Title = 'Test1')
    RootPanel().add(a1) 
    # EXAMPLE 2
    label = Label(text = 'Test 2: Click listener added to a label.')
    label.addClickListener(onClick)
    RootPanel().add(label) 
    # EXAMPLE 3
    a2 = Hyperlink(text = 'Hyperlink', Element = DOM.createSpan())
    a2.setID('param1')
    a2.addClickListener(onClick)
    html2=HTMLPanel("Test 3: <span id ='t3'></span> added to HTMLPanel with click listener.")
    html2.add(a2, "t3")
    RootPanel().add(html2)
    # EXAMPLE 4
    hpanel = HorizontalPanel()
    hpanel.append(HTML('Test 4:  Anchor to external site using Image widget'))
    a3 = Anchor(Widget = Image('http://pyjs.org/assets/images/pyjs.128x128.png'), Href='http://pyjs.org', Title = 'Test4')
    hpanel.append(a3)
    RootPanel().add(hpanel) 
    # EXAMPLE 5
开发者ID:Afey,项目名称:pyjs,代码行数:33,代码来源:Anchor.py


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