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


Python pyjamas.Factory类代码示例

本文整理汇总了Python中pyjamas.Factory的典型用法代码示例。如果您正苦于以下问题:Python Factory类的具体用法?Python Factory怎么用?Python Factory使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Factory类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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


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