本文整理汇总了Python中pyjamas.ui.Hyperlink.Hyperlink类的典型用法代码示例。如果您正苦于以下问题:Python Hyperlink类的具体用法?Python Hyperlink怎么用?Python Hyperlink使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Hyperlink类的17个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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)
开发者ID:Afey,项目名称:pyjs,代码行数:26,代码来源:HTMLLinkPanel.py
示例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)
开发者ID:,项目名称:,代码行数:34,代码来源:
示例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)
开发者ID:jwashin,项目名称:pyjs,代码行数:8,代码来源:Calendar.py
示例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)
开发者ID:anandology,项目名称:pyjamas,代码行数:8,代码来源:HyperlinkImage.py
示例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)
开发者ID:anandology,项目名称:pyjamas,代码行数:9,代码来源:HyperlinkImage.py
示例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)
开发者ID:FreakTheMighty,项目名称:pyjamas,代码行数:57,代码来源:GChartExample24.py
示例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])
开发者ID:antialize,项目名称:djudge,代码行数:33,代码来源:main.py
示例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)
开发者ID:anthonyrisinger,项目名称:aur-pyjs,代码行数:40,代码来源:Search.py
示例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)
开发者ID:jwashin,项目名称:pyjs,代码行数:18,代码来源:Calendar.py
示例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
开发者ID:Afey,项目名称:pyjs,代码行数:51,代码来源:Calendar.py
示例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)
开发者ID:anthonyrisinger,项目名称:translate-pyjs-org.appspot.com,代码行数:17,代码来源:MonthField.py
示例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>
开发者ID:Afey,项目名称:pyjs,代码行数:29,代码来源:Anchor.py
示例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)
开发者ID:anandology,项目名称:pyjamas,代码行数:6,代码来源:SinkList.py
示例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()
开发者ID:jwashin,项目名称:pyjs,代码行数:100,代码来源:Calendar.py
示例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
开发者ID:jwashin,项目名称:pyjs,代码行数:60,代码来源:Calendar.py
示例16: 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(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:,项目名称:,代码行数:101,代码来源:
示例17: addAlgorithm
def addAlgorithm(self, info):
name = info.getName()
link = Hyperlink(name, False, TargetHistoryToken=name)
link.setStyleName("ks-AlgorithmItem")
self.vp_list.add(link)
self.Algorithms.append(info)
开发者ID:aprovodi,项目名称:mlServerCalculations,代码行数:6,代码来源:AlgorithmList.py
注:本文中的pyjamas.ui.Hyperlink.Hyperlink类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论