×

Discussion Board

Results 1 to 12 of 12
  1. #1
    Registered User
    Join Date
    Dec 2008
    Posts
    14

    Smile Canvas issues , plz help :)

    Well this is my first post , on my first day at FN DiBo :P
    Here's my problem now .
    I'm bored of the drawings and stuff like that .
    Having seen X-Plore v1.30 i thought of this .
    Is there any way to get the theme as your bg as seen in x-polre .
    My friend wook suggests it's possible with the appuifw2 module .
    Can anyone give me the code , how to do it .
    I've already tried the transparent image on canvas and this is what i get :
    Code:
    Python 2.2.2 (#0, Nov  7 2008, 14:24:30) [C] on symbian_s60
    Type "copyright", "credits" or "license" for more information.
    Ped 2.30.5 beta
    >>> ===== RESTART =====
    >>> 
    E:\Apps-development\Screen shot\Making app\1.py:63: SyntaxWarning: name 'running' is assigned to before global declaration
      def quarter():
    E:\Apps-development\Screen shot\Making app\1.py:63: SyntaxWarning: name 'running' is assigned to before global declaration
      def quarter():
    Traceback (most recent call last):
      File "ped.py", line 1366, in run_click
      File "E:\Apps-development\Screen shot\Making app\1.py", line 140, in ?
        quarter()
      File "E:\Apps-development\Screen shot\Making app\1.py", line 85, in quarter
        canvas.blit(ship, mask=mask)
    TypeError: Mask must be an Image object
    >>>
    Any help with this is gr8'ly appreciated .
    With best regards,
    Aloycasmir

  2. #2
    Nokia Developer Champion
    Join Date
    Feb 2008
    Location
    Ahmedabad, Gujarat, India
    Posts
    3,852

    Re: Canvas issues , plz help :)

    Quote Originally Posted by aloycasmir View Post
    Well this is my first post , on my first day at FN DiBo :P
    Here's my problem now .
    I'm bored of the drawings and stuff like that .
    Having seen X-Plore v1.30 i thought of this .
    Is there any way to get the theme as your bg as seen in x-polre .
    My friend wook suggests it's possible with the appuifw2 module .
    Can anyone give me the code , how to do it .
    I've already tried the transparent image on canvas and this is what i get :
    Code:
    Python 2.2.2 (#0, Nov  7 2008, 14:24:30) [C] on symbian_s60
    Type "copyright", "credits" or "license" for more information.
    Ped 2.30.5 beta
    >>> ===== RESTART =====
    >>> 
    E:\Apps-development\Screen shot\Making app\1.py:63: SyntaxWarning: name 'running' is assigned to before global declaration
      def quarter():
    E:\Apps-development\Screen shot\Making app\1.py:63: SyntaxWarning: name 'running' is assigned to before global declaration
      def quarter():
    Traceback (most recent call last):
      File "ped.py", line 1366, in run_click
      File "E:\Apps-development\Screen shot\Making app\1.py", line 140, in ?
        quarter()
      File "E:\Apps-development\Screen shot\Making app\1.py", line 85, in quarter
        canvas.blit(ship, mask=mask)
    TypeError: Mask must be an Image object
    >>>
    Any help with this is gr8'ly appreciated .
    With best regards,
    Aloycasmir
    hello aloycasmir

    welcome to forum nokia discussion boards.

    I am not sure about your question but have you checked the TopWindow module in PyS60.

    Hope it helps you.
    Enjoy Pythoning
    Gaba88

  3. #3
    Registered User
    Join Date
    Dec 2008
    Posts
    14

    Re: Canvas issues , plz help :)

    Quote Originally Posted by gaba88 View Post
    hello aloycasmir

    welcome to forum nokia discussion boards.

    I am not sure about your question but have you checked the TopWindow module in PyS60.

    Hope it helps you.
    Enjoy Pythoning
    Gaba88
    Thanx for the welcome as also your reply .
    My question is if we could set appuifw.Canvas as the same as our default theme .
    http://lonelycatgames.com/picture/xplore/shot5.png

    something like this .
    My friend says appuifw2 module can use current theme as bg .
    Any help with that is really apreciated .

    BR,
    Aloycasmir

  4. #4
    Super Contributor
    Join Date
    May 2004
    Location
    Tampere, Finland
    Posts
    524

    Re: Canvas issues , plz help :)

    Quote Originally Posted by aloycasmir View Post
    My friend says appuifw2 module can use current theme as bg .
    Only for Text() controls (and Listbox(), which is already themed in regular appuifw). See for yourself: appuifw2.

  5. #5
    Registered User
    Join Date
    Dec 2008
    Posts
    14

    Question Re: Canvas issues , plz help :)

    ok , i got that Thanx for your time .

    Can i ask for help with transparent image on canvas plz
    I'm using this currently .
    Code:
    import appuifw
    from appuifw import *
    import e32
    from graphics import *
    
    def quit():
        global running
        running=0
        appuifw.app.set_exit()
    
    appuifw.app.screen='large'
    
    def handle_redraw(rect):
        canvas.blit(img)
    
    canvas=appuifw.Canvas(event_callback=None, redraw_callback=handle_redraw)
    
    appuifw.app.body=canvas
    
    app.exit_key_handler=quit
    
    def automask(im):
        width, height = im.size
        mask = Image.new(im.size, '1') # black and white
        tran = im.getpixel((0,0))[0] # transparent top-left
        for y in range(height):
            line = im.getpixel([(x, y) for x in range(width)])
            for x in range(width):
                if line[x] == tran:
                    mask.point((x,y), 0) # mask on the point return mask
                     
                     
    from graphics import Image
    ship = Image.open('C:\\Data\\Games\\no.gif')
    mask = automask(ship)
    canvas.blit(ship, mask=mask) 
    e32.ao_yield()
    And i still don't get the transparency that i'm looking for .
    Best Regards,
    Aloycasmir

  6. #6
    Super Contributor
    Join Date
    May 2004
    Location
    Tampere, Finland
    Posts
    524

    Re: Canvas issues , plz help :)

    Quote Originally Posted by aloycasmir View Post
    Code:
    def quit():
        global running
        running=0
        appuifw.app.set_exit()
    There's no global variable called running in your program.


    Quote Originally Posted by aloycasmir View Post
    Code:
    def handle_redraw(rect):
        canvas.blit(img)
    There's no Image() object called img in your program. This redraw callback will fail.


    Quote Originally Posted by aloycasmir View Post
    Code:
    def handle_redraw(rect):
    def automask(im):
        width, height = im.size
        mask = Image.new(im.size, '1') # black and white
        tran = im.getpixel((0, 0))[0] # transparent top-left
        for y in range(height):
            line = im.getpixel([(x,y) for x in range(width)])
            for x in range(width):
                if line[x] == tran:
                    mask.point((x,y), 0) # mask on the point return mask
                     
                     
    from graphics import Image
    ship = Image.open('C:\\Data\\Games\\no.gif')
    mask = automask(ship)
    canvas.blit(ship, mask=mask) 
    e32.ao_yield()
    Your automask() function does not return anything (or more accurately, it returns None). Probably you accidentally moved the "return mask" part to the end of the preceding line.

    Here's a your program, reworked:

    Code:
    import appuifw
    from appuifw import *   # Bad style
    import e32
    from graphics import *  # Bad style
    
    def automask(im):
        width, height = im.size
        mask = Image.new(im.size, '1') # black and white
        tran = im.getpixel((0, 0))[0] # transparent top-left
        for y in range(height):
            line = im.getpixel([(x, y) for x in range(width)])
            for x in range(width):
                if line[x] == tran:
                    mask.point((x, y), 0) # mask on the point 
        return mask
    
    lock = e32.Ao_lock()
    
    def quit():
        lock.signal()
    
    ship = Image.open("E:\\ship.png")
    mask = automask(ship)
    
    def handle_redraw(rect):
        canvas.blit(ship, mask = mask)
        
    canvas = appuifw.Canvas(event_callback = None, redraw_callback = handle_redraw)
    
    appuifw.app.screen = "large"
    appuifw.app.body = canvas
    app.exit_key_handler = quit
                     
    lock.wait()
    
    appuifw.app.set_exit()

  7. #7
    Registered User
    Join Date
    Dec 2008
    Posts
    14

    Re: Canvas issues , plz help :)

    Quote Originally Posted by jethro.fn View Post
    There's no global variable called running in your program.




    There's no Image() object called img in your program. This redraw callback will fail.




    Your automask() function does not return anything (or more accurately, it returns None). Probably you accidentally moved the "return mask" part to the end of the preceding line.

    Here's a your program, reworked:

    Code:
    import appuifw
    from appuifw import *   # Bad style
    import e32
    from graphics import *  # Bad style
    
    def automask(im):
        width, height = im.size
        mask = Image.new(im.size, '1') # black and white
        tran = im.getpixel((0, 0))[0] # transparent top-left
        for y in range(height):
            line = im.getpixel([(x, y) for x in range(width)])
            for x in range(width):
                if line[x] == tran:
                    mask.point((x, y), 0) # mask on the point 
        return mask
    
    lock = e32.Ao_lock()
    
    def quit():
        lock.signal()
    
    ship = Image.open("E:\\ship.png")
    mask = automask(ship)
    
    def handle_redraw(rect):
        canvas.blit(ship, mask = mask)
        
    canvas = appuifw.Canvas(event_callback = None, redraw_callback = handle_redraw)
    
    appuifw.app.screen = "large"
    appuifw.app.body = canvas
    app.exit_key_handler = quit
                     
    lock.wait()
    
    appuifw.app.set_exit()
    Bro , gr8 thanx .I realised through your code , a typo i had made .
    Now it's working fine
    Extremely gr8-ful to you .

    Another query if you don't mind .
    How to trigger a callaback 'x' when gallery key is pushed using keycapture module .Can you plz give me the complete code .
    Your help is really appreciated .

    Hope , i'll be able to help forum nokia members soon , when my queries are finished and when my app is ready .
    tnx a lot jethro
    Regards,
    Aloycasmir

  8. #8
    Super Contributor
    Join Date
    Feb 2008
    Location
    Belo Horizonte, Brazil
    Posts
    744

    Re: Canvas issues , plz help :)

    Quote Originally Posted by aloycasmir View Post
    Another query if you don't mind .
    How to trigger a callaback 'x' when gallery key is pushed using keycapture module .Can you plz give me the complete code .
    Your help is really appreciated .
    Hi Aloycasmir,

    As long as I know, we cant capture the gallery key

    You can think on using other key, though



    BR,

    Rafael.
    Last edited by Rafael T.; 2008-12-18 at 14:13.

  9. #9
    Registered User
    Join Date
    Dec 2008
    Posts
    14

    Re: Canvas issues , plz help :)

    Quote Originally Posted by Rafael T. View Post
    Hi Aloycasmir,

    As long as I know, we cant capture the gallery key

    You can think on using other key, yhough



    BR,

    Rafael.
    Thanx for replying rafael
    I got it
    You're wrong bro , certainly , we can capture gallery key You'll see in my upcoming app .
    Have a good day .
    If it works fine , i'll even write down the code here
    Best regards ,
    Aloycasmir

  10. #10
    Super Contributor
    Join Date
    Feb 2008
    Location
    Belo Horizonte, Brazil
    Posts
    744

    Re: Canvas issues , plz help :)

    Quote Originally Posted by aloycasmir View Post
    Thanx for replying rafael
    I got it
    You're wrong bro , certainly , we can capture gallery key You'll see in my upcoming app .
    Have a good day .
    If it works fine , i'll even write down the code here
    Best regards ,
    Aloycasmir
    Cool

    Glad I was wrong, anyway

    Just never saw a Python application using this key. Maybe I should have taken a look on the key codes before

    Good luck with your application, hope to see it announced here



    BR,

    Rafael.

  11. #11
    Registered User
    Join Date
    Dec 2008
    Posts
    14

    Re: Canvas issues , plz help :)

    Quote Originally Posted by Rafael T. View Post
    Cool

    Glad I was wrong, anyway

    Just never saw a Python application using this key. Maybe I should have taken a look on the key codes before

    Good luck with your application, hope to see it announced here



    BR,

    Rafael.
    Sure , i.m glad too that you're wrong about that .
    Coz gallery key is one of the least used keys on most phones .
    Time to put it to use
    It'd be an honour if it were announced here too .
    I.m a symbian-freak developer though (and i believe you're too)
    But certainly it'd be better if t.were to be announced here too .
    I'll be posting gallery key recording code shortly - i.m testing it finally .
    It seems to be working , even with keypad locked
    anyways , do stay tuned , this could prove useful for your app too (i believe i know what you're working on , or were working on)
    Best regards,
    Aloycasmir

  12. #12
    Super Contributor
    Join Date
    Feb 2008
    Location
    Belo Horizonte, Brazil
    Posts
    744

    Re: Canvas issues , plz help :)

    You can announce it here maybe linking to Symbian-Freak article and/or forum if you want

    Any code you put here can help many people when they search for that, and maybe avoid some feature questions about the same subject.

    By the way, I have seen some other Symbian-Freak developers here too, but I'm not one of them



    Good luck,

    Rafael.
    Last edited by Rafael T.; 2008-12-19 at 04:07.

Similar Threads

  1. Problem with setFullScreenMode(true) in canvas
    By mramin05 in forum Mobile Java Media (Graphics & Sounds)
    Replies: 6
    Last Post: 2008-12-06, 05:45
  2. canvas...help me plz
    By chirpylife in forum Symbian
    Replies: 1
    Last Post: 2008-10-09, 21:52
  3. How to create a partly transparent Canvas to lay on top of another Canvas?
    By mkleijer in forum Mobile Java Media (Graphics & Sounds)
    Replies: 4
    Last Post: 2007-05-22, 07:00
  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
  5. Mercy Mercy plz full canvas makes me thik!
    By SolaSoly in forum Mobile Java Tools & SDKs
    Replies: 0
    Last Post: 2003-03-28, 03:42

Posting Permissions

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