| Reply | « Previous Thread | Next Thread » |
|
I tried to recreate the wrapping text effect like in akntextutils module (wrapping without cut words), but something goes wrong
This is my code Code:
def text_wrap(text,lung): text_array =[] flag = lg = 0 while len(text) > lg: try: for k in range(0,lung): if text[k] == " ": flag = lg + k except: flag = len(text) lines = text[lg:flag] lg = flag text_array.append(lines) return text_array Code:
all = text_wrap(text_show, 32) for lines in all: show.text((10, top), unicode(lines), font='title', fill = color) top += 20 1. sometimes the new line starts with a white space. I even tried to add 1 to the first character of new line, but in this way sometimes I get a missing character. I know there is something missing, but I can't figure out what it is. 2. how can I get the number of character that can fit in canvas? I put 32, but I think in larger screen I can have a lot of white space on the right. Thanks in advance. |
|
First of all, you can't wrap on a fixed size of a row if you're not using a fixed-width font. Think about it, 32 "W" letters are much wider than 32 "i" letters.
Therefore, you have to use the measure_text() method of PyS60 drawable objects to measure the width of text depending on the font you're using. Your wrapping function will have to be somewhat more complicated. And use the appuifw.app.layout(appuifw.EMainPane)[0] to get width and height of the canvas. |
|
Previously, There was a post related to this !
May be seaching the forum might do some good. Br, Croozeus |
|
I did. I only found this post but I couldn't get it work.
Other posts were related to akntextutils that it's impossible to include in the .sis file, so I had to avoid to use it. BTW if I'm the only one having problems with the class in the first post, I'll check my code and try to make it works. |
|
This class looks good to me. Check it and tell us what problems are you having exactly. We'll try to help.
|
|
It was something related to number of items.
Now it works fine. Thanks for you support! |
| Reply | « Previous Thread | Next Thread » |
| Thread Tools | Search this Thread |
|---|---|
| Rate This Thread | |
| Thread | Thread Starter | Forum | Replies | Last Post |
|---|---|---|---|---|
| Wrap text using drawString ? | artemg | Mobile Java General | 6 | 2009-06-25 11:25 |
| Wrap text using soft return in cell on CAKnGrid | heuven | Symbian User Interface | 3 | 2008-04-01 07:46 |
| Need help to Wrap and Display long text | dc-huang | Symbian User Interface | 0 | 2005-08-30 14:47 |
| Persist text value of user defined option in Enumerated Text Settings List | leethomso | Symbian User Interface | 0 | 2004-11-24 19:49 |
| Nokia 7650 Anchor element text does not wrap | voxsurf | Browsing and Mark-ups | 1 | 2003-02-28 09:53 |