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


Python Hyperlink.addClickListener方法代码示例

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


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

示例1: _gridCancelLink

# 需要导入模块: from pyjamas.ui.Hyperlink import Hyperlink [as 别名]
# 或者: from pyjamas.ui.Hyperlink.Hyperlink import addClickListener [as 别名]
    def _gridCancelLink(self):
        bh4 = Hyperlink(self.cancel)
        bh4.addClickListener(getattr(self, 'onCancel'))

        b2 = SimplePanel()
        b2.add(bh4)
        b2.addStyleName("calendar-cancel")
        self.vp.add(b2)
开发者ID:jwashin,项目名称:pyjs,代码行数:10,代码来源:Calendar.py

示例2: drawFull

# 需要导入模块: from pyjamas.ui.Hyperlink import Hyperlink [as 别名]
# 或者: from pyjamas.ui.Hyperlink.Hyperlink import addClickListener [as 别名]
    def drawFull(self, month, year):
        # should be called only once when we draw the calendar for
        # the first time
        self.vp = VerticalPanel()
        self.vp.setSpacing(2)
        self.vp.addStyleName("calendarbox calendar-module calendar")
        self.setWidget(self.vp)
        self.setVisible(False)
        #
        mth = int(month)
        yr = int(year)

        tp = HorizontalPanel()
        tp.addStyleName("calendar-top-panel")
        tp.setSpacing(5)

        h1 = Hyperlink('<<')
        h1.addClickListener(getattr(self, 'onPreviousYear'))
        h2 = Hyperlink('<')
        h2.addClickListener(getattr(self, 'onPreviousMonth'))
        h4 = Hyperlink('>')
        h4.addClickListener(getattr(self, 'onNextMonth'))
        h5 = Hyperlink('>>')
        h5.addClickListener(getattr(self, 'onNextYear'))

        tp.add(h1)
        tp.add(h2)

        # titlePanel can be changed, whenever we draw, so keep the reference
        txt = "<b>"
        txt += self.getMonthsOfYear()[mth-1] + " " + str(yr)
        txt += "</b>"
        self.titlePanel = SimplePanel()
        self.titlePanel.setWidget(HTML(txt))
        self.titlePanel.setStyleName("calendar-center")

        tp.add(self.titlePanel)
        tp.add(h4)
        tp.add(h5)
        tvp = VerticalPanel()
        tvp.setSpacing(10)
        tvp.add(tp)

        self.vp.add(tvp)

        # done with top panel

        self.middlePanel = SimplePanel()
        grid = self.drawGrid(mth, yr)
        self.middlePanel.setWidget(grid)
        self.vp.add(self.middlePanel)
        self.defaultGrid = grid

        self._gridShortcutsLinks()
        self._gridCancelLink()
        #
        # add code to test another way of doing the layout
        #
        self.setVisible(True)
        return
开发者ID:jwashin,项目名称:pyjs,代码行数:62,代码来源:Calendar.py

示例3: _gridShortcutsLinks

# 需要导入模块: from pyjamas.ui.Hyperlink import Hyperlink [as 别名]
# 或者: from pyjamas.ui.Hyperlink.Hyperlink import addClickListener [as 别名]
    def _gridShortcutsLinks(self):
        bh1 = Hyperlink(_("Current"))
        bh1.addClickListener(getattr(self, 'onToday'))

        b2 = Button(_("Choose"),self.onMonthSelected)

        bh3 = Hyperlink(self.cancel)
        bh3.addClickListener(getattr(self, 'onCancel'))
        
        
        b = HorizontalPanel()
        b.addStyleName("calendar-shortcuts")
        b.add(bh1)
        b.add(b2)
        b.add(bh3)
        
        self.vp.add(b)
开发者ID:anthonyrisinger,项目名称:translate-pyjs-org.appspot.com,代码行数:19,代码来源:MonthField.py

示例4: drawControl

# 需要导入模块: from pyjamas.ui.Hyperlink import Hyperlink [as 别名]
# 或者: from pyjamas.ui.Hyperlink.Hyperlink import addClickListener [as 别名]
def drawControl(container):
    bar = HorizontalPanel(ID='aur-search-bar', VerticalAlignment='middle')
    adv = HorizontalPanel(ID='aur-search-advanced', Visible=False)
    adv_toggle = Hyperlink(Text='Advanced', StyleName='aur-link-stateless aur-search-bar-advanced', TargetHistoryToken=History.getToken())
    query = TextBox(Text='enter search term...', StyleName='aur-search-bar-query')
    go = Button(HTML='Go', StyleName='aur-search-bar-submit')

    container.add(bar)
    container.add(adv)

    # slight workaround to make sure the 'Advanced' toggle doesn't change the page
    def updateAdvToken(token):
        adv_toggle.setTargetHistoryToken(token)
    obj = object()
    setattr(obj, 'onHistoryChanged', updateAdvToken)
    History.addHistoryListener(obj)

    # clickListener to toggle the advanced section
    def toggleAdv(sender):
        if adv.isVisible():
            adv.setVisible(False)
            query.setEnabled(True)
            adv_toggle.setText('Advanced')
        else:
            adv.setVisible(True)
            query.setEnabled(False)
            adv_toggle.setText('Basic')
    adv_toggle.addClickListener(toggleAdv)

    def doGo():
        History.newItem('/package/search')
    go.addClickListener(doGo)

    bar.add(Label('Search Criteria', StyleName='aur-search-bar-label'))
    bar.add(query)
    bar.add(go)
    bar.add(Button(HTML='Orphans', StyleName='aur-search-bar-submit'))
    bar.add(adv_toggle)

    drawAdvanced(adv)
开发者ID:anthonyrisinger,项目名称:aur-pyjs,代码行数:42,代码来源:Search.py

示例5: onRemoteResponse

# 需要导入模块: from pyjamas.ui.Hyperlink import Hyperlink [as 别名]
# 或者: from pyjamas.ui.Hyperlink.Hyperlink import addClickListener [as 别名]
    def onRemoteResponse(self, response, request_info):
#0  (x.id,               
#1 x.problem.name, 
#2 x.problem_id, 
#3 x.submitter.handle, 
#4 x.submitter_id,  
#5 status(x.code),
#6 x.judgeTime,
#7 x.submitTime )
        if response:
            for line in response:
                if line[0] in self.id2row:
                    idx =self.cnt- self.id2row[line[0]]
                    #alert(self.id2row[line[0]] + " " + idx + " " + self.cnt);
                    #return
                else:
                    idx = 1
                    self.table.insertRow(1)
                    self.id2row[line[0]] = self.cnt
                    self.cnt += 1          
                #Hyperlink
                self.table.setText(idx, 0, line[7])
                pl=Hyperlink(line[1])
                pl.addClickListener(self.problemLambda(line[2]));
                self.table.setWidget(idx, 1, pl)
                ul=Hyperlink(line[3])
                ul.addClickListener(self.userLambda(line[4]) );
                self.table.setWidget(idx, 2, ul)
                sl=Hyperlink(line[5])
                sl.addClickListener(self.submissionLambda(line[0]))
                self.table.setWidget(idx, 3, sl)
                if line[6] != 'None': self.time = max(self.time, line[6], line[7])
                else: self.time = max(self.time, line[7])
开发者ID:antialize,项目名称:djudge,代码行数:35,代码来源:main.py

示例6: _gridShortcutsLinks

# 需要导入模块: from pyjamas.ui.Hyperlink import Hyperlink [as 别名]
# 或者: from pyjamas.ui.Hyperlink.Hyperlink import addClickListener [as 别名]
    def _gridShortcutsLinks(self):

        #
        # some links & handlers
        #
        bh1 = Hyperlink(self.yesterday)
        bh1.addClickListener(getattr(self, 'onYesterday'))
        bh2 = Hyperlink(self.today)
        bh2.addClickListener(getattr(self, 'onToday'))
        bh3 = Hyperlink(self.tomorrow)
        bh3.addClickListener(getattr(self, 'onTomorrow'))

        b = HorizontalPanel()
        b.add(bh1)
        b.add(bh2)
        b.add(bh3)
        b.addStyleName("calendar-shortcuts")
        self.vp.add(b)
开发者ID:jwashin,项目名称:pyjs,代码行数:20,代码来源:Calendar.py

示例7: DateField

# 需要导入模块: from pyjamas.ui.Hyperlink import Hyperlink [as 别名]
# 或者: from pyjamas.ui.Hyperlink.Hyperlink import addClickListener [as 别名]
class DateField(Composite):

    icon_img = "icon_calendar.gif"
    icon_style = "calendar-img"
    today_text = "Today"
    today_style = "calendar-today-link"

    def __init__(self, format='%d-%m-%Y'):
        self.format = format
        self.tbox = TextBox()
        self.tbox.setVisibleLength(10)
        # assume valid sep is - / . or nothing
        if format.find('-') >= 0:
            self.sep = '-'
        elif format.find('/') >= 0:
            self.sep = '/'
        elif format.find('.') >= 0:
            self.sep = '.'
        else:
            self.sep = ''
        # self.sep = format[2] # is this too presumptious?
        self.calendar = Calendar()
        self.img = Image(self.icon_img)
        self.img.addStyleName(self.icon_style)
        self.calendarLink = HyperlinkImage(self.img)
        self.todayLink = Hyperlink(self.today_text)
        self.todayLink.addStyleName(self.today_style)
        #
        # lay it out
        #
        hp = HorizontalPanel()
        hp.setSpacing(2)
        vp = VerticalPanel()
        hp.add(self.tbox)
        vp.add(self.calendarLink)
        vp.add(self.todayLink)
        #vp.add(self.calendar)
        hp.add(vp)

        Composite.__init__(self)
        self.initWidget(hp)
        #
        # done with layout, so now set up some listeners
        #
        self.tbox.addFocusListener(self) # hook to onLostFocus
        self.calendar.addSelectedDateListener(getattr(self, "onDateSelected"))
        self.todayLink.addClickListener(getattr(self, "onTodayClicked"))
        self.calendarLink.addClickListener(getattr(self, "onShowCalendar"))

    def getTextBox(self):
        return self.tbox

    def getCalendar(self):
        return self.calendar

    def getDate(self):
        """ returns datetime.date object or None if empty/unparsable by current format"""
        _sdate = self.tbox.getText()
        try:
            return datetime.strptime(_sdate, self.format).date()
        except ValueError:
            return None

    def setID(self, id):
        self.tbox.setID(id)

    def onDateSelected(self, yyyy, mm, dd):
        secs = time.mktime((int(yyyy), int(mm), int(dd), 0, 0, 0, 0, 0, -1))
        d = time.strftime(self.format, time.localtime(secs))
        self.tbox.setText(d)

    def onLostFocus(self, sender):
        #
        text = self.tbox.getText().strip()
        # if blank - leave it alone
        if text and len(text) == 8:
            # ok what format do we have? assume ddmmyyyy --> dd-mm-yyyy
            txt = text[0:2] + self.sep + text[2:4] + self.sep + text[4:8]
            self.tbox.setText(txt)

    def onFocus(self, sender):
        pass

    def onTodayClicked(self, event):
        today = time.strftime(self.format)
        self.tbox.setText(today)

    def onShowCalendar(self, sender):
        txt = self.tbox.getText().strip()
        try:
            if txt:
                _d = datetime.strptime(txt,self.format).date()
                self.calendar.setDate(_d)
        except ValueError: pass

        p = CalendarPopup(self.calendar)
        x = self.tbox.getAbsoluteLeft() + 10
        y = self.tbox.getAbsoluteTop() + 10
        p.setPopupPosition(x, y)
        p.show()
开发者ID:jwashin,项目名称:pyjs,代码行数:102,代码来源:Calendar.py

示例8: drawFull

# 需要导入模块: from pyjamas.ui.Hyperlink import Hyperlink [as 别名]
# 或者: from pyjamas.ui.Hyperlink.Hyperlink import addClickListener [as 别名]
    def drawFull(self, month, year):
        # should be called only once when we draw the calendar for
        # the first time
        self.vp = VerticalPanel()
        self.vp.setSpacing(0)
        self.vp.setPadding(0)
        self.vp.addStyleName("calendarbox calendar-module calendar")
        self.setWidget(self.vp)
        self.setVisible(False)
        #
        mth = int(month)
        yr = int(year)

        tp = HorizontalPanel(Width="100%")
        tp.addStyleName("calendar-top-panel")
        tp.setSpacing(0)
        tp.setPadding(0)

        self.h1 = None
        self.h2 = None
        self.h4 = None
        self.h5 = None
        if self.backyear:
            self.h1 = self.bkls(self.backyear, StyleName="calendar-arrows")
            self.h1.addClickListener(getattr(self, 'onPreviousYear'))
            tp.add(self.h1)
            tp.setCellHorizontalAlignment(self.h1, "left")
        if self.backmonth:
            self.h2 = self.bkls(self.backmonth, StyleName="calendar-arrows")
            self.h2.addClickListener(getattr(self, 'onPreviousMonth'))
            tp.add(self.h2)
            tp.setCellHorizontalAlignment(self.h2, "left")

        # titlePanel can be changed, whenever we draw, so keep the reference
        txt = "<b>"
        txt += self.getMonthsOfYear()[mth-1] + " " + str(yr)
        txt += "</b>"
        self.titlePanel = SimplePanel()
        self.titlePanel.setWidget(HTML(txt))
        self.titlePanel.setStyleName("calendar-center")

        tp.add(self.titlePanel)
        tp.setCellHorizontalAlignment(self.titlePanel, "center")
        tp.setCellWidth(self.titlePanel, "100%")

        if self.fwdmonth:
            self.h4 = self.bkls(self.fwdmonth, StyleName="calendar-arrows")
            self.h4.addClickListener(getattr(self, 'onNextMonth'))
            tp.add(self.h4)
            tp.setCellHorizontalAlignment(self.h4, "right")
            tp.setCellWidth(self.h4, "100%")
            self.h4.setWidth("100%")
        if self.fwdyear:
            self.h5 = self.bkls(self.fwdyear, StyleName="calendar-arrows")
            self.h5.addClickListener(getattr(self, 'onNextYear'))
            tp.add(self.h5)
            tp.setCellHorizontalAlignment(self.h5, "right")

        tvp = VerticalPanel(Width="100%")
        tvp.setSpacing(2)
        tvp.add(tp)

        self.vp.add(tvp)

        # done with top panel

        self.middlePanel = SimplePanel()
        grid = self.drawGrid(mth, yr)
        self.middlePanel.setWidget(grid)
        self.vp.add(self.middlePanel)
        self.defaultGrid = grid

        if self.addbuttons:
            #
            # some links & handlers
            #
            bh1 = Hyperlink(self.yesterday)
            bh1.addClickListener(getattr(self, 'onYesterday'))
            bh2 = Hyperlink(self.today)
            bh2.addClickListener(getattr(self, 'onToday'))
            bh3 = Hyperlink(self.tomorrow)
            bh3.addClickListener(getattr(self, 'onTomorrow'))
            bh4 = Hyperlink(self.cancel)
            bh4.addClickListener(getattr(self, 'onCancel'))

            #
            # add code to test another way of doing the layout
            #
            b = HorizontalPanel()
            b.add(bh1)
            b.add(bh2)
            b.add(bh3)
            b.addStyleName("calendar-shortcuts")
            self.vp.add(b)
            b2 = SimplePanel()
            b2.add(bh4)
            b2.addStyleName("calendar-cancel")
            self.vp.add(b2)

        self.checkLinks(mth, yr)
#.........这里部分代码省略.........
开发者ID:,项目名称:,代码行数:103,代码来源:

示例9: onClick

# 需要导入模块: from pyjamas.ui.Hyperlink import Hyperlink [as 别名]
# 或者: from pyjamas.ui.Hyperlink.Hyperlink import addClickListener [as 别名]
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
    serverXml = \
"""
<html>
  <head>
    <title>Example 5</title>
开发者ID:Afey,项目名称:pyjs,代码行数:33,代码来源:Anchor.py


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