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


Python RootPanel.add方法代码示例

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


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

示例1: work

# 需要导入模块: from pyjamas.ui.RootPanel import RootPanel [as 别名]
# 或者: from pyjamas.ui.RootPanel.RootPanel import add [as 别名]
class FlowPanelDemo:
    """Demos the flow panel. Because of how the Flow Panel works, all elements have to be inline elements.
        Divs, tables, etc. can't be used, unless specified with CSS that they are inline or inline-block.

        Because of how Vertical Panels work (with tables), we use CSS to display tables as inline-blocks.
        IE, excluding IE8, doesn't support inline-blocks, so we have to use a CSS hack
        (see http://blog.mozilla.com/webdev/2009/02/20/cross-browser-inline-block/ for more on the hack)
        However, we use spans instead of divs for the Label by providing an 'element' argument."""
       
    def __init__(self):
        self.root = RootPanel()
        #Flow panel taking up 70% of the page.  CSS centers it.
        self.flow = FlowPanel(Width="70%", StyleName='flow-panel')
       
       
        for x in range(0, 10):
            self.panel = VerticalPanel()
            #Label each image with its number in the sequence
            title = Label("Item %s" % x, element=DOM.createElement('span'), StyleName="title item")
            #Add a neat-o image.
            image = Image('images/pyjamas.png', Width="200px", Height="200px", StyleName="cat-image cat-item")
            #Add to the Vertical Panel the image title
            self.panel.add(title)
            self.panel.add(image)

            self.flow.add(self.panel)

        self.root.add(self.flow)
开发者ID:certik,项目名称:pyjamas,代码行数:30,代码来源:FlowPanel.py

示例2: main

# 需要导入模块: from pyjamas.ui.RootPanel import RootPanel [as 别名]
# 或者: from pyjamas.ui.RootPanel.RootPanel import add [as 别名]
def main(init):
    root = RootPanel()
    container = FocusPanel()
    DeferredCommand.add(Focus(container))
    root.add(container)
    container.setSize(21*15,21*15)
    init(container)
开发者ID:bhuztez,项目名称:canvas-snake,代码行数:9,代码来源:webutils.py

示例3: onModuleLoad

# 需要导入模块: from pyjamas.ui.RootPanel import RootPanel [as 别名]
# 或者: from pyjamas.ui.RootPanel.RootPanel import add [as 别名]
 def onModuleLoad(self):
     slot = RootPanel("calendar")
     if slot is not None:
         calendar = SchoolCalendarWidget(15)
         slot.add(calendar)
         
         slot = RootPanel("days")
         if slot is not None:
             filterWidget = DayFilterWidget(calendar)
             slot.add(filterWidget)
开发者ID:anandology,项目名称:pyjamas,代码行数:12,代码来源:DynaTable.py

示例4: main

# 需要导入模块: from pyjamas.ui.RootPanel import RootPanel [as 别名]
# 或者: from pyjamas.ui.RootPanel.RootPanel import add [as 别名]
def main():
    root = RootPanel()
    tree = Tree()
    cb1 = CheckBox('test 1')
    cb1.addClickListener(onCb1)
    root.add(cb1)
    cb2 = CheckBox('test 2')
    cb2.addClickListener(onCb2)
    item = TreeItem(cb2)
    tree.addItem(item)
    root.add(tree)
开发者ID:brodybits,项目名称:pyjs,代码行数:13,代码来源:TreeItemTest.py

示例5: onModuleLoad

# 需要导入模块: from pyjamas.ui.RootPanel import RootPanel [as 别名]
# 或者: from pyjamas.ui.RootPanel.RootPanel import add [as 别名]
class MapProgram:
    def onModuleLoad( self ):
        self.setUpInstanceVariables()
        self.assemblePanels()
        self.setUpListeners()
        self.service.usernames( self.userNameReceiver )
        self.controlPanel.numPointsListBox.setSelectedIndex( 1 )
        self.service.shakeevents( 'Last Week', self.controlPanel.nameListBox.getValue( self.controlPanel.nameListBox.getSelectedIndex() ), self.shakeEventPointReceiver )


    def setUpInstanceVariables( self ):
        self.service = MapService()
        self.root = RootPanel()
        self.controlPanel = TopPanel()
        self.mapPanel = MapPanel()
        self.userNameReceiver = UserNameReceiver( self )
        #self.usgsPointReceiver = USGSPointReceiver(self)
        self.shakeEventPointReceiver = ShakeEventPointReceiver( self )
        self.markers = []

    def assemblePanels( self ):
        vp = VerticalPanel()
        vp.add( self.controlPanel )
        vp.add( self.mapPanel )
        self.root.add( vp )

    def setUpListeners( self ):
        npBox = self.controlPanel.numPointsListBox
        unBox = self.controlPanel.nameListBox
        def npFn():
            #self.service.points(npBox.getValue(npBox.getSelectedIndex()),self.usgsPointReceiver)
            self.controlPanel.statusHTML.setHTML( 'Fetching Points...' )
            self.service.shakeevents( npBox.getValue( npBox.getSelectedIndex() ), unBox.getValue( unBox.getSelectedIndex() ), self.shakeEventPointReceiver )
        npBox.addChangeListener( npFn )
        unBox.addChangeListener( npFn )

    def mouseOverMarker( self,ind ):
        Window.alert('test1')
        marker = self.markers[ind]
        iwo = InfoWindowOptions()
        iwo.position = marker['latlng']
        iwo.content = marker['title']
        Window.alert('test2')
        self.iw = InfoWindow( iwo )
        self.iw.open( self.mapPanel.map )

    def mouseOutMarker( self ):
        self.iw.close()
开发者ID:jackdreilly,项目名称:iShakeBackend,代码行数:50,代码来源:EventSimple.py

示例6: onModuleLoad

# 需要导入模块: from pyjamas.ui.RootPanel import RootPanel [as 别名]
# 或者: from pyjamas.ui.RootPanel.RootPanel import add [as 别名]
class PanelApp:
    """ A generic multiple-panel web application.

        This class makes it easy to handle multiple panels within a web
        application.  Panels are shown as they are required.
    """
    def onModuleLoad(self):
        """ Dynamically build our user interface when the web page is loaded.
        """
        self._curPanelID = None # ID of currently-shown panel.
        self._root       = RootPanel()

        self._panels = self.createPanels()
        self.showPanel(self.getDefaultPanel())


    def showPanel(self, panelID):
        """ Show the panel with the given ID.
        """
        if panelID == self._curPanelID: return

        if self._curPanelID is not None:
            self._root.remove(self._panels[self._curPanelID])

        self._root.add(self._panels[panelID])
        self._curPanelID = panelID

    # ==============================
    # == METHODS TO BE OVERRIDDEN ==
    # ==============================

    def createPanels(self):
        """ Create the various panels to be used by this application.

            This should be overridden by the subclass to create the various
            panels the application will use.  Upon completion, the subclass
            should return a dictionary mapping the ID to use for each panel to
            the panel to be displayed.
        """
        Window.alert("Must be overridden.")


    def getDefaultPanel(self):
        """ Return the ID of the panel to show on system startup.
        """
        Window.alert("Must be overridden.")
开发者ID:FreakTheMighty,项目名称:pyjamas,代码行数:48,代码来源:uiHelpers.py

示例7: SimplePanel

# 需要导入模块: from pyjamas.ui.RootPanel import RootPanel [as 别名]
# 或者: from pyjamas.ui.RootPanel.RootPanel import add [as 别名]
# 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.ui.RootPanel import RootPanel, RootPanelCls
from pyjamas.ui.SimplePanel import SimplePanel
from pyjamas import DOM

from pyjamas.gmaps.Map import Map, MapTypeId, MapOptions
from pyjamas.gmaps.Base import LatLng


if __name__ == '__main__':

    mapPanel = SimplePanel()
    mapPanel.setSize('100%', '100%')

    options = MapOptions(zoom=8, center=LatLng(-34.397, 150.644),
                         mapTypeId=MapTypeId.ROADMAP)

    #options = MapOptions()
    #options.zoom = 8
    #options.center = LatLng(-34.397, 150.644)
    #options.mapTypeId = MapTypeId.ROADMAP

    map = Map(mapPanel.getElement(), options)

    #root = RootPanelCls(DOM.getElementById("here"))
    root = RootPanel()
    root.add(mapPanel)
开发者ID:Afey,项目名称:pyjs,代码行数:32,代码来源:MapSimple.py

示例8: MapOptions

# 需要导入模块: from pyjamas.ui.RootPanel import RootPanel [as 别名]
# 或者: from pyjamas.ui.RootPanel.RootPanel import add [as 别名]
                style=MapTypeControlStyle.DROPDOWN_MENU),

            navigationControl=True,
            navigationControlOptions=NavigationControlOptions(
                style=NavigationControlStyle.SMALL))
        # the same, in a extensive way:

        #options = MapOptions()

        #options.zoom = 4
        #options.center = LatLng(-25.363882, 131.044922)
        #options.mapTypeId = MapTypeId.ROADMAP

        #options.mapTypeControl = True
        #options.mapTypeControlOptions = MapTypeControlOptions()
        #options.mapTypeControlOptions.style =
        #   MapTypeControlStyle.DROPDOWN_MENU

        #options.navigationControl = True
        #options.navigationControlOptions = NavigationControlOptions()
        #options.navigationControlOptions.style = \
        #    NavigationControlStyle.SMALL

        self.map = Map(self.getElement(), options)


if __name__ == '__main__':

    root = RootPanel()
    root.add(ControlOptions())
开发者ID:Afey,项目名称:pyjs,代码行数:32,代码来源:ControlOptions.py

示例9: StudentContainer

# 需要导入模块: from pyjamas.ui.RootPanel import RootPanel [as 别名]
# 或者: from pyjamas.ui.RootPanel.RootPanel import add [as 别名]
        HorizontalPanel.__init__(self)
        #self.setSpacing('10px')

        pool = StudentContainer(1, 20, 'pool_1')
        for item in [['Fred', 12], ['Jane', 10], ['Sam', 18],
                     ['Ginger', 8], ['Mary', 4]]:
            pool.addStudent(name=item[0], age=item[1])
        self.append(pool)
        self.append(StudentContainer(6, 13, 'pool_2'))
        self.append(StudentContainer(11, 20, 'pool_3'))
        self.setSpacing('10px')

    def containerFromId(self, id):
        for item in self.children:
            if item.getID() == id:
                return item


class MultiTargetDemo(DNDDemo):
    def __init__(self):
        self.drop_widget = ClassContainer()
        self.title = 'Drop with Validation'
        self.id = 'multi'
        DNDDemo.__init__(self)

if __name__ == '__main__':
    pyjd.setup("./public/DNDTest.html")
    j = RootPanel()
    j.add(DNDDemos())
    pyjd.run()
开发者ID:anandology,项目名称:pyjamas,代码行数:32,代码来源:DNDTest.py

示例10: range

# 需要导入模块: from pyjamas.ui.RootPanel import RootPanel [as 别名]
# 或者: from pyjamas.ui.RootPanel.RootPanel import add [as 别名]
        latSpan = northEast.lat() - southWest.lat()

        for i in range(0, 5):
            location = LatLng(southWest.lat() + latSpan * random(),
              southWest.lng() + lngSpan * random())

            options = MarkerOptions()
            options.position = location
            options.map = self.map

            marker = Marker(options)
            marker.setTitle(str(i + 1))

            self.attachSecretMessage(marker, i)

    def attachSecretMessage(self, marker, number):
        message = ["This", "is", "the", "secret", "message"]

        options = InfoWindowOptions()
        options.content = message[number]

        infoWindow = InfoWindow(options)

        marker.addListener('click', lambda: infoWindow.open(self.map, marker))


if __name__ == '__main__':

    root = RootPanel()
    root.add(EventClosure())
开发者ID:Afey,项目名称:pyjs,代码行数:32,代码来源:EventClosure.py

示例11: MapOptions

# 需要导入模块: from pyjamas.ui.RootPanel import RootPanel [as 别名]
# 或者: from pyjamas.ui.RootPanel.RootPanel import add [as 别名]
        SimplePanel.__init__(self)
        self.setSize('100%', '100%')

        options = MapOptions()
        options.zoom = 4
        options.center = LatLng(-25.363882, 131.044922)
        options.mapTypeId = MapTypeId.ROADMAP

        self.map = Map(self.getElement(), options)

        self.map.addListener("click", self.clicked)

    def clicked(self, event):
        print "clicked on " + str(event.latLng)
        self.placeMarker(event.latLng)

    def placeMarker(self, location):
        options = MarkerOptions()
        options.position = location
        options.map = self.map

        marker = Marker(options)

        self.map.setCenter(location)


if __name__ == '__main__':

    root = RootPanel()
    root.add(EventArguments())
开发者ID:Afey,项目名称:pyjs,代码行数:32,代码来源:EventArguments.py

示例12: grid_to_state

# 需要导入模块: from pyjamas.ui.RootPanel import RootPanel [as 别名]
# 或者: from pyjamas.ui.RootPanel.RootPanel import add [as 别名]
        self.add(g)
        self.g.setWidget(y_board, x_board, g)

  def grid_to_state(self, point):
    board = self.state.boards
    for y_board in range(3):
      for x_board in range(3):
        g = self.g.getWidget(y_board, x_board)
        for y_cell in range(3):
          for x_cell in range(3):
            if isinstance(g.getWidget(y_cell, x_cell), Button):
              assert board[y_board][x_board][y_cell][x_cell]['cell'] == 0
            elif (g.getText(y_cell, x_cell) == '1') or (g.getText(y_cell, x_cell) == '2'):
              if self.state.boards[y_board][x_board][y_cell][x_cell]['cell'] == 0:
                self.state.boards[y_board][x_board][y_cell][x_cell]['cell'] = int(g.getText(y_cell, x_cell))
                piece = self.state.next_piece
                piece[0] = y_cell
                piece[1] = x_cell
            else:
              assert (g.getText(y_cell, x_cell) == '-')
    if is_win(self.state.boards[point['y_board']][point['x_board']]):
      self.state.score[str(self.min_player)] += 1


if __name__ == '__main__':
  pyjd.setup("./GridTest.html")
  g = GridWidget()
  r = RootPanel()
  r.add(g)
  pyjd.run()
开发者ID:chetweger,项目名称:min-max-games,代码行数:32,代码来源:Meta.py

示例13: MapOptions

# 需要导入模块: from pyjamas.ui.RootPanel import RootPanel [as 别名]
# 或者: from pyjamas.ui.RootPanel.RootPanel import add [as 别名]
        SimplePanel.__init__(self)
        self.setSize("100%", "100%")

        options = MapOptions()
        options.zoom = 4
        options.center = LatLng(-25.363882, 131.044922)
        options.mapTypeId = MapTypeId.ROADMAP

        self.map = Map(self.getElement(), options)

        self.map.addListener("zoom_changed", self.zoomChanged)

        self.map.addListener("click", self.clicked)

    def zoomChanged(self):
        print "zoom to " + str(self.map.getZoom())
        Timer(1500, self.moveToDarwin)

    def moveToDarwin(self, timer):
        darwin = LatLng(-12.461334, 130.841904)
        self.map.setCenter(darwin)

    def clicked(self):
        self.map.setZoom(8)


if __name__ == "__main__":

    root = RootPanel()
    root.add(EventSimple())
开发者ID:luiseduardohdbackup,项目名称:pyjs,代码行数:32,代码来源:EventSimple.py

示例14: ControlDisableUI

# 需要导入模块: from pyjamas.ui.RootPanel import RootPanel [as 别名]
# 或者: from pyjamas.ui.RootPanel.RootPanel import add [as 别名]
from pyjamas.ui.RootPanel import RootPanel, RootPanelCls
from pyjamas.ui.SimplePanel import SimplePanel
from pyjamas import DOM
from pyjamas.Timer import Timer

from pyjamas.gmaps.Map import Map, MapTypeId, MapOptions
from pyjamas.gmaps.Base import LatLng


class ControlDisableUI(SimplePanel):

    def __init__(self):
        SimplePanel.__init__(self)
        self.setSize('100%', '100%')

        options = MapOptions()

        options.zoom = 4
        options.center = LatLng(-33, 151)
        options.mapTypeId = MapTypeId.ROADMAP

        options.disableDefaultUI = True

        self.map = Map(self.getElement(), options)


if __name__ == '__main__':

    root = RootPanel()
    root.add(ControlDisableUI())
开发者ID:Afey,项目名称:pyjs,代码行数:32,代码来源:ControlDisableUI.py

示例15: ControlSimple

# 需要导入模块: from pyjamas.ui.RootPanel import RootPanel [as 别名]
# 或者: from pyjamas.ui.RootPanel.RootPanel import add [as 别名]
from pyjamas.Timer import Timer

from pyjamas.gmaps.Map import Map, MapTypeId, MapOptions
from pyjamas.gmaps.Base import LatLng


class ControlSimple(SimplePanel):

    def __init__(self):
        SimplePanel.__init__(self)
        self.setSize('100%', '100%')

        #options = MapOptions()
        #options.zoom = 4
        #options.center = LatLng(-33, 151)
        #options.mapTypeId = MapTypeId.ROADMAP
        #options.navigationControl = False
        #options.scaleControl = True

        options = MapOptions(zoom=4, center=LatLng(-33, 151),
                           mapTypeId=MapTypeId.ROADMAP,
                           navigationControl=False, scaleControl=True)

        self.map = Map(self.getElement(), options)


if __name__ == '__main__':

    root = RootPanel()
    root.add(ControlSimple())
开发者ID:Afey,项目名称:pyjs,代码行数:32,代码来源:ControlSimple.py


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