You Are Here:

Community: Developer Discussion Boards

#1 Old Drawing and Clearing text - 2008-08-18, 21:49

Join Date: Jun 2008
Posts: 8
trdillah
Offline
Registered User
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()
Reply With Quote

#2 Old Re: Drawing and Clearing text - 2008-08-18, 21:56

Join Date: Oct 2007
Posts: 2,841
Location: Deva, Romania
bogdan.galiceanu's Avatar
bogdan.galiceanu
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.
Reply With Quote

#3 Old Re: Drawing and Clearing text - 2008-08-19, 06:51

Join Date: Feb 2008
Posts: 2,542
Location: Bhavnagar, Gujarat, India
Send a message via Yahoo to gaba88 Send a message via Skype™ to gaba88
gaba88's Avatar
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
Reply With Quote

#4 Old Re: Drawing and Clearing text - 2008-08-19, 15:53

Join Date: Jun 2008
Posts: 8
trdillah
Offline
Registered User
This makes sense and works perfectly. Thanks!
Reply With Quote

#5 Old Re: Drawing and Clearing text - 2008-08-19, 15:54

Join Date: Jun 2008
Posts: 8
trdillah
Offline
Registered User
Thanks for the reference!
Reply With Quote

#6 Old Re: Drawing and Clearing text - 2008-08-19, 15:55

Join Date: Feb 2008
Posts: 2,542
Location: Bhavnagar, Gujarat, India
Send a message via Yahoo to gaba88 Send a message via Skype™ to gaba88
gaba88's Avatar
gaba88
Offline
Forum Nokia Champion
Quote:
Originally Posted by trdillah View Post
Thanks for the reference!
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 With Quote
Reply « Previous Thread | Next Thread »
Display Modes
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

Posting Rules

You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump

Rate This

 
Bookmark this page: DeliciousDiggFacebookGoogleYahooStumbleUponRedditDiigoTechnocratiTwitter  Share this page Share this page Print this Page Print this page Invite a friend Invite a friend
京ICP备05048969号    Email Newsletters Press Terms & Conditions Privacy Policy Sitemap Contact Us © 2009 Nokia