本文整理汇总了Python中pyjamas.Factory类的典型用法代码示例。如果您正苦于以下问题:Python Factory类的具体用法?Python Factory怎么用?Python Factory使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Factory类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: add
else:
element = DOM.createElement("map")
self.setElement(element)
ComplexPanel.__init__(self, **kwargs)
def add(self, widget):
self.insert(widget, self.getWidgetCount())
def insert(self, widget, beforeIndex):
widget.removeFromParent()
ComplexPanel.insert(self, widget, self.getElement(), beforeIndex)
def setName(self, name):
DOM.setAttribute(self.getElement(), "name", name)
Factory.registerClass('pyjamas.ui.ImageMap', ImageMap)
class MapArea(Widget, MouseHandler, ClickHandler):
""" An area inside an imagemap
"""
def __init__(self, Shape, Coords, **kwargs):
if not kwargs.has_key('Href'):
kwargs['Href'] = ""
kwargs['Shape'] = Shape
kwargs['Coords'] = Coords
if kwargs.has_key('Element'):
element = kwargs.pop('Element')
else:
element = DOM.createElement("area")
self.setElement(element)
Widget.__init__(self, **kwargs)
开发者ID:FreakTheMighty,项目名称:pyjamas,代码行数:31,代码来源:Map.py
示例2: InlineHTML
# Copyright 2010, Daniel Popowich <[email protected]>
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from pyjamas import DOM
from pyjamas import Factory
from pyjamas.ui.HTML import HTML
class InlineHTML(HTML):
'''An HTML, but using <span> instead of <div>'''
def __init__(self, html=None, wordWrap=True, **kwargs):
kwargs['StyleName'] = kwargs.get('StyleName', "gwt-InlineHTML")
kwargs['Element'] = DOM.createSpan()
HTML.__init__(self, html, wordWrap, **kwargs)
Factory.registerClass('pyjamas.ui.InlineHTML', 'InlineHTML', InlineHTML)
开发者ID:anthonyrisinger,项目名称:translate-pyjs-org.appspot.com,代码行数:27,代码来源:InlineHTML.py
示例3: prepareCell
return True
DOM.setInnerHTML(td, "")
return False
def prepareCell(self, row, column):
pass
def prepareRow(self, row):
pass
def removeCell(self, row, column):
self.checkCellBounds(row, column)
td = self.cleanCell(row, column)
tr = self.rowFormatter.getRow(self.bodyElem, row)
DOM.removeChild(tr, td)
def removeRow(self, row):
for column in range(self.getCellCount(row)):
self.cleanCell(row, column)
DOM.removeChild(self.bodyElem, self.rowFormatter.getRow(self.bodyElem, row))
def setCellFormatter(self, cellFormatter):
self.cellFormatter = cellFormatter
def setRowFormatter(self, rowFormatter):
self.rowFormatter = rowFormatter
Factory.registerClass('pyjamas.ui.HTMLTable', 'HTMLTable', HTMLTable)
开发者ID:Afey,项目名称:pyjs,代码行数:29,代码来源:HTMLTable.py
示例4: HyperlinkImage
class HyperlinkImage(Hyperlink):
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)
def addMouseListener(self, listener):
self.mouseListeners.append(listener)
def removeMouseListener(self,listener):
self.mouseListeners.remove(listener)
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)
Factory.registerClass('pyjamas.ui.HyperlinkImage', 'HyperlinkImage', HyperlinkImage)
开发者ID:anandology,项目名称:pyjamas,代码行数:27,代码来源:HyperlinkImage.py
示例5: addLoadListener
def addLoadListener(self, listener):
self.loadListeners.append(listener)
def removeLoadListener(self, listener):
self.loadListeners.remove(listener)
def getUrl(self):
return DOM.getAttribute(self.getElement(), "src")
def onBrowserEvent(self, event):
Widget.onBrowserEvent(self, event)
type = DOM.eventGetType(event)
if type == "load":
for listener in self.loadListeners:
listener.onImageLoad(self)
elif type == "error":
for listener in self.loadListeners:
listener.onImageError(self)
def prefetch(self, url):
img = DOM.createImg()
DOM.setElemAttribute(img, "src", url)
prefetchImages[url] = img
def setUrl(self, url):
DOM.setElemAttribute(self.getElement(), "src", url)
Factory.registerClass('pyjamas.ui.Image', 'Image', Image)
开发者ID:Afey,项目名称:pyjs,代码行数:28,代码来源:Image.py
示例6: ContextMenuPopupPanel
from pyjamas import DOM
from pyjamas import Factory
from PopupPanel import PopupPanel
class ContextMenuPopupPanel(PopupPanel):
def __init__(self, item, **kwargs):
self.item = item
kwargs['Widget'] = item
PopupPanel.__init__(self, True, **kwargs)
def showAt(self, x, y):
self.setPopupPosition(x, y)
self.item.onShow()
self.show()
def onEventPreview(self, event):
type = DOM.eventGetType(event)
if type == "click":
target = DOM.eventGetTarget(event)
parentMenuElement = self.item.getElement()
if DOM.isOrHasChild(parentMenuElement, target):
if self.item.onBrowserEvent(event):
self.hide()
return True
return PopupPanel.onEventPreview(self, event)
Factory.registerClass('pyjamas.ui.ContextMenuPopupPanel', ContextMenuPopupPanel)
开发者ID:FreakTheMighty,项目名称:pyjamas,代码行数:29,代码来源:ContextMenuPopupPanel.py
示例7: onMinimize
def onMinimize(self, sender):
if self._runDialogListener("onMinimize") is False:
return
widget = self.child
if widget is not None:
if widget.isVisible():
widget.setVisible(False)
self.setHeight("")
self.setWidth("")
if self._maximized:
self._minimized = self._maximized
self._toggleMaximize()
else:
self._minimized = None
else:
if self._minimized is not None:
self._toggleMaximize()
widget.setVisible(True)
def onClose(self, sender):
if self._runDialogListener("onClose") is False:
return
self.hide()
def onMouseUp(self, sender, x, y):
if self.dragStartX != x or self.dragStartY != y:
self.onActivate()
DialogBox.endDragging(self)
Factory.registerClass('pyjamas.ui.DialogWindow', 'DialogWindow', DialogWindow)
开发者ID:anthonyrisinger,项目名称:translate-pyjs-org.appspot.com,代码行数:30,代码来源:DialogWindow.py
示例8: hacks
DOM.appendChild(self.getElement(), self.container)
DOM.appendChild(self.container, leftDiv)
DOM.appendChild(self.container, splitDiv)
DOM.appendChild(self.container, rightDiv)
# Sadly, this is the only way I've found to get vertical
# centering in this case. The usually CSS hacks (display:
# table-cell, vertical-align: middle) don't work in an
# absolute positioned DIV.
thumb_html = '<img src="splitPanelThumb.png" />'
DOM.setInnerHTML(splitDiv,
"<table class='hsplitter' height='100%' cellpadding='0' " +
"cellspacing='0'><tr><td align='center' valign='middle'>" +
thumb_html +
"</td></tr></table>")
self.addScrolling(leftDiv)
self.addScrolling(rightDiv)
def getEndOfLinePos(self):
return 0
# TODO: return (LocaleInfo.getCurrentLocale().isRTL() ? 0 : 1)
def getStartOfLinePos(self):
return 1
# TODO: return (LocaleInfo.getCurrentLocale().isRTL() ? 1 : 0)
Factory.registerClass('pyjamas.ui.HorizontalSplitPanel', HorizontalSplitPanel)
开发者ID:FreakTheMighty,项目名称:pyjamas,代码行数:29,代码来源:horizsplitpanel.py
示例9: getStep
def getStep(self):
return DOM.getAttribute(self.getElement(), "step")
def getVisibleLength(self):
return DOM.getIntAttribute(self.getElement(), "size")
def setMaxLength(self, length):
DOM.setIntAttribute(self.getElement(), "maxLength", length)
def setKind(self, kind):
DOM.setAttribute(self.getElement(), "type", kind)
def setMin(self, min):
DOM.setAttribute(self.getElement(), "min", min)
def setMax(self, max):
DOM.setAttribute(self.getElement(), "max", max)
def setPlaceholder(self, placeholder):
DOM.setIntAttribute(self.getElement(), "placeholder", placeholder)
def setStep(self, step):
DOM.setAttribute(self.getElement(), "step", step)
def setVisibleLength(self, length):
DOM.setIntAttribute(self.getElement(), "size", length)
Factory.registerClass('pyjamas.ui.TextBox', 'TextBox', TextBox)
开发者ID:anandology,项目名称:pyjamas,代码行数:29,代码来源:TextBox.py
示例10: onBrowserEvent
SimplePanel.__init__(self, element)
self.disclosurePanel = disclosurePanel
element = self.getElement()
DOM.setAttribute(element, "href", "javascript:void(0);");
DOM.setStyleAttribute(element, "display", "block")
self.sinkEvents(Event.ONCLICK)
self.setStyleName("header")
def onBrowserEvent(self, event):
type = DOM.eventGetType(event)
if type == "click":
DOM.eventPreventDefault(event)
newstate = not self.disclosurePanel.getOpen()
self.disclosurePanel.setOpen(newstate)
Factory.registerClass('pyjamas.ui.ClickableHeader', ClickableHeader)
class DefaultHeader(Widget):
def __init__(self, text, disclosurePanel):
Widget.__init__(self)
self.disclosurePanel = disclosurePanel
self.imageBase = pygwt.getModuleBaseURL()
self.root = DOM.createTable()
self.tbody = DOM.createTBody()
self.tr = DOM.createTR()
self.imageTD = DOM.createTD()
self.labelTD = DOM.createTD()
self.imgElem = DOM.createImg()
self.updateState()
开发者ID:FreakTheMighty,项目名称:pyjamas,代码行数:31,代码来源:DisclosurePanel.py
示例11: int
if int(self.currentMonth) == 12:
self.currentMonth = 1
self.currentYear = int(self.currentYear) + 1
else:
self.currentMonth = int(self.currentMonth) + 1
self.draw(self.currentMonth, self.currentYear)
def drawPreviousYear(self):
self.currentYear = int(self.currentYear) - 1
self.draw(self.currentMonth, self.currentYear)
def drawNextYear(self):
self.currentYear = int(self.currentYear) + 1
self.draw(self.currentMonth, self.currentYear)
Factory.registerClass('pyjamas.ui.Calendar', 'Calendar', Calendar)
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:
开发者ID:jwashin,项目名称:pyjs,代码行数:31,代码来源:Calendar.py
示例12: ButtonBase
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from pyjamas import DOM
from pyjamas import Factory
from FocusWidget import FocusWidget
class ButtonBase(FocusWidget):
def __init__(self, element, **kwargs):
FocusWidget.__init__(self, element, **kwargs)
def getHTML(self):
return DOM.getInnerHTML(self.getElement())
def getText(self):
return DOM.getInnerText(self.getElement())
def setHTML(self, html):
DOM.setInnerHTML(self.getElement(), html)
def setText(self, text):
DOM.setInnerText(self.getElement(), text)
Factory.registerClass('pyjamas.ui.ButtonBase', ButtonBase)
开发者ID:FreakTheMighty,项目名称:pyjamas,代码行数:29,代码来源:ButtonBase.py
示例13: checkTabIndex
self.selectedTab = None
return True
self.selectedTab = self.panel.getWidget(index + 1)
self.setSelectionStyle(self.selectedTab, True)
for listener in self.tabListeners:
listener.onTabSelected(self, index)
return True
def checkTabIndex(self, index):
if (index < -1) or (index >= self.getTabCount()):
#throw new IndexOutOfBoundsException();
pass
def setSelectionStyle(self, item, selected):
if item is not None:
if selected:
item.addStyleName("gwt-TabBarItem-selected")
self.setStyleName(DOM.getParent(item.getElement()),
"gwt-TabBarItem-wrapper-selected", True)
else:
item.removeStyleName("gwt-TabBarItem-selected")
self.setStyleName(DOM.getParent(item.getElement()),
"gwt-TabBarItem-wrapper-selected", False)
Factory.registerClass('pyjamas.ui.TabBar', 'TabBar', TabBar)
开发者ID:anandology,项目名称:pyjamas,代码行数:29,代码来源:TabBar.py
示例14: round
widget_width = self.getOffsetWidth()
length_range = widget_width - 10 # handle width is hard-coded
val_diff_x = self.max_value_x - self.min_value_x
relative_x = length_range * (value_x - self.min_value_x) / val_diff_x
# limit the position to be in the widget!
if relative_x < 0:
relative_x = 0
if relative_x >= length_range:
relative_x = length_range
widget_height = self.getOffsetHeight()
height_range = widget_height - 10 # handle height is hard-coded
val_diff_y = self.max_value_y - self.min_value_y
relative_y = height_range * (value_y - self.min_value_y) / val_diff_y
# limit the position to be in the widget!
if relative_y < 0:
relative_y = 0
if relative_y >= height_range:
relative_y = height_range
relative_y = height_range - relative_y # turn round (bottom to top)
# move the handle
DOM.setStyleAttribute(self.handle, "top", "%dpx" % relative_y)
DOM.setStyleAttribute(self.handle, "left", "%dpx" % relative_x)
DOM.setStyleAttribute(self.handle, "position", "absolute")
Factory.registerClass('pyjamas.ui.AreaSlider', 'AreaSlider', AreaSlider)
开发者ID:anandology,项目名称:pyjamas,代码行数:30,代码来源:AreaSlider.py
示例15: round
relative_y = height_range
relative_y = height_range - relative_y # turn round (bottom to top)
val_diff = self.max_value - self.min_value
new_value = ((val_diff * relative_y) / height_range) + self.min_value
new_value = self.processValue(new_value)
self.setControlPos(new_value)
self.setValue(new_value)
def setControlPos(self, value):
widget_height = self.getOffsetHeight()
height_range = widget_height - 10 # handle height is hard-coded
val_diff = self.max_value - self.min_value
relative_y = height_range * (value - self.min_value) / val_diff
# limit the position to be in the widget!
if relative_y < 0:
relative_y = 0
if relative_y >= height_range:
relative_y = height_range
relative_y = height_range - relative_y # turn round (bottom to top)
# move the handle
DOM.setStyleAttribute(self.handle, "top", "%dpx" % relative_y)
DOM.setStyleAttribute(self.handle, "position", "absolute")
Factory.registerClass('pyjamas.ui.VerticalSlider', 'VerticalSlider', VerticalSlider)
开发者ID:Afey,项目名称:pyjs,代码行数:30,代码来源:VerticalSlider.py
示例16: addItem
def addItem(comp, props, childs, parentInstance, eventTarget):
klsname = comp['name']
modname = comp.get('module')
if modname is None:
modname = '.'.join(["pyjamas.ui", klsname])
kls = Factory.lookupClass('.'.join([modname, klsname]))
args = {}
wprops = {}
if props.has_key("common"):
wprops.update(props['common'])
if props.has_key("widget"):
wprops.update(props['widget'])
for n in kls._getProps():
name = n[ui.PROP_NAME]
if not wprops.has_key(name):
continue
fname = n[ui.PROP_FNAM]
if wprops[name] == '':
continue
args[fname] = wprops[name]
# create item with properties including weird ones
# which can't fit into the name value structure
item = kls(**args)
if hasattr(item, "_setWeirdProps"):
item._setWeirdProps(wprops, BuilderState(self, eventTarget))
tooltip = wprops.get('tooltip')
if tooltip is not None:
item.addMouseListener(TooltipListener(tooltip))
identifier = comp['id']
widget_order.append(identifier)
widgets_by_name[identifier] = klsname
widget_instances[identifier] = item
l = widgets_by_class.get(klsname, [])
l.append(identifier)
widgets_by_class[klsname] = l
#if parentInstance is not None:
# context = parentInstance.getIndexedChild(comp['index'])
# context.add(item.componentInstance)
for (index, child) in enumerate(childs):
if not child[0].has_key("type") or child[0]["type"] is None:
continue
childitem = addItem(child[0], child[1], child[2], item,
eventTarget)
if childitem is None:
continue
print "childitem", childitem
item.addIndexedItem(child[0]["index"], childitem)
if not "elements" in props:
props["elements"] = {}
if not index in props["elements"]:
props["elements"][index] = {}
elemprops = props['elements'][index]
print "elemprops", childitem, item, elemprops
item.setElementProperties(childitem, elemprops)
# add child (by name) to item
cname = child[0]["id"]
setattr(item, cname, childitem)
# make the event target the recipient of all events
if eventTarget is not None and props.has_key("events"):
added_already = []
#print props["events"]
for listener_name, listener_fn in props["events"].items():
if listener_name in added_already or not listener_fn:
continue
args = {}
args[listener_name] = listener_fn
fname = eventListeners[listener_name][0]
listener = MultiListener(eventTarget, **args)
setattr(item, "_%sListener" % fname, listener)
#print "add listener", listener_name, fname
listen_add_fn = getattr(item, fname)
listen_add_fn(listener)
return item
开发者ID:anthonyrisinger,项目名称:translate-pyjs-org.appspot.com,代码行数:81,代码来源:Builder.py
示例17: HTML
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from pyjamas import DOM
from pyjamas import Factory
from Label import Label
from pyjamas.ui import Event
from pyjamas.ui import InnerHTML
class HTML(Label, InnerHTML):
def __init__(self, html=None, wordWrap=True, Element=None, **kwargs):
if not kwargs.has_key('StyleName'): kwargs['StyleName']="gwt-HTML"
if html: kwargs['HTML'] = html
kwargs['WordWrap'] = wordWrap
if Element is None:
Element = DOM.createDiv()
self.setElement(Element)
Label.__init__(self, **kwargs)
self.sinkEvents(Event.ONCLICK | Event.MOUSEEVENTS)
Factory.registerClass('pyjamas.ui.HTML', HTML)
开发者ID:certik,项目名称:pyjamas,代码行数:29,代码来源:HTML.py
示例18: appendAndMaybeAdopt
elif layout.direction == self.WEST:
row = rows[northRow]
DOM.insertChild(row.tr, td, row.center)
row.center += 1
self.appendAndMaybeAdopt(td, child.getElement(), beingAdded)
DOM.setIntAttribute(td, "rowSpan", southRow - northRow + 1)
westCol += 1
elif layout.direction == self.EAST:
row = rows[northRow]
DOM.insertChild(row.tr, td, row.center)
self.appendAndMaybeAdopt(td, child.getElement(), beingAdded)
DOM.setIntAttribute(td, "rowSpan", southRow - northRow + 1)
eastCol -= 1
elif layout.direction == self.CENTER:
centerTd = td
if self.center is not None:
row = rows[northRow]
DOM.insertChild(row.tr, centerTd, row.center)
self.appendAndMaybeAdopt(centerTd, self.center.getElement(), beingAdded)
def appendAndMaybeAdopt(self, parent, child, beingAdded):
if beingAdded is not None:
if DOM.compare(child, beingAdded.getElement()):
CellPanel.add(self, beingAdded, parent)
return
DOM.appendChild(parent, child)
Factory.registerClass("pyjamas.ui.DockPanel", DockPanel)
开发者ID:andreyvit,项目名称:pyjamas,代码行数:30,代码来源:DockPanel.py
示例19: remove
widget.setVisible(False)
def remove(self, widget):
if isinstance(widget, int):
widget = self.getWidget(widget)
if not ComplexPanel.remove(self, widget):
return False
if self.visibleWidget == widget:
self.visibleWidget = None
return True
def showWidget(self, index):
self.checkIndex(index)
if self.visibleWidget is not None:
self.visibleWidget.setVisible(False)
self.visibleWidget = self.getWidget(index)
self.visibleWidget.setVisible(True)
def checkIndex(self, index):
if (index < 0) or (index >= self.getWidgetCount()):
# throw new IndexOutOfBoundsException();
pass
Factory.registerClass('pyjamas.ui.DeckPanel', DeckPanel)
开发者ID:certik,项目名称:pyjamas,代码行数:29,代码来源:DeckPanel.py
示例20: onControlValueChanged
self.value_x = new_value[0]
self.value_y = new_value[1]
if not notify:
return
for listener in self.valuechange_listeners:
listener.onControlValueChanged(self, old_value, new_value)
def onControlValueChanged(self, value_old_xy, value_new_xy):
pass
def onKeyDown(self, sender, keycode, modifiers):
if keycode == KeyboardListener.KEY_UP:
DOM.eventPreventDefault(DOM.eventGetCurrentEvent())
new_value = \
self.processValue((self.value_x + self.step_x,
self.value_y + self.step_y))
self.setControlPos(new_value)
self.setValue(new_value)
elif keycode == KeyboardListener.KEY_DOWN:
DOM.eventPreventDefault(DOM.eventGetCurrentEvent())
new_value = \
self.processValue((self.value_x - self.step_x,
self.value_y-self.step_y))
self.setControlPos(new_value)
self.setValue(new_value)
Factory.registerClass('pyjamas.ui.DoubleControl', 'DoubleControl', DoubleControl)
开发者ID:Afey,项目名称:pyjs,代码行数:29,代码来源:DoubleControl.py
注:本文中的pyjamas.Factory类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论