| Reply | « Previous Thread | Next Thread » |
|
In my program i am loading an image on the screen using canvas.blit(image) where image is already opened. The image gets displayed correctly the first time but when running the program if options menu is opened or a note is displayed then the image is erased.
How can I refresh the image in such events? Also I would like to change the image when one of the options menu is selected. How can I achieve this? I tried using image.load(). But it did'nt work. |
| nitroxxx123 |
| View Public Profile |
| Find all posts by nitroxxx123 |
|
Join Date: Oct 2007
Posts: 2,841
Location: Deva, Romania
Offline
Forum Nokia Champion
|
||
|
Quote:
Quote:
Code:
def handle_redraw(rect):
canvas.blit(image)
canvas = appuifw.Canvas(redraw_callback=handle_redraw)
Well you can clear the canvas using canvas.clear() and then blit the new image. Or just blit the new image without clearing the canvas it covers the old one. |
|
Thanks It worked
|
| nitroxxx123 |
| View Public Profile |
| Find all posts by nitroxxx123 |
|
I'm having a problem also with the canvas.
In my application, I have a presentation at the begining in full screen mode, using Canvas. After that, I have two tabs, one of them with a list, and the second one with an image, using a new canvas2, and a new image2. I don't know why, but after drawing the proper canvas in the tab, is covered by a white canvas. I know that's not that easy to solve without the code posted, but does anyone have an idea why can that be? Here some lines: def print_feedback(self): global img2, canvas2 self.setRow(20) img2=Image.new((screenSize[0],screenSize[1])) img2.clear((0,0,0)) self.setRow(40) img2=self.prepare_text(img2, self.tab_prev_message) # define your redraw function (still belonging to app 3) def handle_redraw(rect): global img2, canvas2 canvas2.blit(img2) # define the canvas, include the redraw callback function canvas2 =appuifw.Canvas(event_callback=None, redraw_callback=handle_redraw) appuifw.app.body = canvas2 e32.ao_sleep(2) def exit_handler2(): global app_lock2 app_lock2.signal() print_activity_description = appuifw.Listbox([u"Stefan", u"Holger", u"Emil", u"Ludger"], exit_handler2) def handle_tab(self, index): if index == 0: appuifw.app.body = self.print_feedback() if index == 1: appuifw.app.body = self.print_description def createTabs(self, titles,tabs_menu): global app_lock2 appuifw.app.screen='normal' appuifw.app.set_tabs(titles,self.handle_tab) appuifw.app.body = self.print_feedback() app_lock2.wait() audio.say('exiting createTabs') By using the e32.ao_sleep(2) in print_feedback, I saw that my image was printed, but overlaped after 2 seconds with the white one. I know that the application has not left the tab section, as the audios are not played. And, my previous images were not white, so I don't know where this white canvas covering my feedback is coming from. Any clues? I have tryied a lot of things, so any comment will be more than welcome. |
|
Join Date: Feb 2008
Posts: 2,542
Location: Bhavnagar, Gujarat, India
gaba88
Offline
Forum Nokia Champion
|
|
hello didacgil99
it will be great if you edit your post and provide code tags in your post so that you can always get a good help. ![]() Enjoy Pythoning Gaba88 Gargi Das- http://gargidas.blogsot.com Forum Nokia Python Wiki Learn Python at http://mobapps.org/PyS60 |
|
I'm having a problem also with the canvas.
In my application, I have a presentation at the begining in full screen mode, using Canvas. After that, I have two tabs, one of them with a list, and the second one with an image, using a new canvas2, and a new image2. I don't know why, but after drawing the proper canvas in the tab, is covered by a white canvas. I know that's not that easy to solve without the code posted, but does anyone have an idea why can that be? Here some lines: Code:
class GUI:
def __init__(self):
global app_lock2
self.wall=Image.open('e:\\GeM\\images\\wall.jpg')
self.tab_prev_message = u''
self.tab_description = u''
app_lock2 = e32.Ao_lock()
#this function gets an string, and prepares an image cutting the string in pieces to fit on the screen
def prepare_text(self, img, text, col=10, chars=40, colour=(255,255,255), space=20):
while len(text) > chars:
#I look for the furthest space in the first 40 characters
position2 = 0
position = 0
while (position2 < chars):
if position2 == -1:
break
position = position2
position2 = text.find(' ',position+1)
img.text((col,self.row), u"%s" %text[0:position],colour)
self.row += space
#I update the text to print with the rest of the string. We skip the space " " (position+1)
text = text[position+1:len(text)]
if len(text) > 0: #the last line needs to be printed directly
img.text((col,self.row), u"%s" %text,colour)
self.row += space
#The text has been splitet already
return img
def print_feedback(self):
global img2, canvas2
self.setRow(20)
img2=Image.new((screenSize[0],screenSize[1]))
img2.clear((0,0,0))
self.setRow(40)
img2=self.prepare_text(img2, self.tab_prev_message)
# define your redraw function (still belonging to app 3)
def handle_redraw(rect):
global img2, canvas2
canvas2.blit(img2)
# define the canvas, include the redraw callback function
canvas2 =appuifw.Canvas(event_callback=None, redraw_callback=handle_redraw)
appuifw.app.body = canvas2
e32.ao_sleep(2)
def exit_handler2():
global app_lock2
app_lock2.signal()
print_activity_description = appuifw.Listbox([u"Stefan", u"Holger", u"Emil", u"Ludger"], exit_handler2)
def handle_tab(self, index):
if index == 0:
appuifw.app.body = self.print_feedback()
if index == 1:
appuifw.app.body = self.print_description
def createTabs(self, titles,tabs_menu):
global app_lock2
appuifw.app.screen='normal'
appuifw.app.set_tabs(titles,self.handle_tab)
appuifw.app.body = self.print_feedback()
app_lock2.wait()
audio.say('exiting createTabs')
And, somewhere in the application I have: Code:
gui = GUI()
gui.presentation() #even the code is now show, it uses a global Canvas "canvas" and a global Image "img"
# and does a full screen presentation
[...]
gui.createTabs([u"Feedback", u"Description"], gui.handle_tab)
By using the e32.ao_sleep(2) in print_feedback, I saw that my image was printed, but overlaped after 2 seconds with the white one. I know that the application has not left the tab section, as the audios are not played. And, my previous images were not white, so I don't know where this white canvas covering my feedback is coming from. Any clues? I have tryied a lot of things, so any comment will be more than welcome.
Last edited by didacgil9 : 2009-04-27 at 14:46.
|
|
Review your handle_redraw() function. Most likely it's not supporting your tabs views.
Cheers, --jouni |
|
Quote:
Should does someone have an example of tab creation with canvas, having canvas previously printed on the screen before? I need to say that I have not declared any other event_handler in any other section, that could be also called when I change the tab in focus. I'm still looking for a reasonable answer to my question. I don't really understand why that happens, but I'm quite new to Python. |
|
Well, if you're really sure that handle_redraw is correct, then I propose tracing your app. Then you know for sure where and why the "false" redraw happens. No need to read code, just read log file
![]() Debug tips here: http://wiki.forum.nokia.com/index.ph...ing_techniques Btw your code is pretty cryptic. I'm guessing you copy & pasted some lines? Would have been most helpful to see where the breaks are, but it's your question. General suggestion: use only one canvas. Also cannot imagine what this line is supposed to do "appuifw.app.body = self.print_feedback()", when that func doesn't return anything at all. Guess: print_feedback creates new canvas, populates and activates it, but at return (after 2 sec timer) the body is reset with empty value, which gets redrawn as empty screen. Cheers, --jouni |
|
Quote:
Quote:
Code:
img2=self.prepare_text(img2, self.tab_prev_message) Quote:
I will check that appuifw.app.body should get (img, canvas, etc) and I will prepare the return in that sense. Thank you very much for your answers. I really appreciate them |
| Reply | « Previous Thread | Next Thread » |
| Thread Tools | Search this Thread |
|---|---|
| Rate This Thread | |
| Thread | Thread Starter | Forum | Replies | Last Post |
|---|---|---|---|---|
| How to display jpeg image on separate window | amol_benare604 | General Symbian C++ | 2 | 2009-03-21 12:00 |
| Image display which is converted | kalgi | General Symbian C++ | 4 | 2009-02-09 06:45 |
| Re: Image display and select | zed1 | Mobile Java Media (Graphics & Sounds) | 1 | 2007-01-05 17:04 |
| Display, modify and save image | mazi888 | Symbian Media (Graphics & Sounds) | 1 | 2006-03-13 21:14 |