You Are Here:

Community: Developer Discussion Boards

#1 Old Graphics interface - 2009-01-26, 19:53

Join Date: Oct 2008
Posts: 24
BAM8
Offline
Registered User
Hello, I´ve a problem when I try to draw a line in my app for a s60 mobile. I try this:


import e32
import appuifw
import graphics
import key_codes
import random
...
img.text((180, 200), u'%d' % (3))
img.line((30,40),(100,40),outline=0,fill=0)
...

and I´ve tried the second line in a great amount of ways and i become once and again the same error: Invalid syntax. When I quit the second line it all works fine. What am I doing wrong?

Thanks!
Reply With Quote

#2 Old Re: Graphics interface - 2009-01-26, 20:04

Join Date: Oct 2007
Posts: 2,841
Location: Deva, Romania
bogdan.galiceanu's Avatar
bogdan.galiceanu
Offline
Forum Nokia Champion
That's because the coordinates are supposed to be in one tuple. So use either
img.line((30,40,100,40),outline=0,fill=0)
or
img.line(((30,40),(100,40)),outline=0,fill=0)
Reply With Quote

#3 Old Re: Graphics interface - 2009-01-26, 20:07

Join Date: Sep 2007
Posts: 395
Location: Bhavnagar
Send a message via Yahoo to james1980
james1980's Avatar
james1980
Offline
Forum Nokia Champion
Hi BAM8,
If would like to tell you that please give a complete code here so that one can easily find the error and one more thing, use code tag while writing a code so that it will maintain all white spaces. It is given as a '#" button on the top of the window.

Regards.


Jajal Mehul
Reply With Quote

#4 Old Re: Graphics interface - 2009-01-26, 20:10

Join Date: Oct 2008
Posts: 24
BAM8
Offline
Registered User
I tried that too, and the way i put here too... all of them give me a mistake.

Code:
import e32
import appuifw
import graphics
import key_codes
import random


RGB_BLACK = (0, 0, 0)
RGB_WHITE = (255, 255, 255)
RGB_RED = (255, 0, 0)
RGB_GREEN = (0, 255, 0)
RGB_BLUE = (0, 0, 255)
RGB_YELLOW = (255, 255, 0)

screen_x = 240
screen_y = 320
origo_x = 120
origo_y = 160
canvas = None
img = None
im1 = None

# MAGIC
my_zoom = 3
my_scale = my_zoom * 120



def cb_handle_redraw():
    ''' Overwrite default screen redraw event handler '''
    if not canvas:
        return
    if img:

        # Remove old and draw new data
        img.clear((0,0,0))
        img.text((10, 100), u'Pasos', font="dense")
        img.text((180, 100), u'%d' % (1))
        img.text((10, 150), u'Calorías', font="dense")
        img.text((180, 150), u'%d' % (2))
        img.text((10, 200), u'Distancia (metros)', font="dense")
        img.text((180, 200), u'%d' % (3))
		img.line((30,40, 100,40),width = 2, outline=(255,0,0))
        canvas.blit(img)

def menu_view():
    im1.clear((0,0,0))

def cb_quit():
    ''' About to exit, do clean-up first '''
    # Undo bind() just in case
    canvas.bind(key_codes.EKey0, None)
    canvas.bind(key_codes.EKey1, None)
    canvas.bind(key_codes.EKey2, None)
    canvas.bind(key_codes.EKey3, None)
    canvas.bind(key_codes.EKeyStar, None)
    canvas.bind(key_codes.EKeyHash, None)


    app_lock.signal()

#############################################################

fTodosE = file(u"E:\\Python\\accTodosExcel.csv", "w+")


appuifw.app.orientation = 'portrait'
appuifw.app.screen = 'full'
appuifw.app.title = u'Entrenador Personal'
appuifw.app.exit_key_handler = cb_quit
appuifw.app.menu = [
    (u"Show Graph", lambda: menu_view()),
    (u"Exit", cb_quit)
    ]

canvas = appuifw.Canvas(
       redraw_callback = cb_handle_redraw)

# Calls automatically resize_callback which calls redraw_callback
# No resize_callback so have to call redraw_callback myself
img = graphics.Image.new(canvas.size)
appuifw.app.body = canvas
im1 = graphics.Image.new(canvas.size)
screen_x, screen_y = canvas.size
origo_x = screen_x / 2
origo_y = screen_y / 2
cb_handle_redraw()

# Keys are used for testing the code
canvas.bind(key_codes.EKey0, lambda: reset_data())
canvas.bind(key_codes.EKeyStar, lambda: set_scale(1))
canvas.bind(key_codes.EKeyHash, lambda: set_scale(-1))
canvas.bind(key_codes.EKey9, lambda: screen_shot())

#############################################################
app_lock = e32.Ao_lock()
app_lock.wait()
Reply With Quote

#5 Old Re: Graphics interface - 2009-01-26, 20:13

Join Date: Oct 2008
Posts: 24
BAM8
Offline
Registered User
I´ve seen the mistake! I was with an editor that tabulates in wrong way... Now it works! Thank u!
Reply With Quote
Reply « Previous Thread | Next Thread »
Display Modes
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

Posting Rules

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

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump
Similar Threads
Thread Thread Starter Forum Replies Last Post
关于Symbian的语音系统 matthew0816 Symbian 3 2008-02-19 08:15
A bug: setColor with offscreen graphics - PLEASE, REPLY THIS TIME palmcrust Mobile Java General 11 2003-12-04 13:43
Using the Graphics object outside of paint()? weedy Mobile Java General 4 2003-06-06 11:03
[ANN] TinyLine 2D v1.4 freeware: Light weight 2D Graphics for J2ME Platform girow Mobile Java General 1 2003-02-25 11:28
Realtime graphics on 7650 suckho General Symbian C++ 2 2002-09-18 12:14

Rate This

 
Bookmark this page: DeliciousDiggFacebookGoogleYahooStumbleUponRedditDiigoTechnocratiTwitter  Share this page Share this page Print this Page Print this page Invite a friend Invite a friend
京ICP备05048969号    Email Newsletters Press Terms & Conditions Privacy Policy Sitemap Contact Us © 2009 Nokia