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


Python Grid.setText方法代码示例

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


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

示例1: __init__

# 需要导入模块: from pyjamas.ui.Grid import Grid [as 别名]
# 或者: from pyjamas.ui.Grid.Grid import setText [as 别名]
    def __init__(self):

        # layed out in a grid with odd rows a different color for
        # visual separation
        #lucky = Grid(9,10, CellPadding=25, CellSpacing=1, BorderWidth=1)
        lucky = Grid()
        lucky.resize(9,10)
        lucky.setBorderWidth(1)
        lucky.setCellPadding(25)
        lucky.setCellSpacing(1)
        val = 0
        for x in range(0,9):
            for y in range(0,10):
                val += 1
                lucky.setText(x,y,val)

        grid = Grid(1,3,CellPadding=20,CellSpacing=0)
        rf = grid.getRowFormatter()
        rf.setStyleName(0, 'oddrow')

        # popup timer buttons
        ptb = PopupTimerButton(1)
        grid.setWidget(0, 0, CaptionPanel('Start the Lucky Number Countdown', ptb, StyleName='left'))
        grid.setWidget(0, 1, CaptionPanel('Current Lucky Number',ptb.box))
        grid.setWidget(0, 2, lucky)

        # add it all to the root panel
        RootPanel().add(grid, lucky)
开发者ID:rgeos,项目名称:bingo,代码行数:30,代码来源:bingo.py

示例2: GridWidget

# 需要导入模块: from pyjamas.ui.Grid import Grid [as 别名]
# 或者: from pyjamas.ui.Grid.Grid import setText [as 别名]
class GridWidget(AbsolutePanel):

    def __init__(self):
        AbsolutePanel.__init__(self)

        self.page=0
        self.min_page=1
        self.max_page=10
        
        self.addb=Button("Next >", self)
        self.subb=Button("< Prev", self)
        self.clearb=Button("Clear", self)
        
        self.g=Grid()
        self.g.resize(5, 5)
        self.g.setWidget(0, 0, HTML("<b>Grid Test</b>"))
        self.g.setBorderWidth(2)
        self.g.setCellPadding(4)
        self.g.setCellSpacing(1)
        
        self.updatePageDisplay()

        self.add(self.subb)
        self.add(self.addb)
        self.add(self.clearb)
        self.add(self.g)

    def onClick(self, sender):
        if sender == self.clearb:
            print "clear"
            self.g.clear()
            return
        elif sender==self.addb:
            self.page+=1
        elif sender==self.subb:
            self.page-=1
        self.updatePageDisplay()
        

    def updatePageDisplay(self):
        if self.page<self.min_page: self.page=self.min_page
        elif self.page>self.max_page: self.page=self.max_page
        total_pages=(self.max_page-self.min_page) + 1
        
        self.g.setHTML(0, 4, "<b>page %d of %d</b>" % (self.page, total_pages))
        
        if self.page>=self.max_page:
            self.addb.setEnabled(False)
        else:
            self.addb.setEnabled(True)
            
        if self.page<=self.min_page:
            self.subb.setEnabled(False)
        else:
            self.subb.setEnabled(True)

        for y in range(1, 5):
            for x in range(5):
                self.g.setText(y, x, "%d (%d,%d)" % (self.page, x, y))
开发者ID:anandology,项目名称:pyjamas,代码行数:61,代码来源:GridTest.py

示例3: AccountListSink

# 需要导入模块: from pyjamas.ui.Grid import Grid [as 别名]
# 或者: from pyjamas.ui.Grid.Grid import setText [as 别名]
class AccountListSink(VerticalPanel):
    def __init__(self, hendler = None):
        VerticalPanel.__init__(self,
                               #HorizontalAlignment=HasAlignment.ALIGN_CENTER,
                               #VerticalAlignment=HasAlignment.ALIGN_MIDDLE,
                               Width="100%",
                               #Height="100%",
                               Spacing=5)
                               
        self.remote = DataService(['getaccounts'])        
                               
        self.grid = Grid(1, 3,
                    BorderWidth=1,
                    CellPadding=4,
                    CellSpacing=1,
                    StyleName="grid")
        self.grid.setText(0, 0, u"Number")
        self.grid.setText(0, 1, u"Type")
        self.grid.setText(0, 2, u"Balance")
        
        formatter = self.grid.getRowFormatter()
        formatter.setStyleName(0, "grid-header")
        
        self.add(Label(u"Accounts"))
        
        self.add(self.grid)
        
    def updateGrid(self, accounts):         
        rows = len(accounts)
        if rows > 0:
            self.grid.resize(rows+1, 3)
            for row in range(rows):
                link = PseudoLink(accounts[row]['number'],
                                  self.onClick,
                                  ID=accounts[row]['number'])
                self.grid.setWidget(row+1, 0, link)
                self.grid.setText(row+1, 1, accounts[row]['type'])
                self.grid.setText(row+1, 2, accounts[row]['balance'])
                
    def onShow(self):
        self.remote.getaccounts(self)
        
    def onClick(self, sender):
        Window.alert(sender.getID())
         
                 
    def onRemoteResponse(self, response, request_info):
        '''
        Called when a response is received from a RPC.
        '''
        if request_info.method == 'getaccounts':
            #TODO
            self.updateGrid(response)
        else:
            Window.alert('Unrecognized JSONRPC method.')
            
    def onRemoteError(self, code, message, request_info):
        Window.alert(message)
开发者ID:fedenko,项目名称:clientbank,代码行数:60,代码来源:AccountListSink.py

示例4: __init__

# 需要导入模块: from pyjamas.ui.Grid import Grid [as 别名]
# 或者: from pyjamas.ui.Grid.Grid import setText [as 别名]
    def __init__(self):
        SimplePanel.__init__(self)

        grid = Grid(5, 5,
                    BorderWidth=2,
                    CellPadding=4,
                    CellSpacing=1)
        grid.setHTML(0, 0, '<b>Hello, World!</b>')

        for row in range(1, 5):
            for col in range(1, 5):
                grid.setText(row, col, str(row) + "*" + str(col) + " = " + str(row*col))

        self.add(grid)
开发者ID:Afey,项目名称:pyjs,代码行数:16,代码来源:grid.py

示例5: drawGrid

# 需要导入模块: from pyjamas.ui.Grid import Grid [as 别名]
# 或者: from pyjamas.ui.Grid.Grid import setText [as 别名]
    def drawGrid(self, month, year):
        # draw the grid in the middle of the calendar

        daysInMonth = self.getDaysInMonth(month, year)
        # first day of the month & year
        secs = time.mktime((year, month, 1, 0, 0, 0, 0, 0, -1))
        struct = time.localtime(secs)
        # 0 - sunday for our needs instead 0 = monday in tm_wday
        startPos = (struct.tm_wday + 1) % 7
        slots = startPos + daysInMonth - 1
        rows = int(slots/7) + 1
        grid = Grid(rows+1, 7) # extra row for the days in the week
        grid.setWidth("100%")
        grid.addTableListener(self)
        self.middlePanel.setWidget(grid)
        #
        # put some content into the grid cells
        #
        for i in range(7):
            grid.setText(0, i, self.getDaysOfWeek()[i])
            grid.cellFormatter.addStyleName(0, i, "calendar-header")
        #
        # draw cells which are empty first
        #
        day =0
        pos = 0
        while pos < startPos:
            grid.setText(1, pos , " ")
            grid.cellFormatter.setStyleAttr(1, pos, "background", "#f3f3f3")
            grid.cellFormatter.addStyleName(1, pos, "calendar-blank-cell")
            pos += 1
        # now for days of the month
        row = 1
        day = 1
        col = startPos
        while day <= daysInMonth:
            if pos % 7 == 0 and day <> 1:
                row += 1
            col = pos % 7
            grid.setText(row, col, str(day))
            if self.currentYear == self.todayYear and \
               self.currentMonth == self.todayMonth and day == self.todayDay:
                grid.cellFormatter.addStyleName(row, col, "calendar-cell-today")
            else:
                grid.cellFormatter.addStyleName(row, col, "calendar-day-cell")
            day += 1
            pos += 1
        #
        # now blank lines on the last row
        #
        col += 1
        while col < 7:
            grid.setText(row, col, " ")
            grid.cellFormatter.setStyleAttr(row, col, "background", "#f3f3f3")
            grid.cellFormatter.addStyleName(row, col, "calendar-blank-cell")
            col += 1

        return grid
开发者ID:jwashin,项目名称:pyjs,代码行数:60,代码来源:Calendar.py

示例6: DynaTableWidget

# 需要导入模块: from pyjamas.ui.Grid import Grid [as 别名]
# 或者: from pyjamas.ui.Grid.Grid import setText [as 别名]
class DynaTableWidget(Composite):

    def __init__(self, provider, columns, columnStyles, rowCount):
        Composite.__init__(self)

        self.acceptor = RowDataAcceptorImpl(self)
        self.outer = DockPanel()
        self.startRow = 0
        self.grid = Grid()
        self.navbar = NavBar(self)

        self.provider = provider
        self.initWidget(self.outer)
        self.grid.setStyleName("table")
        self.outer.add(self.navbar, DockPanel.NORTH)
        self.outer.add(self.grid, DockPanel.CENTER)
        self.initTable(columns, columnStyles, rowCount)
        self.setStyleName("DynaTable-DynaTableWidget")

    def initTable(self, columns, columnStyles, rowCount):
        self.grid.resize(rowCount + 1, len(columns))
        for i in range(len(columns)):
            self.grid.setText(0, i, columns[i])
            if columnStyles:
                self.grid.cellFormatter.setStyleName(0, i, columnStyles[i] + "header")

    def setStatusText(self, text):
        self.navbar.status.setText(text)

    def clearStatusText(self, text):
        self.navbar.status.setHTML("&nbsp;")

    def refresh(self):
        self.navbar.gotoFirst.setEnabled(False)
        self.navbar.gotoPrev.setEnabled(False)
        self.navbar.gotoNext.setEnabled(False)

        self.setStatusText("Please wait...")
        self.provider.updateRowData(self.startRow, self.grid.getRowCount() - 1, self.acceptor)

    def setRowCount(self, rows):
        self.grid.resizeRows(rows)

    def getDataRowCount(self):
        return self.grid.getRowCount() - 1
开发者ID:Afey,项目名称:pyjs,代码行数:47,代码来源:DynaTableWidget.py

示例7: __init__

# 需要导入模块: from pyjamas.ui.Grid import Grid [as 别名]
# 或者: from pyjamas.ui.Grid.Grid import setText [as 别名]
    def __init__(self):
        Sink.__init__(self)
        inner = Grid(10, 5, Width="100%", BorderWidth="1")
        outer = FlexTable(Width="100%", BorderWidth="1")

        outer.setWidget(0, 0, Image(self.baseURL() + "rembrandt/LaMarcheNocturne.jpg"))
        outer.getFlexCellFormatter().setColSpan(0, 0, 2)
        outer.getFlexCellFormatter().setHorizontalAlignment(0, 0, HasHorizontalAlignment.ALIGN_CENTER)

        outer.setHTML(1, 0, "Look to the right...<br>That's a nested table component ->")
        outer.setWidget(1, 1, inner)
        outer.getCellFormatter().setColSpan(1, 1, 2)
        
        for i in range(10):
            for j in range(5):
                inner.setText(i, j, "%d" % i + ",%d" % j)

        self.initWidget(outer)
开发者ID:FreakTheMighty,项目名称:pyjamas,代码行数:20,代码来源:Tables.py

示例8: Underway

# 需要导入模块: from pyjamas.ui.Grid import Grid [as 别名]
# 或者: from pyjamas.ui.Grid.Grid import setText [as 别名]
class Underway(HorizontalPanel):
    def __init__(self):
        HorizontalPanel.__init__(self, Spacing=4)
        self.add(Label('Underway:', StyleName='section'))
        s = ScrollPanel()
        self.add(s)
        v = VerticalPanel()
        s.add(v)
        self.queued = Grid(StyleName='users')
        v.add(self.queued)
        self.button = Button('Refresh', self, StyleName='refresh')
        self.add(self.button)
        self.err = Label()
        self.add(self.err)
        self.update()

    def update(self):
        remote = server.AdminService()
        id = remote.getUnderway(self)
        if id < 0:
            self.err.setText('oops: could not call getUnderway')

    def onRemoteResponse(self, result, request_info):
        self.button.setEnabled(True)
        self.queued.clear()
        if not result:
            self.queued.resize(1, 1)
            self.queued.setText(0, 0, 'No users are currently being added.')
        else:
            self.queued.resize(len(result) + 1, 6)
            self.queued.setText(0, 0, 'Pos')
            self.queued.setText(0, 1, 'Name')
            self.queued.setText(0, 2, 'Friends')
            self.queued.setText(0, 3, '% done')
            self.queued.setText(0, 4, 'Queued at')
            self.queued.setText(0, 5, 'Started at')
            row = 1
            for name, nFriends, done, queuedAt, startTime in result:
                self.queued.setText(row, 0, row)
                self.queued.setText(row, 1, name)
                self.queued.setText(row, 2, nFriends)
                self.queued.setText(row, 3, '%.2f' % done)
                self.queued.setText(row, 4, queuedAt)
                self.queued.setText(row, 5, startTime)
                row += 1

    def onRemoteError(self, code, message, request_info):
        self.button.setEnabled(True)
        self.err.setText('Could not getUnderway: ' + message)

    def onClick(self, sender):
        self.err.setText('')
        self.button.setEnabled(False)
        self.update()
开发者ID:fluidinfo,项目名称:Tickery,代码行数:56,代码来源:underway.py

示例9: PopupPagina

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

#.........这里部分代码省略.........
        lblinha2.addItem("4", value=4)
        lblinha2.addItem("5", value=5)

        lbcoluna1 = ListBox()
        lbcoluna1.setID("cm1")
        lbcoluna1.addItem("1", value=1)
        lbcoluna1.addItem("2", value=2)
        lbcoluna1.addItem("3", value=3)
        lbcoluna1.addItem("4", value=4)
        lbcoluna1.addItem("5", value=5)
        lbcoluna1.addItem("6", value=6)
        lbcoluna1.addItem("7", value=7)

        lbcoluna2 = ListBox()
        lbcoluna2.setID("cm2")
        lbcoluna2.addItem("1", value=1)
        lbcoluna2.addItem("2", value=2)
        lbcoluna2.addItem("3", value=3)
        lbcoluna2.addItem("4", value=4)
        lbcoluna2.addItem("5", value=5)
        lbcoluna2.addItem("6", value=6)
        lbcoluna2.addItem("7", value=7)

        self.lblStatus = Label("Label para Status")

        # Eventos
        self.imageFechar.addClickListener(self.onFecharPopup)

        # Cabeçalho da poupPanel
        self.grid = Grid(1, 16)
        self.grid.setWidth(self.getWidth())
        self.grid.setHTML(0, 0, "<b>Matriz 1:</b> Nº Linhas:")
        self.grid.setWidget(0, 1, lblinha1)
        self.grid.setText(0, 2, "Nº Colunas:")
        self.grid.setWidget(0, 3, lbcoluna1)
        self.grid.setHTML(0, 4, "<b>Matriz 2:</b> Nº Linhas:")
        self.grid.setWidget(0, 5, lblinha2)
        self.grid.setText(0, 6, "Nº Colunas:")
        self.grid.setWidget(0, 7, lbcoluna2)
        #        self.grid.setWidget(0, 3, self.txtColunas)
        self.grid.setWidget(0, 8, self.btnStepByStep)
        self.grid.setWidget(0, 9, self.btnDesfazer)
        self.grid.setWidget(0, 10, self.btnFazer)
        self.grid.setHTML(0, 11, "<b>Velocidade:</b>")
        self.grid.setWidget(0, 12, self.lbVelocidade)
        self.grid.setWidget(0, 13, self.btnAutomatic)
        # self.grid.setWidget(0, 14, self.btnInterativo)
        self.grid.setWidget(0, 15, self.imageFechar)
        # self.grid.setWidget(0, 7, self.btnFechar)
        self.grid.getCellFormatter().setAlignment(
            0, 15, HasHorizontalAlignment.ALIGN_RIGHT, HasVerticalAlignment.ALIGN_TOP
        )

        self.panel = FlexTable(Height="100%", width="100%", BorderWidth="0", CellPadding="0", CellSpacing="0")

        self.panel.setWidget(0, 0, self.caption)
        self.panel.setWidget(1, 0, self.grid)
        self.panel.getCellFormatter().setHeight(2, 0, "100%")
        self.panel.getCellFormatter().setWidth(2, 0, "100%")
        self.panel.getCellFormatter().setAlignment(
            2, 0, HasHorizontalAlignment.ALIGN_CENTER, HasVerticalAlignment.ALIGN_TOP
        )
        self.panel.setID("contetepopup")

        painelhorizontal = HorizontalPanel()
        gridinterativa = FlexTable()
开发者ID:nielsonsantana,项目名称:emath,代码行数:70,代码来源:PopupPagina.py

示例10: drawGrid

# 需要导入模块: from pyjamas.ui.Grid import Grid [as 别名]
# 或者: from pyjamas.ui.Grid.Grid import setText [as 别名]
    def drawGrid(self, month, year):
        # draw the grid in the middle of the calendar

        self.checkLinks(month, year)

        daysInMonth = self.getDaysInMonth(month, year)
        # first day of the month & year
        secs = time.mktime((year, month, 1, 0, 0, 0, 0, 0, -1))
        struct = time.localtime(secs)
        startPos = (struct.tm_wday + self.dayoffset) % 7
        slots = startPos + daysInMonth - 1
        rows = int(slots/7) + 1
        grid = Grid(rows+1, 7, # extra row for the days in the week
                    StyleName="calendar-grid") 
        grid.setWidth("100%")
        grid.addTableListener(self)
        self.middlePanel.setWidget(grid)
        cf = grid.getCellFormatter()
        #
        # put some content into the grid cells
        #
        for i in range(7):
            grid.setText(0, i, self.getDaysOfWeek()[i])
            cf.addStyleName(0, i, "calendar-header")
        #
        # draw cells which are empty first
        #
        day = 0
        pos = 0
        while pos < startPos:
            self._setCell(grid, 1, pos, BLANKCELL, "calendar-blank-cell")
            pos += 1
        # now for days of the month
        row = 1
        day = 1
        col = startPos
        while day <= daysInMonth:
            if pos % 7 == 0 and day != 1:
                row += 1
            col = pos % 7
            if not self._indaterange(self.currentYear, self.currentMonth, day):
                self._setCell(grid, row, col, BLANKCELL, "calendar-blank-cell")
                day += 1
                pos += 1
                continue
            if self.currentYear == self.todayYear and \
               self.currentMonth == self.todayMonth and day == self.todayDay:
                style = "calendar-cell-today"
            else:
                style = "calendar-day-cell"
            self._setCell(grid, row, col, str(day), style)
            day += 1
            pos += 1
        #
        # now blank lines on the last row
        #
        col += 1
        while col < 7:
            self._setCell(grid, row, col, BLANKCELL, "calendar-blank-cell")
            col += 1

        return grid
开发者ID:,项目名称:,代码行数:64,代码来源:

示例11: __init__

# 需要导入模块: from pyjamas.ui.Grid import Grid [as 别名]
# 或者: from pyjamas.ui.Grid.Grid import setText [as 别名]
    def __init__(self, statusSummary, sender):
        VerticalPanel.__init__(self, Spacing=10,
                               StyleName='userlist-error-box')
        self.add(HTML("We're currently working on users you mentioned",
                      StyleName='userlist-error-title'))

        self.add(HTML(
            """<p>Below is a summary of work already in progress, or
        queued, which must complete before we can run your query. Please
        note that Tickery is subject to Twitter's API rate limiting and
        general network latency, so you may need to be patient. We'll get
        there!</p>

        <p><a href=\"%s\">Here's a link</a> to this results page so you can
        come back to see how we're doing.  You can also click %r again to
        see updated progress.</p>""" %
            (sender.resultsLink(), go.goButtonText),
            StyleName='userlist-error-text'))

        nRows = 0

        underway = statusSummary['underway']
        nUnderway = len(underway)
        queued = statusSummary['queued']
        nQueued = len(queued)

        nCols = 4
        width = 200

        if nUnderway:
            nRows += nUnderway + 1
        if nQueued:
            nRows += nQueued + 1

        g = Grid(nRows, nCols, StyleName='users')
        g.setCellPadding(2)
        cellFormatter = g.getCellFormatter()
        row = 0

        if nUnderway:
            g.setHTML(row, 0, 'Users currently being processed&nbsp;')
            cellFormatter.setStyleName(row, 0, 'title-lhs')
            g.setText(row, 1, 'Name')
            cellFormatter.setStyleName(row, 1, 'title')
            g.setText(row, 2, 'Friends')
            cellFormatter.setStyleName(row, 2, 'title')
            g.setText(row, 3, '% done')
            cellFormatter.setStyleName(row, 3, 'title')
            cellFormatter.setWidth(row, 3, width)
            row += 1

            for u, nFriends, done in underway:
                cellFormatter.setStyleName(row, 0, 'blank')
                n = utils.splitthousands(nFriends)
                g.setHTML(row, 1, utils.screennameToTwitterLink(u))
                g.setHTML(row, 2, utils.screennameToTwitterFriendsLink(u, n))
                cellFormatter.setHorizontalAlignment(row, 2, 'right')

                pct = '%d' % int(done * 100.0)
                left = Label(pct, StyleName='done', Width=int(done * width))
                g.setWidget(row, 3, left)

                row += 1

        if nQueued:
            g.setHTML(row, 0, 'Users queued for processing&nbsp;')
            cellFormatter.setStyleName(row, 0, 'title-lhs')
            g.setText(row, 1, 'Name')
            cellFormatter.setStyleName(row, 1, 'title')
            g.setText(row, 2, 'Friends')
            cellFormatter.setStyleName(row, 2, 'title')
            g.setText(row, 3, 'Queue position')
            cellFormatter.setStyleName(row, 3, 'title')
            row += 1

            for u, nFriends, pos in queued:
                cellFormatter.setStyleName(row, 0, 'blank')
                n = utils.splitthousands(nFriends)
                g.setHTML(row, 1, utils.screennameToTwitterLink(u))
                g.setHTML(row, 2, utils.screennameToTwitterFriendsLink(u, n))
                cellFormatter.setHorizontalAlignment(row, 2, 'right')
                g.setText(row, 3, pos)
                cellFormatter.setHorizontalAlignment(row, 3, 'right')
                row += 1

        self.add(g)
开发者ID:fluidinfo,项目名称:Tickery,代码行数:88,代码来源:unknown.py

示例12: GridWidget

# 需要导入模块: from pyjamas.ui.Grid import Grid [as 别名]
# 或者: from pyjamas.ui.Grid.Grid import setText [as 别名]
class GridWidget(AbsolutePanel):
  def __init__(self):
    AbsolutePanel.__init__(self)

    StyleSheetCssText(margins) # initialize css...

    header = """<div><H2 align="center">Welcome to Unbeatable Tic-Tac-Toe!</H2><br>My <a href="https://github.com/chetweger/min-max-games/blob/master/ttt/ttt.py">implementation</a> uses the min-max search algorithm with alpha beta pruning and a transposition table!</div>"""
    header = HTML(header, StyleName='margins_both')
    self.add(header)

    self.ai_first = Button("AI first.", self, StyleName='margins_left')
    self.add(self.ai_first)

    self.new_game = Button("New game", self, StyleName='margins_left')
    self.add(self.new_game)

    self.g=Grid(StyleName='margins_left')
    self.g.resize(3, 3)
    self.g.setBorderWidth(2)
    self.g.setCellPadding(4)
    self.g.setCellSpacing(1)

    self.init()
    self.add(self.g)

    self.state = State()

    self.game_resolution=Label("", StyleName='margins_left')
    self.add(self.game_resolution)

  def start_new_game(self):
    self.state = State()
    self.game_over = False
    self.ai_first.setVisible(True)
    self.state_to_grid(self.state)

  def onClick(self, sender):
    if sender == self.ai_first:
      print 'player is ', self.state.player
      self.state.max_v = 1
      self.state.min_v = 2
      self.ai_first.setVisible(False)
      print 'button ai_first exists', hasattr(self, 'ai_first')

      self.state.print_me()
      next_state = ab(self.state)
      self.state = next_state
      self.state_to_grid(next_state)
      print '[after]player is ', self.state.player

    elif sender == self.new_game:
      self.start_new_game()

    else:
      print 'player is ', self.state.player
      '''
      self.g.setText(0, 1, 'wassup')
      self.g.setText(p['x'], p['y'], str(self.state.min_v))
      '''
      if self.ai_first.isVisible():
        print 'Setting state.max_v'
        self.state.max_v = 2
        self.state.min_v = 1
        self.ai_first.setVisible(False)
      p = sender.point
      self.g.setText(p['y'], p['x'], str(self.state.player))

      self.state = self.grid_to_state()
      self.check_for_tie() # end 1
      if is_win(self.state):
        self.state_to_grid(self.state, game_over=True, over_message='You won! This should not happen. This is a bug. Please email [email protected] describing the conditions of the game.')

      self.state.player = next_player(self.state.player)

      self.state.print_me()
      next_state = ab(self.state)
      self.state = next_state
      self.state_to_grid(next_state)
      self.check_for_tie() # end 1
      if is_win(self.state):
        self.state_to_grid(self.state, game_over=True, over_message='You lost! Better luck next time.')

  def check_for_tie(self):
    if is_over(self.state):
      self.state_to_grid(self.state, game_over=True, over_message='The game is a tie.')


  def state_to_grid(self, state, game_over=False, over_message=''):
    if over_message:
      self.game_resolution.setText(over_message)
      self.game_resolution.setVisible(True)
    else:
      self.game_resolution.setVisible(False)
    board = state.board
    for y in range(3):
      for x in range(3):
        if board[y][x] == 0:
          if not game_over:
            b = Button('Press', self)
            b.point = {'x':x, 'y':y}
#.........这里部分代码省略.........
开发者ID:chetweger,项目名称:min-max-games,代码行数:103,代码来源:TTT.py

示例13: Queued

# 需要导入模块: from pyjamas.ui.Grid import Grid [as 别名]
# 或者: from pyjamas.ui.Grid.Grid import setText [as 别名]
class Queued(HorizontalPanel):
    def __init__(self):
        HorizontalPanel.__init__(self, Spacing=4)
        self.add(Label("Queued:", StyleName="section"))
        s = ScrollPanel()
        self.add(s)
        v = VerticalPanel()
        s.add(v)
        self.queued = Grid(StyleName="users")
        v.add(self.queued)
        self.button = Button("Refresh", self, StyleName="refresh")
        self.add(self.button)
        self.err = Label()
        self.add(self.err)
        self.update()

    def update(self):
        remote = server.AdminService()
        id = remote.getQueued(self)
        if id < 0:
            self.err.setText("oops: could not call getQueued")

    def onRemoteResponse(self, result, request_info):
        self.button.setEnabled(True)
        self.queued.clear()
        if not result:
            self.queued.resize(1, 1)
            self.queued.setText(0, 0, "No users are queued for addition.")
        else:
            self.queued.resize(len(result) + 1, 4)
            self.queued.setText(0, 0, "Pos")
            self.queued.setText(0, 1, "Name")
            self.queued.setText(0, 2, "Friends")
            self.queued.setText(0, 3, "Queued at")
            row = 1
            for name, nFriends, time in result:
                self.queued.setText(row, 0, row)
                self.queued.setText(row, 1, name)
                self.queued.setText(row, 2, nFriends)
                self.queued.setText(row, 3, time)
                row += 1

    def onRemoteError(self, code, message, request_info):
        self.button.setEnabled(True)
        self.err.setText("Could not getQueued: " + message)

    def onClick(self, sender):
        self.err.setText("")
        self.button.setEnabled(False)
        self.update()
开发者ID:jdunck,项目名称:Tickery,代码行数:52,代码来源:queued.py


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