def __init__(self, title, outputFile, paperSize, timestamp="", includeSplunkLogo=None, cidFontList=None): """ outputFile can either be a filename or a file-like object """ self.outputFile = outputFile self.paperSize = paperSize self.reportLabPaperSize = PAPERSIZES[ self.paperSize]['reportLabPaperSize'] self.logoTransformSize = PAPERSIZES[ self.paperSize]['logoTransformSize'] self._log("outputFile: " + str(self.outputFile)) self._log("reportLabPaperSize: " + str(self.reportLabPaperSize)) self._title = title self._timestamp = timestamp if includeSplunkLogo != None: self._includeSplunkLogo = includeSplunkLogo logger.debug("pdf-init pdfrenderer include-splunk-logo=%s" % self._includeSplunkLogo) self._fontManager = FontManager(cidFontList=cidFontList) self.TITLE_STYLE.fontSize = 14 self.TITLE_STYLE.leading = 16 self.CENTER_STYLE.alignment = reportlab.lib.enums.TA_CENTER # TODO: need a better way to determine max cell height # 225 ~= margins + footer height + a few lines for header row self.maxTableCellHeight = self.reportLabPaperSize[1] - 225 return
def main() -> None: mode = input('MODE (L, R, C): ') # Initialize a fullscreen window pygame.init() screen = pygame.display.set_mode((0, 0), pygame.FULLSCREEN) # Window title pygame.display.set_caption('ESW Digital Waste Bins') # Make a display # TODO: add more modules to the display # TODO: store in subclass? for each bin # Landfill if mode == 'L': title_fm = FontManager(['impact']) text = title_fm.create_text('LANDFILL', 100, color=WHITE) title = TitleFrame(text=text, bg=BLACK, pady=100) content = Content(display_bg_color=WHITE) Display(title, content).draw(screen) # Compost elif mode == 'C': title_fm = FontManager(['impact']) text = title_fm.create_text('COMPOST', 100, color=WHITE) title = TitleFrame(text=text, bg=GREEN, pady=100) content = Content(display_bg_color=WHITE) Display(title, content).draw(screen) # Recycle elif mode == 'R': title_fm = FontManager(['impact']) text = title_fm.create_text('RECYCLE', 100, color=WHITE) title = TitleFrame(text=text, bg=BLUE, pady=100) content = Content(display_bg_color=WHITE) Display(title, content).draw(screen) else: print('Not a valid option.') return None # Game loop clock = pygame.time.Clock() running = True prev_reading = scaleReading() # initial scale reading while running: # Handle events for event in pygame.event.get(): if event.type == pygame.QUIT: running = False break elif event.type == pygame.KEYDOWN: if event.key == pygame.K_ESCAPE: running = False break curr_reading = scaleReading() weight_diff = curr_reading-prev_reading # check if the reading has changed compared to last time if weight_diff > MIN_WEIGHT_DIFF and motionReading(): # start telling the thrower how much he she saved etc prev_reading = curr_reading elif weight_diff < MIN_WEIGHT_DIFF and motionReading(): # thank the thrower but don't display the weight prev_reading = curr_reading else: prev_reading = curr_reading # Next frame (20 fps) clock.tick(20) # Repaint screen pygame.display.flip() # Exit pygame.quit()
def __init__(self, N_labels, fontSize): self.fontSize = fontSize self.initLabels(N_labels) self.fontManager = FontManager(fontSize)