libtcod / python-tcod

A high-performance Python port of libtcod. Includes the libtcodpy module for backwards compatibility with older projects.
BSD 2-Clause "Simplified" License
410 stars 36 forks source link

Using get_height_rect without an existing console #67

Closed FractalWire closed 5 years ago

FractalWire commented 5 years ago

So, I'm having a case where I'd like to use get_height_rect without an existing console, or at least, with a console of (width=0, height=0). This console is basically use to hold the content of a print_box function, and that's it. This is a console dedicated to the content of a tooltip with variable value.

But if I want to use print_box, I'd need to know and set the height of the console before using the print_box function. Get_height_rect would be perfect here but if we use it on a Console(0,0), the only value we'd get is 0.

Any Idea how I could work around that ? I could implement my own print_box function in python, but it would not be as efficient as print_box I guess.

HexDecimal commented 5 years ago

I'll go ahead and write a function which doesn't require a console.

Python's textwrap module could be used to replace libtcod's text wrapper if you ever needed to.