Join Now
Quality Rating:
  • Currently 2.5 / 5
(2.5 / 5 - 4 votes cast)
Expertise Level:
  • Currently 2.0 / 5
(2.0 / 5 - 2 votes cast)

This page was last modified 22:30, 7 July 2008.

How to create an partly transparent object,text .

From Forum Nokia Wiki


The code below will help in creating transparent objects, texts and many more things in PyS60.

import appuifw
import graphics
import e32
 
def quit():
    global running
    running = False
 
def handle_redraw(rect):
    canvas.clear(0x009900)
    canvas.polygon(((0, 0), (bw, 0), (0, bh)), outline = 0xFFFF00, fill = 0xFFFF00)
 
    textimgsize = (320, 20)
    textimg = graphics.Image.new(textimgsize, "L")
    textimg.clear(0x000000)
    colorimg = graphics.Image.new(textimgsize)
    colorimg.clear(0xFFFFFF)
 
    textmsg = u"75% transparent text"
    fontspec = (None, None, graphics.FONT_BOLD)
 
    tleft, ttop, tright, tbottom = textimg.measure_text(textmsg, fontspec)[0]
    tw = (tright - tleft)
    th = (tbottom - ttop)
 
    alpha = 0xC0C0C0  
    textimg.text((-tleft, -ttop), textmsg, alpha, fontspec)
    canvas.blit(colorimg, target = ((bw - tw) / 2, (bh - th) / 2), mask = textimg)
 
canvas = appuifw.Canvas()
appuifw.app.body = canvas
bw, bh = canvas.size
appuifw.app.exit_key_handler = quit
 
running = True
while running:
    handle_redraw(None)
    e32.ao_yield()
Related Discussions
Thread Thread Starter Forum Replies Last Post
Reg: Transparent Floating Window. gabbar007 Symbian User Interface 1 2006-07-24 06:49
Transparent PNG images in Nokia's MIDP implementations nkn_motoko Mobile Java General 2 2002-05-10 09:19
How to modify a form-field? giapage Python 12 2008-04-18 09:36
Dynamically change the color of a PNG? ericprat Mobile Java Media (Graphics & Sounds) 13 2006-04-28 19:36
how to send object across bluetooth? zichangfu Symbian Networking & Messaging 1 2005-04-08 07:39
 
Powered by MediaWiki
     
     RDF Facets:
     
     
     qfnZtopicQUqfnTopicZpythonQ
     qfnZtopicQUqfnTopicZseriesE5f60Q
     qfnZtypeQUqfnTypeZCommunityContentQ
     qfnZtypeQUqfnTypeZWebpageQ
     qfnZtypeQUqfnTypeZWikiContentQ
     qmarsZlanguageQUxhttpE3aE2fE2fswE2enokiaE2ecomE2flanguageE2d1E2fenX
     
    
            
            RDF Facets:
            
            
                        qfnZuserE5ftagQSxcX
                        qfnZuserE5ftagQSxsymbianX