MCPcopy Index your code
hub / github.com/PySimpleGUI/PySimpleGUI / _GetNumLinesNeeded

Function _GetNumLinesNeeded

PySimpleGUI/PySimpleGUI.py:18007–18017  ·  view source on GitHub ↗
(text, max_line_width)

Source from the content-addressed store, hash-verified

18005# Helper function for determining how to wrap text #
18006# ===================================================#
18007def _GetNumLinesNeeded(text, max_line_width):
18008 if max_line_width == 0:
18009 return 1
18010 lines = text.split('\n')
18011 num_lines = len(lines) # number of original lines of text
18012 max_line_len = max([len(l) for l in lines]) # longest line
18013 lines_used = []
18014 for L in lines:
18015 lines_used.append(len(L) // max_line_width + (len(L) % max_line_width > 0)) # fancy math to round up
18016 total_lines_needed = sum(lines_used)
18017 return total_lines_needed
18018
18019
18020# ============================== PROGRESS METER ========================================== #

Callers 2

popup_scrolledFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected