Skip to content

Commit b0e5f1c

Browse files
committed
ENH: Fixed aspect ratio
1 parent ced9054 commit b0e5f1c

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

pelita/ui/qt/qt_viewer.py

+16-2
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
QSocketNotifier, pyqtSignal, pyqtSlot)
1111
from PyQt6.QtGui import QKeySequence, QShortcut
1212
from PyQt6.QtWidgets import (QApplication, QGraphicsView, QGridLayout,
13-
QHBoxLayout, QMainWindow, QPushButton, QWidget)
13+
QHBoxLayout, QVBoxLayout, QMainWindow, QPushButton, QWidget)
1414

1515
from .qt_items import EndTextOverlay
1616
from .qt_scene import PelitaScene, blue_col, red_col
@@ -175,6 +175,11 @@ def setupUi(self):
175175
self.view = GameView(self.scene)
176176
self.view.setCacheMode(QGraphicsView.CacheModeFlag.CacheBackground)
177177

178+
game_layout_w = QWidget(self)
179+
game_layout = QVBoxLayout(game_layout_w)
180+
game_layout.addWidget(self.view)
181+
game_layout.addStretch()
182+
178183
bottom_info = QWidget(self)
179184
bottom_info_layout = QHBoxLayout(bottom_info)
180185

@@ -189,7 +194,7 @@ def setupUi(self):
189194
grid_layout.addWidget(self.stats_blue, 1, 0)
190195
grid_layout.addWidget(self.stats_red, 1, 1)
191196

192-
grid_layout.addWidget(self.view, 2, 0, 1, 2)
197+
grid_layout.addWidget(game_layout_w, 2, 0, 1, 2)
193198
grid_layout.addWidget(bottom_info, 3, 0, 1, 2)
194199
grid_layout.addWidget(self.button, 4, 0, 1, 2)
195200

@@ -340,6 +345,15 @@ class GameView(QGraphicsView):
340345
def __init__(self, scene, parent=None):
341346
super().__init__(scene, parent)
342347

348+
def minimumHeight(self) -> int:
349+
return super().minimumHeight()
350+
351+
def hasHeightForWidth(self) -> bool:
352+
return True
353+
354+
def heightForWidth(self, a0: int) -> int:
355+
return a0 // 2
356+
343357
def resizeEvent(self, event) -> None:
344358
if self.scene().shape:
345359
x, y = self.scene().shape

0 commit comments

Comments
 (0)