本文整理汇总了Python中pyjamas.ui.Button.Button.point方法的典型用法代码示例。如果您正苦于以下问题:Python Button.point方法的具体用法?Python Button.point怎么用?Python Button.point使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyjamas.ui.Button.Button
的用法示例。
在下文中一共展示了Button.point方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: state_to_grid
# 需要导入模块: from pyjamas.ui.Button import Button [as 别名]
# 或者: from pyjamas.ui.Button.Button import point [as 别名]
def state_to_grid(self, prev_x_board=-1, prev_y_board=-1, prev_x_cell=-1, prev_y_cell=-1):
board = self.state.boards
for y_board in range(3):
for x_board in range(3):
# for this mini-grid, do i make buttons or dashes?
will_make_buttons = self.will_buttons(y_board, x_board)
g=Grid()
g.resize(3, 3)
g.setBorderWidth(2)
g.setCellPadding(9)
g.setCellSpacing(1)
for y_cell in range(3):
for x_cell in range(3):
if board[y_board][x_board][y_cell][x_cell]['cell'] == 0:
if will_make_buttons:
if self.min_player == -1:
b = Button('Play 1 here.', self)
else:
b = Button('Play %d here.' % (self.state.next_piece[2]), self)
b.point = {'x_cell':x_cell, 'y_cell':y_cell, 'y_board': y_board, 'x_board': x_board}
else:
b = HTML('-')
elif board[y_board][x_board][y_cell][x_cell]['cell'] == 1:
if (prev_x_cell == x_cell and
prev_y_cell == y_cell and
prev_y_board == y_board and
prev_x_board == x_board):
b = HTML('<p style="color:red">1</p>')
else:
b = HTML('1')
elif board[y_board][x_board][y_cell][x_cell]['cell'] == 2:
if (prev_x_cell == x_cell and
prev_y_cell == y_cell and
prev_y_board == y_board and
prev_x_board == x_board):
b = HTML('<p style="color:red">2</p>')
else:
b = HTML('2')
g.setWidget(y_cell, x_cell, b)
self.add(g)
self.g.setWidget(y_board, x_board, g)
示例2: init
# 需要导入模块: from pyjamas.ui.Button import Button [as 别名]
# 或者: from pyjamas.ui.Button.Button import point [as 别名]
def init(self):
'''Initializes the grid on which the game is played.
'''
for y_board in range(3):
for x_board in range(3):
g=Grid()
g.resize(3, 3)
g.setBorderWidth(2)
g.setCellPadding(9)
g.setCellSpacing(1)
for x_cell in range(3):
for y_cell in range(3):
b = Button('Play here.', self)
b.point = {'x_cell':x_cell, 'y_cell':y_cell, 'y_board': y_board, 'x_board': x_board}
g.setWidget(y_cell, x_cell, b)
self.add(g)
self.g.setWidget(y_board, x_board, g)
示例3: state_to_grid
# 需要导入模块: from pyjamas.ui.Button import Button [as 别名]
# 或者: from pyjamas.ui.Button.Button import point [as 别名]
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}
self.g.setWidget(y, x, b)
else:
self.g.setText(y, x, '-')
elif board[y][x] == '1':
self.g.setText(y, x, '1')
elif board[y][x] == '2':
self.g.setText(y, x, '2')
else:
print 'state_to_grid exception'
示例4: init
# 需要导入模块: from pyjamas.ui.Button import Button [as 别名]
# 或者: from pyjamas.ui.Button.Button import point [as 别名]
def init(self):
for y in range(3):
for x in range(3):
b = Button('Press', self)
b.point = {'x':x, 'y':y}
self.g.setWidget(y, x, b)