本文整理汇总了Python中PyQt5.QtWidgets.QVBoxLayout.setGeometry方法的典型用法代码示例。如果您正苦于以下问题:Python QVBoxLayout.setGeometry方法的具体用法?Python QVBoxLayout.setGeometry怎么用?Python QVBoxLayout.setGeometry使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt5.QtWidgets.QVBoxLayout
的用法示例。
在下文中一共展示了QVBoxLayout.setGeometry方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Table
# 需要导入模块: from PyQt5.QtWidgets import QVBoxLayout [as 别名]
# 或者: from PyQt5.QtWidgets.QVBoxLayout import setGeometry [as 别名]
class Table(QMainWindow):
def __init__(self, player_index):
super().__init__()
self.initUI(0, player_index)
def initUI(self, p, player_index):
self.answer = None
self.moves_made = 0
self.boxes = []
self.checkboxes = []
self.presses = 0
self.last_throws = (0, 0)
self.figures = []
self.player_color = QColor(255, 255, 0)
self.player_starting_pos = player_index * 14
self.current_move = 0
self.player_cnt = 0
self.command_widget = QVBoxLayout()
self.roll_dice_button = QPushButton('Roll dice', self)
self.roll_dice_button.clicked.connect(self._roll_dice)
self.command_widget.addWidget(self.roll_dice_button)
self.command_widget.setGeometry(QRect(650, 300, 200, 100))
# outer parts
for i in range(0, 7):
self.__build_square(self.boxes, i, 335, 545 -
(i % 15) * 35, QColor(255, 255, 255))
for i in range(7, 13):
self.__build_square(self.boxes, i, 370 + (i - 7)
* 35, 335, QColor(255, 255, 255))
self.__build_square(self.boxes, 13, 545, 300, QColor(255, 255, 255))
for i in range(14, 20):
self.__build_square(self.boxes, i, 265 + (22 - i)
* 35, 265, QColor(255, 255, 255))
for i in range(20, 27):
self.__build_square(self.boxes, i, 335, 265 -
(i - 20) * 35, QColor(255, 255, 255))
self.__build_square(self.boxes, 27, 300, 55, QColor(255, 255, 255))
for i in range(28, 35):
self.__build_square(self.boxes, i, 265, 55 +
(i - 28) * 35, QColor(255, 255, 255))
for i in range(35, 41):
self.__build_square(self.boxes, i, 230 - (i - 35)
* 35, 265, QColor(255, 255, 255))
self.__build_square(self.boxes, 41, 55, 300, QColor(255, 255, 255))
for i in range(42, 49):
self.__build_square(self.boxes, i, 55 + (i - 42)
* 35, 335, QColor(255, 255, 255))
for i in range(49, 55):
self.__build_square(self.boxes, i, 265, 370 +
(i - 49) * 35, QColor(255, 255, 255))
self.__build_square(self.boxes, 55, 300, 545, QColor(255, 255, 255))
# inner parts
for i in range(56, 62):
self.__build_square(self.boxes, i, 300, 510 -
(i - 56) * 35, QColor(200, 0, 0))
for i in range(62, 68):
self.__build_square(self.boxes, i, 510 - (i - 62)
* 35, 300, QColor(0, 0, 200))
for i in range(68, 74):
self.__build_square(self.boxes, i, 300, 90 +
(i - 68) * 35, QColor(200, 0, 200))
for i in range(74, 80):
self.__build_square(self.boxes, i, 90 + (i - 74)
* 35, 300, QColor(p, 200, 200))
self.setGeometry(600, 900, 900, 600)
self.show()
# Table builder function
def __add_checkbox(self, index):
box = QVBoxLayout()
checkbox = QCheckBox(str(index), self)
self.checkboxes.append(checkbox)
checkbox.stateChanged.connect(self.signal_for_figure)
checkbox.setCheckable(False)
box.addWidget(checkbox)
self.boxes[index].setLayout(box)
def __build_square(self, boxes, i, horiz, vert, color):
self.boxes.append(QFrame(self))
self.boxes[i].setGeometry(horiz, vert, 30, 30)
self.boxes[i].setStyleSheet(
"QWidget {background-color: %s }" %
color.name())
# Figure behaviour functions
def draw_figure(self, figure_pos, player_color, counter):
self.boxes[figure_pos].setStyleSheet(
"QWidget {background-color: %s }" %
QColor(
player_color[0],
player_color[1],
#.........这里部分代码省略.........