Get the height of a string if using the supplied font in pixels. Cannot be used until a window has been created. If an error occurs, 0 will be returned :param font: specifies the font family, size, etc. Tuple or Single string format 'name size styles'. Styles: itali
(cls, font)
| 4297 | |
| 4298 | @classmethod |
| 4299 | def char_height_in_pixels(cls, font): |
| 4300 | """ |
| 4301 | Get the height of a string if using the supplied font in pixels. |
| 4302 | Cannot be used until a window has been created. |
| 4303 | If an error occurs, 0 will be returned |
| 4304 | :param font: specifies the font family, size, etc. Tuple or Single string format 'name size styles'. Styles: italic * roman bold normal underline overstrike, to be measured |
| 4305 | :type font: (str or (str, int[, str]) or None) |
| 4306 | :return: Height in pixels of "A" |
| 4307 | :rtype: (int) |
| 4308 | """ |
| 4309 | |
| 4310 | # A window must exist before can perform this operation. Create the hidden master root if it doesn't exist |
| 4311 | _get_hidden_master_root() |
| 4312 | |
| 4313 | size = 0 |
| 4314 | try: |
| 4315 | size = tkinter.font.Font(font=font).metrics('linespace') |
| 4316 | except Exception as e: |
| 4317 | _error_popup_with_traceback('Exception retrieving char height in pixels', e) |
| 4318 | |
| 4319 | return size |
| 4320 | |
| 4321 | @classmethod |
| 4322 | def string_width_in_pixels(cls, font, string): |
nothing calls this directly
no test coverage detected