×

Discussion Board

Results 1 to 2 of 2
  1. #1
    Registered User
    Join Date
    Sep 2009
    Location
    Napoli - Italy
    Posts
    14

    Post best solution to render text with wrapping without any class

    Hi,
    I've to render a text from web page (with urllib).
    If I use this:
    Code:
    myText = appuifw.Text()
    content = urllib.urlopen(URL_BASE).read()
    myText.set(u""+content)
    appuifw.app.body = myText
    myText is wrapped correctly but I don't know how to insert an image in canvas together myText.
    On the contrary, if I use this:
    Code:
    def Draw(rect):
      canvas.clear(0xffffff)
      logo = Image.open("E:\\myImg.jpg")
      canvas.blit(logo,target=(0,0))
      canvas.text((20,200), u'Welcome', fill = 0x0000ff, font = "normal")
      myText = appuifw.Text()
      myText.set(u"Benvenuto in appname\n\n\nIn attesa di nuovi contenuti...")
    
    Draw(())
    
    appuifw.app.body=canvas=Canvas(redraw_callback=Draw)
    I can insert text and image together but if the text is more long, it doesn't wrapped.
    I found some classes to do this but it's possible that there isn't any simple way to wrapped a text (for example an attribute of canvas.text)?
    Thank you
    Last edited by antoniog85; 2010-05-25 at 21:24.
    Antonio GIULIANA
    www.antoniogiuliana.it

  2. #2
    Super Contributor
    Join Date
    Nov 2007
    Location
    Sertaozinho/Brazil
    Posts
    768

    Re: best solution to render text with wrapping without any class

    Hi antoniog85

    I found some classes to do this but it's possible that there isn't any simple way to wrapped a text (for example an attribute of canvas.text)?
    I don´t know any simple way
    How about to generate a html file and call the standard browser to show the file ?

    Code:
    import time
    froom appuifw import *
    
    def done():
        note(u"done!","error")
    
    def preview_html():
    
        html = u"<h1>Hello world !</h1>"
        name = "html_" + time.strftime("%Y%m%d_%H%M%S", time.localtime()) + ".html"
    
        try:
            fp = open(name,"wt")
        except:
            note(u"oops!","error")
            return
    
        fp.write("<html>\n")
        fp.write('<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>\n')
        fp.write("<body>\n")
        fp.write(html)
        fp.write("</body></html>")
        fp.close()
            
        viewer = Content_handler(done)
    
    preview_html()
    You can use BeautifulSoupto process the html as well.

    Regards,

Similar Threads

  1. CustomItem and text wrapping
    By jay.bertrand in forum Mobile Java General
    Replies: 0
    Last Post: 2009-01-23, 13:42
  2. C++ Symbols class(), class()->,class. ????
    By PACALA_BA in forum Symbian
    Replies: 7
    Last Post: 2008-09-15, 20:57
  3. how to display text in class CAknGMSStyleGrid (photo album)
    By liuajie in forum Symbian User Interface
    Replies: 2
    Last Post: 2007-11-27, 04:57
  4. Replies: 2
    Last Post: 2007-03-14, 17:15
  5. Replies: 1
    Last Post: 2003-03-26, 10:04

Posting Permissions

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