當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。