Book Spine Calculator

From Scribus Wiki
Revision as of 10:33, 1 October 2010 by Owencook (talk | contribs)
Jump to navigation Jump to search

#/usr/bin/env python
# -*- coding: utf-8 -*-

import scribus
import math  


from scribus import UNIT_POINTS,BUTTON_OK,ICON_WARNING
startMsg1 = "The conventional design suggests that spine width is calculated as follows: \n\n"
startMsg2 = "10 divided by 176, multiplied by the number of pages of text within the book, divided by 90, "
startMsg3 = "multiplied by the weight of the paper in gsm, add 1mm for the crease in the cover and this will give you a soft cover book thickness in millimetres.\n\n"
startMsg4 = "Add 3mm to this figure and you have the spine thickness of a hard covered book"
startMsg = startMsg1 + startMsg2 + startMsg3 + startMsg4


start = scribus.messageBox('Book Spine Width Calculator', startMsg, ICON_WARNING, BUTTON_OK)


P = scribus.valueDialog('Spine Calculator','Enter Number of pages')
P = float(P)
G = scribus.valueDialog('Spine Calculator','Enter Paper Weight (gsm)')
G = float(G)

# Need some sanity checks here, max and min values P and G

A = float(10)
B = float(176)

bsw = (A/B) * (P/90) * G + 1 + 3
bsw = float("%2.2f" % (bsw))
bsws = bsw - 3
P = int(P)
G = int(G)

widthMsg1 = "The spine thickness for a soft cover book of " + str(P) + " pages of " + str(G) + " gsm paper is " + str(bsws) + " mm.\n\n"
widthMsg2 = "The spine thickness for a hard cover book of " + str(P) + " pages of " + str(G) + " gsm paper is " + str(bsw) + " mm."
widthMsg = widthMsg1 + widthMsg2


end = scribus.messageBox('Book Spine Width', widthMsg, ICON_WARNING, BUTTON_OK)