def initialize(self, choices=None): from calibre.utils.icu import numeric_sort_key if self.system_default_paper_size is None: PaperSizes.system_default_paper_size = 'a4' if iswindows or ismacos: # On Linux, this can cause Qt to load the system cups plugin # which can crash: https://bugs.launchpad.net/calibre/+bug/1861741 PaperSizes.system_default_paper_size = 'letter' if QPrinter().pageSize() == QPagedPaintDevice.Letter else 'a4' if not choices: from calibre.ebooks.conversion.plugins.pdf_output import PAPER_SIZES choices = PAPER_SIZES for a in sorted(choices, key=numeric_sort_key): s = getattr(QPageSize, a.capitalize()) sz = QPageSize.definitionSize(s) unit = {QPageSize.Millimeter: 'mm', QPageSize.Inch: 'inch'}[QPageSize.definitionUnits(s)] name = '{} ({:g} x {:g} {})'.format(QPageSize.name(s), sz.width(), sz.height(), unit) self.addItem(name, a)
def initialize(self, choices=None): from calibre.utils.icu import numeric_sort_key if self.system_default_paper_size is None: QComboBox.system_default_paper_size = 'letter' if QPrinter( ).pageSize() == QPagedPaintDevice.Letter else 'a4' if not choices: from calibre.ebooks.conversion.plugins.pdf_output import PAPER_SIZES choices = PAPER_SIZES for a in sorted(choices, key=numeric_sort_key): s = getattr(QPageSize, a.capitalize()) sz = QPageSize.definitionSize(s) unit = { QPageSize.Millimeter: 'mm', QPageSize.Inch: 'inch' }[QPageSize.definitionUnits(s)] name = '{} ({:g} x {:g} {})'.format(QPageSize.name(s), sz.width(), sz.height(), unit) self.addItem(name, a)