def parsed(self): if not self.renderer.aborted and self.renderer.lrf is not None: width, height = self.renderer.lrf.device_info.width, \ self.renderer.lrf.device_info.height hdelta = self.tool_bar.height()+3 s = QScrollBar(self) scrollbar_adjust = min(s.width(), s.height()) self.graphics_view.resize_for(width+scrollbar_adjust, height+scrollbar_adjust) screen_height = self.screen().availableSize().height() - 25 height = min(screen_height, height+hdelta+scrollbar_adjust) self.resize(width+scrollbar_adjust, height) self.setWindowTitle(self.renderer.lrf.metadata.title + ' - ' + __appname__) self.document_title = self.renderer.lrf.metadata.title if self.opts.profile: import cProfile lrf = self.renderer.lrf cProfile.runctx('self.document.render(lrf)', globals(), locals(), lrf.metadata.title+'.stats') print('Stats written to', self.renderer.lrf.metadata.title+'.stats') else: start = time.time() self.document.render(self.renderer.lrf) print('Layout time:', time.time()-start, 'seconds') self.renderer.lrf = None self.graphics_view.setScene(self.document) self.graphics_view.show() self.spin_box.setRange(1, self.document.num_of_pages) self.slider.setRange(1, self.document.num_of_pages) self.spin_box.setSuffix(' of %d'%(self.document.num_of_pages,)) self.spin_box.updateGeometry() self.stack.setCurrentIndex(0) self.graphics_view.setFocus(Qt.FocusReason.OtherFocusReason) elif self.renderer.exception is not None: exception = self.renderer.exception print('Error rendering document', file=sys.stderr) print(exception, file=sys.stderr) print(self.renderer.formatted_traceback, file=sys.stderr) msg = '<p><b>%s</b>: '%(exception.__class__.__name__,) + as_unicode(exception) + '</p>' msg += '<p>Failed to render document</p>' msg += '<p>Detailed <b>traceback</b>:<pre>' msg += self.renderer.formatted_traceback + '</pre>' d = ConversionErrorDialog(self, 'Error while rendering file', msg) d.exec()