| Reply | « Previous Thread | Next Thread » |
|
Hi All,
word = "Nokia" How do i print a word on canvas in center align ? i do not want to fixed coordinate on the canvas because the a word is changing dynamically so the word size would be increase like (word = "Computer"). Please help me is there any solution for this issue. Pavan Pareta http://www.croozeus.com/started.htm |
| pavan.pareta |
| View Public Profile |
| Find all posts by pavan.pareta |
|
Join Date: Oct 2007
Posts: 2,841
Location: Deva, Romania
Online
Forum Nokia Champion
|
|
|
Hi,
Check out the graphics section from the PyS60 Library Reference. It has a paragraph about the measure_text method: Quote:
|
|
This will help you:
Code:
size = img.measure_text(string, (None, None, FONT_BOLD)) img.text(((screen_width-size[1])/2, vertical_position), string, 0xffffff, (None, None, FONT_BOLD)) |
|
Join Date: Feb 2008
Posts: 743
Location: Belo Horizonte, Brazil
Rafael T.
Offline
Forum Nokia Champion
|
|
|
Quote:
Code:
import graphics
import sysinfo
x, y = sysinfo.display_pixels() #gets width and height of the screen
img = graphics.Image.new((x,y))
text = "Welcome!"
((x1, y1, x2, y2), dummy, dummy) = \
img.measure_text(text, font='title')
img.text((x/2-x2/2, y+y1), text, (255, 0, 0), 'title')
![]() Hope it helps, Rafael.
Last edited by Rafael T. : 2009-03-07 at 04:45.
|
|
Hi All,
Really very good solution. Thanks for help me. Pavan Pareta http://www.croozeus.com/started.htm |
| pavan.pareta |
| View Public Profile |
| Find all posts by pavan.pareta |
| Reply | « Previous Thread | Next Thread » |
| Thread Tools | Search this Thread |
|---|---|
| Rate This Thread | |
| Thread | Thread Starter | Forum | Replies | Last Post |
|---|---|---|---|---|
| Change the align of all the text in the application to "right" | mikecotic | Mobile Java General | 2 | 2008-12-06 06:38 |
| draw Text "Hello World1\Hello World2" at center of screen | junmobus | Symbian User Interface | 5 | 2008-05-26 07:10 |
| How do you center text on the screen? | Subotai4Winds | General Symbian C++ | 1 | 2005-01-24 04:01 |
| Persist text value of user defined option in Enumerated Text Settings List | leethomso | Symbian User Interface | 0 | 2004-11-24 19:49 |
| How to draw right align text? | yingchuan | Symbian | 1 | 2004-10-23 03:05 |