Handling tabs in a controltextbox
#1
hello,

i am quiet new into python scripting. after reading some docs i've tried to create a script for reading a (notepad) text file containing tabs (it's a sorted list). this is a code fragment:

f = open(rootdir + "list.txt")
data = f.read()

self.test = xbmcgui.controltextbox(50, 130, 670, 400, "font12", "0xffffffff")
self.addcontrol(self.test)
self.test.settext(data)
self.setfocus(self.test)

when i start the script in xbmc i'll see the textfile in the controlbox,but all the tabs are replaced with a strange block character and the text is not lined up. am i doing something wrong? please help.

regards,

marc
Reply
#2
data = data.replace('\t', ' ')

set ' ' to the number of spaces you want
For python coding questions first see http://mirrors.xbmc.org/docs/python-docs/
Reply
#3
thanks nuka,

question is, will it also align the text. for example:

thistext      1  (two tabs)
thatistext   2  (one tab)

if you replace character $09 with spaces you will get possibly:

thistext  1
thatistext 2

í don't know why $09 will not be treaded as a real tab in a controltextbox.

regards,

marc
Reply

Logout Mark Read Team Forum Stats Members Help
Handling tabs in a controltextbox0