Ver Fonte

Update card grid to allow unit selection

Weiyi Lou há 3 anos atrás
pai
commit
6f9b53f167
1 ficheiros alterados com 11 adições e 3 exclusões
  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