finding Text Length in pixels
#1
Hii

I'm pretty new to python and i'm having trouble finding the length of a text string in pixels. Now i know i can get the length in characters by using the len() function but because the text is proportional i cant just multiply this by a fixed number to get how many pixels wide the whole string will take up.

I'm writing a script to emulate (to a degree) a menu system like windows within XBMC.
I need this so i can position the menu headings across the top of the screen without gaps between headings and to position the menu items directly below each heading.
The menu headings will be different lengths and to set the width of each heading control i need to know exactly how wide the text will be.

I will eventually upload this script as i think it'll be useful for other script writers. It will be rather generic and very simply to implement any sort of menu thats required.

Hope someone can help with this little problem


Dire.











\
Reply
#2
You could center the menu headers and use lists which would limit the text shown but it would also scroll the full text when selected.

example for header would be:

self.header = xbmcgui.ControlLabel(xpos, ypos, xlength, ylength, 'Header', 'font13', '0xFFFFFFFF', '', 0x00000002)
Reply

Logout Mark Read Team Forum Stats Members Help
finding Text Length in pixels0