| Reply | « Previous Thread | Next Thread » |
|
Hi,
I am trying to read in the location of an image on the memory card and display this image on the screen. There are no problems reading from the file. The image location is "e:\\python\\map.jpg". This is held in a variable called theMap. The error i am getting occurs when i do the following: Code:
im = graphics.Image.open(theMap) Code:
im = graphics.Image.open("e:\\python\\map.jpg")
|
|
I'm sorry, I don't actually understand what the problem is.
This works as it should: Code:
im = graphics.Image.open("e:\\python\\map.jpg")
Code:
theMap = u'e:\\python\\map.jpg' im = graphics.Image.open(theMap) |
|
Quote:
The image location can change depending on what map I want to display so I can't have the location "hard coded". theMap is set to "e:\\python\\map.jpg" because this is what is read from the file, but as I said before Code:
im = graphics.Image.open(theMap) |
|
Join Date: Feb 2008
Posts: 743
Location: Belo Horizonte, Brazil
Rafael T.
Offline
Forum Nokia Champion
|
|
Hi Davie1,
Are you displaying it on a canvas? If not, you should use canvas as the application body. Example: Code:
import appuifw, graphics
path = "E:\\Python\\map.jpg"
img = graphics.Image.open(path)
def handle_redraw(rect):
canvas.blit(img)
canvas = appuifw.Canvas(redraw_callback = handle_redraw)
appuifw.app.body = canvas
Hope it helps, Rafael. |
|
Quote:
Symbian OS uses a single backslash symbol (\) to separate path components. This is unfortunate, as Python uses the same symbol as an escape mechanism for string literals. This enables entering symbols that normally interfere with the syntax of string literals: quotation marks (\"), apostrophes (\') and the backslash (\\) itself, as well as character codes (\xnn and \unnnn). This has the effect that to represent a literal backslash in a Python string literal, you need to precede it with another backslash, i.e. enter the backslash twice, like in your example. Reading text from a file does not undergo this type of escape-processing. If you read Symbian OS paths from a file, the file must contain a single backslash as path separator, otherwise the OS won't find the file you're referring to. You also need to decide an encoding for your file (UTF-8 is good) and decode it to a Unicode string when reading, so that filenames with accented characters will work. |
|
Quote:
Thank you to everyone for their help. It is much appreciated ![]() |
| Reply | « Previous Thread | Next Thread » |
| Thread Tools | Search this Thread |
|---|---|
| Rate This Thread | |
| Thread | Thread Starter | Forum | Replies | Last Post |
|---|---|---|---|---|
| modifying image on display in canvas | aqibarain | Mobile Java General | 1 | 2007-11-30 10:01 |
| simple script to display rgb image | gojkoa | Python | 1 | 2005-11-21 10:33 |
| HELP: Mutable Image to Immutable Image? | rj_cybersilver | Mobile Java Media (Graphics & Sounds) | 1 | 2005-03-26 10:58 |
| how to display image? | ganesh_babu | Mobile Java Media (Graphics & Sounds) | 8 | 2004-06-22 09:02 |
| Game Developement - Display object on a image background | kenkwokkam | Mobile Java General | 0 | 2003-02-08 15:58 |