Crop Text in Text or dialog controls
#1
i have a large bulk of text in a string, that i would like to display to the user in either a dialog or a text box, and the text seems to run off the side of the control and off the side of the screen, instead of sticking to the paramaters of the control. is it possible to get text within the control to stick to the controls paramaters ? or how could i edit my text so that every n'th letter has a new line, with out putting new lines in the middle of a word
Reply
#2
i had to write the logic to split up a long string of text into multiple lines based on the controls height and width and the variable width of each character. i ended up building a lookup table for font13, font14, and font16 for the character widths. the code is in the xbmc mythtv project which is still being worked on.

the problem with doing it this way is that a skin might use other fonts and then all bets are off. it would be nice if the font character widths were exposed to python through some api in the interpreter.
Reply
#3
there's a python lib called textwrap that can split strings using a defined number of characters.
i used it in my gueux infos script, so check it if you need an example on how to use it.
Reply

Logout Mark Read Team Forum Stats Members Help
Crop Text in Text or dialog controls0