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


Python Helpers.paint_grid_button方法代码示例

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


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

示例1: _populate_grid_at_position

# 需要导入模块: from helpers import Helpers [as 别名]
# 或者: from helpers.Helpers import paint_grid_button [as 别名]
    def _populate_grid_at_position(self,
                                   grid_position,
                                   mapper,
                                   layout,
                                   coordinate_pair):
        # creates a button and positions it on the grid

        x, y = coordinate_pair[0], coordinate_pair[1]
        textual_coordinates = "{0}-{1}".format(x, y)
        button = QCustomPushButton(
            self,
            grid_position,
            Coordinates.parse_coordinates(textual_coordinates,
                                          self._grid_size)
        )

        Helpers.paint_grid_button(button, style.FIELD_BLUE)
        button.setObjectName("GridButton")
        button.setFixedSize(style.FIELD_ICON_SIZE + 10,
                            style.FIELD_ICON_SIZE + 10)
        button.setIconSize(QSize(style.FIELD_ICON_SIZE, style.FIELD_ICON_SIZE))

        # set the QSignalMapper's mapping to work with strings
        mapper.setMapping(button, textual_coordinates)
        # connecting the button's clicked signal to the QSignalMappers
        # mapped slot
        button.clicked.connect(mapper.map)
        # finally, add the button to the QGridLayout
        layout.addWidget(button, x, y)
开发者ID:Venom1991,项目名称:RagingSeas,代码行数:31,代码来源:raging_seas_window.py

示例2: _mark_buttons

# 需要导入模块: from helpers import Helpers [as 别名]
# 或者: from helpers.Helpers import paint_grid_button [as 别名]
    def _mark_buttons(self, field_color):
        # marks the buttons with regards to the current chosen orientation

        x, y = self._coordinates.x, self._coordinates.y
        ship_dimensions = self._ship.ship_type.value
        left_grid = self._parent.ui.gridLayoutLeft

        if self._ship_orientation == ShipOrientation.horizontal:
            for i in xrange(y, (ship_dimensions + y)):
                target_button = self._parent.resolve_grid_button(
                    left_grid,
                    Coordinates(x, i)
                )
                Helpers.paint_grid_button(target_button, field_color)
        elif self._ship_orientation == ShipOrientation.vertical:

            for i in xrange(x, (ship_dimensions + x)):
                target_button = self._parent.resolve_grid_button(
                    left_grid,
                    Coordinates(i, y)
                )
                Helpers.paint_grid_button(target_button, field_color)
开发者ID:Venom1991,项目名称:RagingSeas,代码行数:24,代码来源:q_custom_push_button.py

示例3: _paint_player_grid

# 需要导入模块: from helpers import Helpers [as 别名]
# 或者: from helpers.Helpers import paint_grid_button [as 别名]
    def _paint_player_grid(self, grid_layout, player, reveal=False):
        # marks the grid's squares according to their state

        grid = player.grid
        dimensions = grid.grid_size.value

        if player.player_type == PlayerType.human:
            reveal = True

        for i in xrange(0, dimensions):
            for j in xrange(0, dimensions):
                current_square = grid.squares.item((i, j))
                owner = current_square.owner
                square_state = current_square.square_state
                button = self.resolve_grid_button(grid_layout,
                                                  Coordinates(i, j))

                if (
                    square_state == SquareState.vacant or
                    square_state == SquareState.unoccupiable
                ):
                    Helpers.paint_grid_button(button, style.FIELD_BLUE)
                elif square_state == SquareState.populated:
                    if reveal:
                        Helpers.paint_grid_button(button, style.FIELD_GRAY)
                    else:
                        Helpers.paint_grid_button(button, style.FIELD_BLUE)
                elif square_state == SquareState.hit:
                    if owner is not None:
                        if owner.ship_state == ShipState.damaged:
                            Helpers.paint_grid_button(button, style.FIELD_RED)
                        elif owner.ship_state == ShipState.sunk:
                            Helpers.paint_grid_button(button,
                                                      style.FIELD_BLACK)
                    else:
                        Helpers.paint_grid_button(button,
                                                  style.FIELD_LIGHT_BLUE)
开发者ID:Venom1991,项目名称:RagingSeas,代码行数:39,代码来源:raging_seas_window.py


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