Explorar o código

Update card grid to allow unit selection

Weiyi Lou %!s(int64=3) %!d(string=hai) anos
pai
achega
6f9b53f167
Modificáronse 1 ficheiros con 11 adicións e 3 borrados
  1. 11 3
      card_grid_generator/card_grid_generator_extension.py

+ 11 - 3
card_grid_generator/card_grid_generator_extension.py

@@ -104,10 +104,18 @@ class CardGridGenerator(Extension):
         docWidth = doc.width()
         docHeight = doc.height()
 
+        # Card dimensions.
+        multiplier = 1
+        docPPI = doc.resolution()
+        if self.unitInput.currentText() == "inch":
+            multiplier = docPPI
+        if self.unitInput.currentText() == "mm":
+            multiplier = docPPI/25.4
+        bleedSize = float(self.bleedInput.text()) * multiplier
+        cardWidth = float(self.widthInput.text()) * multiplier
+        cardHeight = float(self.heightInput.text()) * multiplier
+
         # Card dimensions with bleed.
-        bleedSize = int(self.bleedInput.text())
-        cardWidth = int(self.widthInput.text())
-        cardHeight = int(self.heightInput.text())
         cardBledWidth = cardWidth + bleedSize * 2
         cardBledHeight = cardHeight + bleedSize * 2