Handling tabs in a controltextbox

  Thread Rating:
  • 0 Votes - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Post Reply
dikkesnoek Offline
Senior Member
Posts: 108
Joined: Apr 2004
Reputation: 0
Post: #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
find quote
Nuka1195 Online
Skilled Python Coder
Posts: 3,914
Joined: Dec 2004
Reputation: 17
Post: #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/
find quote
dikkesnoek Offline
Senior Member
Posts: 108
Joined: Apr 2004
Reputation: 0
Post: #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
find quote