You Are Here:

Community: Developer Discussion Boards

#1 Old Animated img's in python? - 2008-10-28, 14:47

Join Date: Sep 2008
Posts: 21
JimmPooJimmPoo
Offline
Registered User
Hi,

I wrote my first app: nCoin v0.57
nCoin is an App that can toss a coin for something.

so here are my questions:

1.
Is it possible to show an animated img while the coin is "spinning" in the phone?

2.
how to flip the coin through pressing the Joistick?


Try it:
Download:
http://www.mediafire.com/?dmyhw0y4aws

- Latest Python and megapymodulepack must be installed.
- This is unsigned so you must self-sign or have a hacked phone.
Last edited by JimmPooJimmPoo : 2008-10-28 at 15:00.
Reply With Quote

#2 Old Re: Animated img's in python? - 2008-10-28, 17:49

Join Date: Sep 2008
Posts: 21
JimmPooJimmPoo
Offline
Registered User


nobody an Idea?

I only want to show a *.gif image in python...
Reply With Quote

#3 Old Re: Animated img's in python? - 2008-10-28, 18:00

Join Date: Oct 2007
Posts: 2,841
Location: Deva, Romania
bogdan.galiceanu's Avatar
bogdan.galiceanu
Online
Forum Nokia Champion
1) As far as I know it isn't possible to display animated gif files (you can only display the first frame of it). So maybe you can have a few different images and display them in a fast sequence so it would look like the coin is spinning.

2) You can bind the joystick (selection) button to the canvas so that when it's pressed, call a function that "flips" the coin.
Reply With Quote

#4 Old Re: Animated img's in python? - 2008-10-28, 18:13

Join Date: Sep 2008
Posts: 21
JimmPooJimmPoo
Offline
Registered User
thx for ur reply
so u mean extract the gif images to a few different images?
and then? i used this code to show one image:

Code:
scr=topwindow.TopWindow()
inf=graphics.Image.open("Path to file...")
scr.add_image(inf,(0,0,240,320))
scr.show()
but when I add this a again to view a second img,
for a little second, the background image of my app is shown.
there is no smoothly transition of the images...

u know a better code, to view a few images in fast sequence?
Reply With Quote

#5 Old Re: Animated img's in python? - 2008-10-28, 18: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 JimmPooJimmPoo View Post
Hi,

I wrote my first app: nCoin v0.57
nCoin is an App that can toss a coin for something.

so here are my questions:

1.
Is it possible to show an animated img while the coin is "spinning" in the phone?

2.
how to flip the coin through pressing the Joistick?

I just tested a script with an animated .gif and it didn't worked. The image stays still. But, as Bogdan said, you can display them in sequence so it will look like a spin.


To call the function for flipping the coin, you can use canvas.bind, as Bogdan also told you. For example:

Code:
import e32, appuifw, graphics
import key_codes

path = 'E:\\Python\\comeback.gif'
img = graphics.Image.open(path)

def coin_flip():

    # handle the flip here ...

def handle_redraw(rect):
    canvas.blit(img)

canvas = appuifw.Canvas(event_callback = None, redraw_callback = handle_redraw)
appuifw.app.body = canvas
appuifw.app.body = 'full'

canvas.bind(key_codes.EKeySelect, coin_flip)

app_lock = e32.Ao_lock()
app_lock.wait()

Hope it helps,

Rafael.
Reply With Quote

#6 Old Re: Animated img's in python? - 2008-10-28, 19:10

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 JimmPooJimmPoo View Post
thx for ur reply
so u mean extract the gif images to a few different images?
and then? i used this code to show one image:

Code:
scr=topwindow.TopWindow()
inf=graphics.Image.open("Path to file...")
scr.add_image(inf,(0,0,240,320))
scr.show()
but when I add this a again to view a second img,
for a little second, the background image of my app is shown.
there is no smoothly transition of the images...

u know a better code, to view a few images in fast sequence?
Sorry for the old reply below, we posted almost at the same time

I'm curious about something:

Why are you using topwindow module? This code you passed us is displaying the image in the whole screen. For this, you can simplify and use appuifw.Canvas()

For the animation being smooth, I recommend you to do many images and change them just a little bit at a time so it won't do any "rude" movement

So, take a look at the code I provided you on the post below. It uses the appuifw.Canvas(). I recommend you to use this because you'll avoid things like displaying the background when changing the images of your animation, as you will draw directly on the application's background


Hope it helps,

Rafael.
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
Please help installing Python libraries on S60 ericroijen Python 11 2009-07-18 11:43
New to Python for S60 (PyS60)? Read this first! croozeus Python 2 2008-10-17 20:23
[announce] the first Mobile Python book is now available ! cyke64 Python 1 2008-01-08 10:58
[announce] Mobile Python book soon in Sept 2007 ! cyke64 Python 11 2007-10-03 20:46
Animated GIF for MMS Specifications handtap General Messaging 2 2003-08-22 10:46

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