| Reply | « Previous Thread | Next Thread » |
|
Hi,
I'm drawing a score (text) to the canvas and I'd like to update the screen with new scores. As of now, when I draw more text, it overwrites the existing instead of removing the existing text and rewriting. Does anyone know how to clear the canvas first so as to only remove the portion of the canvas with the score? I don't want to remove what will exist on the full canvas, I only want to update the score: Code:
import appuifw
import graphics
import messaging
import e32
import positioning
import location
import sysinfo
import TopWindow, graphics
from topwindow import *
from appuifw import *
from graphics import *
class DrawScore:
def __init__(self):
self.score=0
self.fillarray={}
self.resboxoffset=2
self.canvas=appuifw.Canvas(redraw_callback=self.redraw)
self.draw=Draw(self.canvas)
appuifw.app.body=self.canvas
self.redraw()
def redraw(self):
self.draw_score()
def draw_score(self):
scoretext=u"%dlb"%self.score
self.draw.text((35,105),scoretext,(0,192,0),"title")
def clear_text(self):
scoretext=u""
score = DrawScore()
score.score = 300
score.redraw()
|
|
Join Date: Oct 2007
Posts: 2,841
Location: Deva, Romania
Offline
Forum Nokia Champion
|
|
Hi and welcome to the Forum Nokia discussion boards.
You could draw a rectangle of the same color as the canvas over that portion, and draw the new score over it. |
|
Join Date: Feb 2008
Posts: 2,542
Location: Bhavnagar, Gujarat, India
gaba88
Offline
Forum Nokia Champion
|
|
hi trdillah
welcome to the forum nokia discussion boards. I will suggest you to go through the example of "graphics primitive" in the mobile python book. I think that example will help you a lot. Enjoy Pythoning Gaba88 Gargi Das- http://gargidas.blogsot.com Forum Nokia Python Wiki Learn Python at http://mobapps.org/PyS60 |
|
This makes sense and works perfectly. Thanks!
|
|
Thanks for the reference!
|
|
Join Date: Feb 2008
Posts: 2,542
Location: Bhavnagar, Gujarat, India
gaba88
Offline
Forum Nokia Champion
|
|
you are welcome trdillah
Enjoy Pythoning Gaba88 Gargi Das- http://gargidas.blogsot.com Forum Nokia Python Wiki Learn Python at http://mobapps.org/PyS60 |
| Reply | « Previous Thread | Next Thread » |
| Thread Tools | Search this Thread |
|---|---|
| Rate This Thread | |