本文整理汇总了Python中pyjamas.ui.Hyperlink.Hyperlink类的典型用法代码示例。如果您正苦于以下问题:Python Hyperlink类的具体用法?Python Hyperlink怎么用?Python Hyperlink使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Hyperlink类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: replaceLinks
def replaceLinks(self, tagname="a"):
""" replaces <tag href="#pagename">sometext</tag> with:
Hyperlink("sometext", "pagename")
"""
tags = self.findTags(tagname)
pageloc = Window.getLocation()
pagehref = pageloc.getPageHref()
for el in tags:
href = el.href
l = href.split("#")
if len(l) != 2:
continue
if l[0] != pagehref:
continue
token = l[1]
if not token:
continue
html = DOM.getInnerHTML(el)
parent = DOM.getParent(el)
index = DOM.getChildIndex(parent, el)
hl = Hyperlink(TargetHistoryToken=token,
HTML=html,
Element=DOM.createSpan())
DOM.insertChild(parent, hl.getElement(), index)
self.children.insert(index, hl)
parent.removeChild(el)
示例2: replaceLinks
def replaceLinks(self, tagname="a", use_page_href=True, ajaxify=False):
""" replaces <tag href="#pagename">sometext</tag> with:
Hyperlink("sometext", "pagename"). Hyperlinks use
the History module so the notification will come
in on an onHistoryChanged.
"""
self._clear_hyperlinks()
tags = self.findTags(tagname)
pageloc = Window.getLocation()
pagehref = pageloc.getPageHref()
for el in tags:
href = el.href
l = href.split("#")
if len(l) != 2:
continue
if use_page_href and not l[0].startswith(pagehref):
continue
token = l[1]
if not token:
continue
html = DOM.getInnerHTML(el)
parent = DOM.getParent(el)
index = DOM.getChildIndex(parent, el)
if ajaxify:
token = '!%s' % token
hl = Hyperlink(TargetHistoryToken=token,
HTML=html,
Element=DOM.createSpan())
DOM.insertChild(parent, hl.getElement(), index)
parent.removeChild(el)
self.children.insert(index, hl)
hl.setParent(self)
self.hyperlinks.append(hl)
示例3: _gridCancelLink
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)
示例4: __init__
def __init__(self, img, **kwargs):
self.mouseListeners = []
if not kwargs.has_key('StyleName'):
kwargs['StyleName'] = 'gwt-HyperlinkImage'
Hyperlink.__init__(self, **kwargs)
DOM.appendChild(DOM.getFirstChild(self.getElement()), img.getElement())
img.unsinkEvents(Event.ONCLICK | Event.MOUSEEVENTS)
self.sinkEvents(Event.ONCLICK | Event.MOUSEEVENTS)
示例5: onBrowserEvent
def onBrowserEvent(self, event):
type = DOM.eventGetType(event)
if type == 'mousedown' or type == 'mouseup' or type == 'mousemove' or type == 'mouseover' or type == 'mouseout':
MouseListener.fireMouseEvent(self.mouseListeners, self, event)
# stop event falling through esp. for drag on image
DOM.eventPreventDefault(event)
else:
Hyperlink.onBrowserEvent(self, event)
示例6: __init__
def __init__(self):
GChart.__init__(self)
self.SELECTION_CURVE = 0 # curve index of selection cursor
self.p1 = Point(); # first corner (@mousedown) of selection rect
self.p2 = Point(); # second corner (@mouseup) of selection rect
self.selecting = False
self.moving = False
self.ctrlPressed = False; # as evaluated at mouse down
self.altPressed = False
# (# zoom ins) - (# zoom outs) since selection rect created
# lets us know when to restore initial plot area limits/cursor
self.zoomIndex = 0
self.zoomController = ZoomController(self)
# min plot area fraction zoom selection cursor must capture
self.initialPlotRegion = Region()
self.initialSelectionRegion = Region()
self.setChartTitle(
"Drag to pan; Press Ctrl while drag-selecting a rectangle to zoom")
self.setChartSize(500, 150)
a = Hyperlink("huh?")
a.setPixelSize(10, 500)
self.getYAxis().setAxisLabel(a)
# another option is to use clipToDecoratedChart(True) instead.
self.setClipToPlotArea(True)
self.addCurve()
for i in range(N_POINTS):
self.getCurve().addPoint(i, math.sin((2* math.pi * i)/N_POINTS)*
math.sin(10*(2* math.pi * i)/N_POINTS))
self.getCurve().getSymbol().setSymbolType(SymbolType.LINE)
# will use this curve to create the selection cursor
self.addCurve()
self.getCurve().addPoint(-Double.MAX_VALUE, -Double.MAX_VALUE)
self.getCurve().setVisible(False)
# preferentially selects cursor over ordinary curves:
self.getCurve().getSymbol().setDistanceMetric(0,0)
self.getCurve().getSymbol().setHoverWidget(self.zoomController)
self.getCurve().getSymbol().setHoverLocation( AnnotationLocation.CENTER)
# hides hover-buttons when mouse is outside zoom-cursor
self.getCurve().getSymbol().setBrushSize(0, 0)
self.SELECTION_CURVE = self.getNCurves()-1
# give them some x-panning space
self.getXAxis().setAxisMin(0.25*N_POINTS)
self.getXAxis().setAxisMax(0.75*N_POINTS)
self.getYAxis().setTickLabelThickness(50)
self.getYAxis().setAxisMin(-0.5)
self.getYAxis().setAxisMax(0.5)
"""
self.addClickListener(self)
"""
self.addMouseListener(self)
示例7: onRemoteResponse
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])
示例8: drawControl
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)
示例9: _gridShortcutsLinks
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)
示例10: __init__
def __init__(self, format='%d-%m-%Y'):
DateSelectedHandler.__init__(self)
if self.img_base is None:
self.img_base = pygwt.getImageBaseURL(True)
if self.icon_img is None:
self.icon_img = self.img_base + 'icon_calendar.gif'
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"))
self.tbox.addChangeListener(getattr(self, "onFieldChanged"))
self.tbox.addInputListener(getattr(self, "onFieldChanged"))
self._last_date = None
示例11: _gridShortcutsLinks
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)
示例12: onClick
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>
示例13: addSink
def addSink(self, info):
name = info.getName()
link = Hyperlink(name, False, TargetHistoryToken=name)
link.setStyleName("ks-SinkItem")
self.vp_list.add(link)
self.sinks.append(info)
示例14: DateField
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()
示例15: drawFull
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