Give up on Understanding layouts????
parent
dea4168dce
commit
822d47f684
|
@ -87,15 +87,14 @@ class MenuBoard(BoxBoard):
|
||||||
super().__init__(width, height, parent)
|
super().__init__(width, height, parent)
|
||||||
|
|
||||||
self.layout = QGraphicsLinearLayout(Qt.Horizontal)
|
self.layout = QGraphicsLinearLayout(Qt.Horizontal)
|
||||||
self.layout.setMaximumWidth(width)
|
self.layout.setMinimumWidth(width)
|
||||||
self.layout.setMaximumHeight(height)
|
self.layout.setMinimumWidth(height)
|
||||||
|
|
||||||
|
self.diff_display = menu_grap.DifficultyDisplayer(parent=self)
|
||||||
|
self.layout.addItem(self.diff_display)
|
||||||
self.timer_display = menu_grap.TimerDisplayer(parent=self)
|
self.timer_display = menu_grap.TimerDisplayer(parent=self)
|
||||||
self.timer_display2 = menu_grap.TimerDisplayer(parent=self)
|
|
||||||
self.timer_display3 = menu_grap.TimerDisplayer(parent=self)
|
|
||||||
self.layout.addItem(self.timer_display)
|
self.layout.addItem(self.timer_display)
|
||||||
self.layout.addItem(self.timer_display2)
|
self.layout.setItemSpacing(0, 50)
|
||||||
self.layout.addItem(self.timer_display3)
|
self.layout.setItemSpacing(1, 0)
|
||||||
self.layout.setSpacing(0)
|
|
||||||
|
|
||||||
self.setLayout(self.layout)
|
self.setLayout(self.layout)
|
||||||
|
|
|
@ -35,3 +35,32 @@ class TimerDisplayer(QGraphicsWidget):
|
||||||
painter.drawRect(box)
|
painter.drawRect(box)
|
||||||
painter.drawText(box, Qt.AlignCenter, "00:00")
|
painter.drawText(box, Qt.AlignCenter, "00:00")
|
||||||
|
|
||||||
|
class DifficultyDisplayer(QGraphicsWidget):
|
||||||
|
|
||||||
|
def __init__(self, parent=None):
|
||||||
|
super().__init__(parent)
|
||||||
|
|
||||||
|
self.width = 100
|
||||||
|
self.height = 50
|
||||||
|
|
||||||
|
self.box_pen = QPen()
|
||||||
|
self.box_pen.setColor(Qt.white)
|
||||||
|
self.pen_width = 3
|
||||||
|
self.box_pen.setWidth(self.pen_width)
|
||||||
|
|
||||||
|
|
||||||
|
self.timer_box = QRectF(0, 0, self.width, self.height)
|
||||||
|
self.setMinimumSize(QSizeF(self.width, self.height))
|
||||||
|
self.setMaximumSize(QSizeF(self.width, self.height))
|
||||||
|
|
||||||
|
self.size_policy = QSizePolicy(QSizePolicy.Minimum, QSizePolicy.Minimum)
|
||||||
|
self.size_policy.setHeightForWidth(True)
|
||||||
|
self.setSizePolicy(self.size_policy)
|
||||||
|
|
||||||
|
def paint(self, painter, style, widget=None):
|
||||||
|
box = self.timer_box
|
||||||
|
#print(self.size().width())
|
||||||
|
painter.setPen(self.box_pen)
|
||||||
|
painter.drawRect(box)
|
||||||
|
painter.drawText(box, Qt.AlignCenter, "Normal")
|
||||||
|
|
||||||
|
|
2
main.py
2
main.py
|
@ -16,7 +16,7 @@ class SudokuWindow(QGraphicsView):
|
||||||
super().__init__()
|
super().__init__()
|
||||||
|
|
||||||
# Set up the Scene to manage the GraphicItems
|
# Set up the Scene to manage the GraphicItems
|
||||||
self.scene = QGraphicsScene(0, 0, 420, 500, self)
|
self.scene = QGraphicsScene(0, 0, 420, 510, self)
|
||||||
|
|
||||||
self.setScene(self.scene)
|
self.setScene(self.scene)
|
||||||
self.setSceneRect(self.scene.sceneRect())
|
self.setSceneRect(self.scene.sceneRect())
|
||||||
|
|
Loading…
Reference in New Issue