From 3d77ab264b3ba548248db0ba65f262f214be6d87 Mon Sep 17 00:00:00 2001 From: Kjell Wooding Date: Sat, 4 Jun 2016 14:55:11 -0700 Subject: [PATCH 1/2] first try at fixing the aspect ratio --- main.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/main.py b/main.py index 99585fa..ab6737b 100644 --- a/main.py +++ b/main.py @@ -51,6 +51,9 @@ class HexMapCell(label.Label): def __init__(self, row=0, col=0, **kwargs): self.region_in_map = MapCoords(row, col) super(HexMapCell, self).__init__(**kwargs) + self.size_hint = (1,None) + self.height = self.width / math.sqrt(3) + class BU(HexMapCell): pass From cc1604fe36687c46c84e28e9ed804f5c18f3647d Mon Sep 17 00:00:00 2001 From: Kjell Wooding Date: Sat, 4 Jun 2016 15:08:18 -0700 Subject: [PATCH 2/2] fix aspect ratio of hex grid --- Making a Wargame.ipynb | 9 +++++++++ main.py | 4 +--- strategygame.kv | 9 +++++++-- 3 files changed, 17 insertions(+), 5 deletions(-) diff --git a/Making a Wargame.ipynb b/Making a Wargame.ipynb index 22a7359..849d20e 100644 --- a/Making a Wargame.ipynb +++ b/Making a Wargame.ipynb @@ -565,6 +565,15 @@ " size_hint: 1, .33\n" ] }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], + "source": [] + }, { "cell_type": "code", "execution_count": null, diff --git a/main.py b/main.py index ab6737b..31d0ac5 100644 --- a/main.py +++ b/main.py @@ -48,12 +48,10 @@ class StrategyGame(FloatLayout): class HexMapCell(label.Label): + def __init__(self, row=0, col=0, **kwargs): self.region_in_map = MapCoords(row, col) super(HexMapCell, self).__init__(**kwargs) - self.size_hint = (1,None) - self.height = self.width / math.sqrt(3) - class BU(HexMapCell): pass diff --git a/strategygame.kv b/strategygame.kv index 728eebc..e7b7481 100644 --- a/strategygame.kv +++ b/strategygame.kv @@ -1,10 +1,10 @@ - +#:import math math #:include debug.kv : id: _game main_map: _main_map - map_rows: 10 + map_rows: 30 map_cols: 10 BoxLayout: orientation: 'horizontal' @@ -23,6 +23,7 @@ text: 'mini-map' size_hint: 1, .33 + : canvas: Color: @@ -51,3 +52,7 @@ Line: points: (self.right, self.y, self.right, self.top) width: 2 + +: + size_hint: 1, None + height: self.width / math.sqrt(3)