Question

Hi I have a nokia 5800 phone on which I was doing some pys60 ui programming. I used the below code to create the arrow. In short the draw() will draw the arrow onto the canvas surface. The canvas has redraw_callback and resize_callback hooked up to call draw() eventually. But on tilting I get some random text (garbage) output on the screen.

import appuifw
from appuifw import *
import e32
from graphics import *

def up(dummy):
    appuifw.note(u'Button 1 Clicked', 'note')

def down(dummy):
    appuifw.note(u'Button 2 Clicked', 'note')

appuifw.app.screen = 'normal'

def on_resize(dummy):
    draw()

def on_redraw(dummy):
    draw()  

def on_exit():
    global lock
    lock.signal()

def draw():
    global canvas
    canvas.clear()
    canvas.polygon((20,20,20,60,40,40,20,20), fill=(255,0,0), width=10)


canvas = appuifw.Canvas(resize_callback=on_resize, redraw_callback=on_redraw)
lock = e32.Ao_lock()
appuifw.exit_key_handler = on_exit
draw()
lock.wait()

Here is how it looks when I've held the phone straight up.

Held Straight

Here is how it looks when I've tilted it.

Tilted

Was it helpful?

Solution

Note that the space that has the text (in landspace) is the size of the width minus the width it was when the orientation was portrait. Are you forgetting to resize the canvas to the landscape new dimentions?

It seems the text is the console output, check what is not being defined and whatever else is being output there.

OTHER TIPS

appuifw.app.orientation = 'portrait'

or even:

appuifw.app.orientation = 'landscape'
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top