×

Discussion Board

Results 1 to 5 of 5
  1. #1
    Registered User
    Join Date
    Mar 2008
    Posts
    17

    Canvas & debug print statements

    Here is a real newbie question:

    I am using print statements for debug. But my latest application is using a Canvas (I need to get keypresses and show images). The canvas covers the screen and I can't see the print statements. (I have not discovered a way of shrinking the canvas other than app.normal, which is not enough shrinkage).

    Is there a simple way to mix print and Canvas? Is there a form one can place on the cavas for scrolling text windows?

    I apoligize, but I searched the FAQ and did not find an answer.

  2. #2
    Nokia Developer Moderator
    Join Date
    Oct 2007
    Location
    Deva, Romania
    Posts
    3,471

    Re: Canvas & debug print statements

    You could try to write on the canvas using a small font. Maybe something like this:

    Code:
    canvas.text((10,y), u"Text goes here", font="default")
    y+=15
    
    #You have to increase y each time to avoid writing on top of the previous line
    Other than that I don't know of anything that would work.

    EDIT:There may be a "long way around": having a menu to switch between the two.
    Code:
    import appuifw, e32
    from graphics import *
    from key_codes import *
    
    a=e32.Ao_lock()
    def quit():a.signal()
    appuifw.app.exit_key_handler=quit
    
    bg=Image.new((240,240))
    
    t=appuifw.Text()
    
    #The keyboard class I used can be found here (at "Method 2"):http://wiki.forum.nokia.com/index.php/How_to_handle_keypress_easily
    
    def showc():
    	global keyboard
    	def handle_redraw(rect):canvas.blit(bg)
    	canvas=appuifw.Canvas(event_callback=keyboard.handle_event, redraw_callback=handle_redraw)
    	appuifw.app.body=canvas
    
    def showt():
    	global t
    	appuifw.app.body=t
    	t.add(u"G\n")
    
    appuifw.app.menu=[(u"Canvas", showc), (u"Text", showt)]
    
    t.add(u'Something')
    bg.text((30,30), u"Something", font="title")
    t.add(u"something else\n")
    
    a.wait()
    In the example above, you can use the menu to switch between canvas and text. To illustrate that it works, every time you select "text", "G" will be printed. Just adapt it to your needs.
    Last edited by bogdan.galiceanu; 2008-04-06 at 19:08.

  3. #3
    Regular Contributor
    Join Date
    Mar 2008
    Posts
    57

    Re: Canvas & debug print statements

    If You want to see exceptions, use an exception harness (search the forum for that) to display unhandled exceptions.

    As to mixing print and canvas, there's no easy way. The thing you describe about "scrolling text window" is perfectly possible in python (using redirection of sys.stdout and sys.stderr), but well - someone has to write it .

    And then there's the canvas.text method that Bogdan mentioned, which You can use instead of print (easy if You want one short message at a time).

    Oh, and another idea: while You can't have two different built-in controls (like Canvas and Text) on screen at once, You can have one under the other. You could use Your canvas normally and print to the Text window below. Use a key handler to switch to the Text window and back whenever You'd want to see Your debug messages. Utilizing the print statement and catching the exceptions is possible with this method also (using redirection of sys.stdout and sys.stderr).
    Last edited by nokia_e70; 2008-04-06 at 19:41.

  4. #4
    Regular Contributor
    Join Date
    Dec 2007
    Location
    Kuopio, Finland
    Posts
    50

    Re: Canvas & debug print statements

    Quote Originally Posted by DrYSG View Post
    Here is a real newbie question:

    I am using print statements for debug. But my latest application is using a Canvas (I need to get keypresses and show images). The canvas covers the screen and I can't see the print statements. (I have not discovered a way of shrinking the canvas other than app.normal, which is not enough shrinkage).

    Is there a simple way to mix print and Canvas? Is there a form one can place on the cavas for scrolling text windows?

    I apoligize, but I searched the FAQ and did not find an answer.
    Maybe you could use audio.say(u'debug message') instead of print u'debug message'

    Ilpo

  5. #5
    Registered User
    Join Date
    Mar 2008
    Posts
    17

    Re: Canvas & debug print statements

    Great idea. I am obviously thinking too much inside the box, and this is embarrasing, since I try to the be to be the out of the box thinker.

Similar Threads

  1. AT Commands to read/receive SMS
    By Fatema in forum General Messaging
    Replies: 2
    Last Post: 2008-02-29, 11:20
  2. How to send an image with attachment in email
    By krtrivdi in forum Symbian
    Replies: 1
    Last Post: 2007-01-09, 12:07
  3. Sending an image over email
    By jeclarim in forum Symbian
    Replies: 3
    Last Post: 2006-12-15, 20:25
  4. Major problem with delegation to Canvas
    By bartekn in forum Mobile Java Media (Graphics & Sounds)
    Replies: 8
    Last Post: 2003-10-08, 17:46

Posting Permissions

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