You Are Here:

Community: Developer Discussion Boards

#1 Old Smile Canvas issues , plz help :) - 2008-12-14, 11:26

Join Date: Dec 2008
Posts: 14
aloycasmir
Offline
Registered User
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
Reply With Quote

#2 Old Re: Canvas issues , plz help :) - 2008-12-14, 11:59

Join Date: Feb 2008
Posts: 2,542
Location: Bhavnagar, Gujarat, India
Send a message via Yahoo to gaba88 Send a message via Skype™ to gaba88
gaba88's Avatar
gaba88
Offline
Forum Nokia Champion
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


Gargi Das- http://gargidas.blogsot.com

Forum Nokia Python Wiki


Learn Python at http://mobapps.org/PyS60
Reply With Quote

#3 Old Re: Canvas issues , plz help :) - 2008-12-14, 12:23

Join Date: Dec 2008
Posts: 14
aloycasmir
Offline
Registered User
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
Reply With Quote

#4 Old Re: Canvas issues , plz help :) - 2008-12-14, 16:34

Join Date: May 2004
Posts: 524
Location: Tampere, Finland
jethro.fn's Avatar
jethro.fn
Offline
Forum Nokia Champion
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.
Reply With Quote

#5 Old Question Re: Canvas issues , plz help :) - 2008-12-15, 07:40

Join Date: Dec 2008
Posts: 14
aloycasmir
Offline
Registered User
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
Reply With Quote

#6 Old Re: Canvas issues , plz help :) - 2008-12-15, 09:37

Join Date: May 2004
Posts: 524
Location: Tampere, Finland
jethro.fn's Avatar
jethro.fn
Offline
Forum Nokia Champion
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()
Reply With Quote

#7 Old Re: Canvas issues , plz help :) - 2008-12-17, 14:50

Join Date: Dec 2008
Posts: 14
aloycasmir
Offline
Registered User
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
Reply With Quote

#8 Old Re: Canvas issues , plz help :) - 2008-12-17, 17:40

Join Date: Feb 2008
Posts: 743
Location: Belo Horizonte, Brazil
Send a message via Skype™ to Rafael T.
Rafael T.'s Avatar
Rafael T.
Offline
Forum Nokia Champion
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 15:13.
Reply With Quote

#9 Old Re: Canvas issues , plz help :) - 2008-12-18, 07:43

Join Date: Dec 2008
Posts: 14
aloycasmir
Offline
Registered User
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
Reply With Quote

#10 Old Re: Canvas issues , plz help :) - 2008-12-18, 15:15

Join Date: Feb 2008
Posts: 743
Location: Belo Horizonte, Brazil
Send a message via Skype™ to Rafael T.
Rafael T.'s Avatar
Rafael T.
Offline
Forum Nokia Champion
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.
Reply With Quote

#11 Old Re: Canvas issues , plz help :) - 2008-12-18, 23:40

Join Date: Dec 2008
Posts: 14
aloycasmir
Offline
Registered User
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
Reply With Quote

#12 Old Re: Canvas issues , plz help :) - 2008-12-19, 00:09

Join Date: Feb 2008
Posts: 743
Location: Belo Horizonte, Brazil
Send a message via Skype™ to Rafael T.
Rafael T.'s Avatar
Rafael T.
Offline
Forum Nokia Champion
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 05:07.
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
Problem with setFullScreenMode(true) in canvas mramin05 Mobile Java Media (Graphics & Sounds) 6 2008-12-06 06:45
canvas...help me plz chirpylife Python 1 2008-10-09 22:52
How to create a partly transparent Canvas to lay on top of another Canvas? mkleijer Mobile Java Media (Graphics & Sounds) 4 2007-05-22 08:00
Major problem with delegation to Canvas bartekn Mobile Java Media (Graphics & Sounds) 8 2003-10-08 18:46
Mercy Mercy plz full canvas makes me thik! SolaSoly Mobile Java Tools & SDKs 0 2003-03-28 04:42

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