ControlImage trouble
#1
I'm just trying to get the some picture paths from a file and then display the picture.

This is what I'm doing:

arquivo = open('d:\\temp\\listagem.txt', "r")
List = arquivo.readlines()

..some..python code here...

self.addControl(xbmcgui.ControlImage(0,0,800,600, List[0]))

But I got the following error in the log:
ERROR: Texture manager unable to load file: d:\\linux\\pictures\\02052010047.jpg

If I change the controlImage line to the following, it works:

self.addControl(xbmcgui.ControlImage(0,0,800,600, 'd:\\linux\\pictures\\02052010047.jpg'))

What am I doing wrong? Any idea? Huh
Reply
#2
The former has two \\ stored in the string. The latter only has a single one, as the literal string converts \\ to \.
Always read the XBMC online-manual, FAQ and search the forum before posting.
Do not e-mail XBMC-Team members directly asking for support. Read/follow the forum rules.
For troubleshooting and bug reporting please make sure you read this first.


Image
Reply
#3
I must have forgotten to press submit...

As JMarshall said, it is due to the double backslashes '\\'

and easy solution is to uses:

Code:
.replace("\\\\", "\\")
on the string containing the path.
Reply
#4
Sorry I must be stupid because I didn't get it Tongue

This is the content of listagem.txt:

D:\\Linux\\Pictures\\02052010046.jpg
D:\\Linux\\Pictures\\02052010047.jpg
D:\\Linux\\Pictures\\02052010048.jpg
D:\\Linux\\Pictures\\02052010049.jpg
D:\\Linux\\Pictures\\02052010050.jpg
D:\\Linux\\Pictures\\02052010051.jpg
D:\\Linux\\Pictures\\02052010052.jpg


All the paths got double backslash...there isn't double \\ anywhere...
Reply
#5
Jair Wrote:Sorry I must be stupid because I didn't get it Tongue

This is the content of listagem.txt:

D:\\Linux\\Pictures\\02052010046.jpg
D:\\Linux\\Pictures\\02052010047.jpg
D:\\Linux\\Pictures\\02052010048.jpg
D:\\Linux\\Pictures\\02052010049.jpg
D:\\Linux\\Pictures\\02052010050.jpg
D:\\Linux\\Pictures\\02052010051.jpg
D:\\Linux\\Pictures\\02052010052.jpg


All the paths got double backslash...there isn't double \\ anywhere...


In Python, the '\' character represents an escape character( \t - means tab, \n - means new line, \\ - means \ ) To make proper paths, you need to change double backslashes to single, therefore you need to replace the double backslash with a single backslash. In python that means you need to replace the "\\\\" with "\\"(\\\\ - is really just \\, and \\ - is really \)

so changing your line from:

Code:
self.addControl(xbmcgui.ControlImage(0,0,800,600, List[0]))

to

Code:
self.addControl(xbmcgui.ControlImage(0,0,800,600, List[0].replace("\\\\","\\")))

As long as List[0] is a valid string.

Give it a shot, there is plenty of documentation about this.(google is you friend)
Reply

Logout Mark Read Team Forum Stats Members Help
ControlImage trouble0