×

Discussion Board

Page 1 of 2 12 LastLast
Results 1 to 15 of 17
  1. #1
    Registered User
    Join Date
    May 2008
    Posts
    25

    New to python - some basic questions (I think)

    Hello everyone! I'm looking at this
    forum for some couple of days trying to understand things,
    and I'm still left with some questions (some hard to find because I find alot of information about one thing, information which I don't need) to some basic things:

    1. app_lock = e32.Ao_lock() what is this command really do?
    and what the module e32 is?

    2. canvas.blit(img) does this command means draw the img?

    3. I built this little application:
    Code:
    import appuifw
    import graphics
    import e32
    img=graphics.Image.open('e:\\SCube\\start.jpg')
    
    
    def handle_redraw(rect):
        global img
        canvas.blit(img)
    
    
    def quit():
        app_lock.signal()
        
    canvas=appuifw.Canvas(redraw_callback=handle_redraw)
    appuifw.app.body=canvas
    canvas.blit(img)
    appuifw.app.screen='full'
    appuifw.app.exit_key_handler = quit
    
    img=graphics.Image.open('e:\\img1.jpg')
    canvas.blit(img)
    img=graphics.Image.open('e:\\img2.jpg')
    canvas.blit(img)
    img=graphics.Image.open('e:\\img3.jpg')
    canvas.blit(img)
    
    app_lock = e32.Ao_lock()
    app_lock.wait()
    I can see that the image's switch kind of slowely (even without putting any delay between them, I guess it's because python load each image from the memory which seems to be slow)

    can I do something like "preload" the images so I can show them right away just after calling them?

    Another thing, when I use time.sleep(1) for example, can I tell the application to do something in that 1 second?

    I'm really new in Python so this is why I ask all of these basic questions.

    Thanks!

  2. #2
    Super Contributor
    Join Date
    Oct 2007
    Location
    Deva, Romania
    Posts
    3,471

    Re: New to python - some basic questions (I think)

    Hi,

    You should read the PyS60 Library Reference. It contains all the information you need

    app_lock = e32.Ao_lock()
    This instantiates an active object lock. When run in the Script Shell, Python scripts are executed and then exit if they don't have a locked active object that is waiting to be released. In other words, it prevents the script from closing until the user tells it to.

    canvas.blit(img)
    This "puts" the image on the canvas.

    You can load several images and show them only after they are all loaded. That would make the effect smoother.

    You cannot make the application do something in the sleep period.
    time.sleep(secs)
    Suspend execution for the given number of seconds. The argument may be a floating point number to indicate a more precise sleep time. The actual suspension time may be less than that requested because any caught signal will terminate the sleep() following execution of that signal’s catching routine. Also, the suspension time may be longer than requested by an arbitrary amount because of the scheduling of other activity in the system.

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

    Re: New to python - some basic questions (I think)

    Quote Originally Posted by shynet View Post
    Hello everyone! I'm looking at this
    forum for some couple of days trying to understand things,
    and I'm still left with some questions (some hard to find because I find alot of information about one thing, information which I don't need) to some basic things:
    hello shynet

    and a warm welcome to you at the forum nokia dibo.
    Quote Originally Posted by shynet View Post
    1. app_lock = e32.Ao_lock() what is this command really do?
    and what the module e32 is?
    this command call the function Ao_lock which actually locks your application at the end so that you can get a valid output.
    you can know various functions of e32 module from here.

    Quote Originally Posted by shynet View Post

    2. canvas.blit(img) does this command means draw the img?
    ya the canvas.blit function first draws the image on the canvas.

    Hope this helps you
    Enjoy Pythoning
    Gaba88

    PS: bogdan was faster then me

  4. #4
    Nokia Developer Champion
    Join Date
    Sep 2007
    Location
    Bhavnagar
    Posts
    928

    Re: New to python - some basic questions (I think)

    hi,
    welcome to the forum.
    1. e32.Ao_lock is use to make your application to be wait before it exit using lock.wait() command. you can exit your application when user press some key mostly exit key. you have to use lock.signal() for that to release your application from wait state.
    e32 is actually a inbuilt module for python.

    2. you are right that canvas.blit is used to draw the image.
    Jajal Mehul

  5. #5
    Nokia Developer Champion
    Join Date
    Sep 2007
    Location
    Bhavnagar
    Posts
    928

    Re: New to python - some basic questions (I think)

    Sorry for the same reply.
    Actually me,gaba88 and bogdan had reply almost at the same time so that i had not seen their post.

    Jajal Mehul

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

    Wink Re: New to python - some basic questions (I think)

    Quote Originally Posted by shynet View Post
    I can see that the image's switch kind of slowely (even without putting any delay between them, I guess it's because python load each image from the memory which seems to be slow)

    can I do something like "preload" the images so I can show them right away just after calling them?

    Thanks!
    Hello again

    i guess as you are bliting the images from memory only it will certainly take a delay. I guess no other methods which will prevent this delay.

    Enjoy Pythoning
    Gaba88

  7. #7
    Super Contributor
    Join Date
    Oct 2007
    Location
    Deva, Romania
    Posts
    3,471

    Re: New to python - some basic questions (I think)

    Quote Originally Posted by gaba88 View Post
    i guess as you are bliting the images from memory only it will certainly take a delay. I guess no other methods which will prevent this delay.
    Well opening all the images before starting to blit them would probably reduce the flickering.

  8. #8
    Registered User
    Join Date
    May 2008
    Posts
    25

    Re: New to python - some basic questions (I think)

    Wow! Thanks for all of you!!! I think I now understand most of my questions the last thing I really need is the Image part, what I'm trying to do is to display image after image (Animation) every image size is 240X320 which fit exactly to my phone (Nokia N95). which means, the images will not show together, they will just "cover" each other (each image fits to the screen size), any ideas on how to do what I want to faster? one that come up to my mind is loading the image to the phone ram but I don't know if it's a good idea or a right one to pick. I think the "Animation" word says it all, show image after image to create an animation.

    Also I'm using for my program the axyz module for the accelerometer, I'm trying to recognize a "Shake" I have wrriten this code and it seems to work fine:
    Code:
    if abs(x)>85:
    Shake detected...
    is this a good method to detect phone shacking? Thank you very very much!

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

    Re: New to python - some basic questions (I think)

    Quote Originally Posted by shynet View Post
    Code:
    if abs(x)>85:
    Shake detected...
    is this a good method to detect phone shacking? Thank you very very much!
    Seems ok. Although, it depends on what kind you shake you want. Just test the values and see what you think it should be like. The shake value is pretty much a personal thing, so just test it and check what you like


    BR,

    Rafael.

  10. #10
    Registered User
    Join Date
    May 2008
    Posts
    25

    Re: New to python - some basic questions (I think)

    Quote Originally Posted by Rafael T. View Post
    Seems ok. Although, it depends on what kind you shake you want. Just test the values and see what you think it should be like. The shake value is pretty much a personal thing, so just test it and check what you like


    BR,

    Rafael.
    I'm just back from school,Thank you for your respone! I think it's pretty much ok and another question how can I create a form with a scroll (like most program that use accelerometer) to change the sensitivity like this program:
    http://symbianwebblog.files.wordpres..._beta40005.jpg
    and anybody got any idea on how to create a fast switching images?

    Thanks again!!!!

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

    Re: New to python - some basic questions (I think)

    Quote Originally Posted by shynet View Post
    I'm just back from school,Thank you for your respone! I think it's pretty much ok and another question how can I create a form with a scroll (like most program that use accelerometer) to change the sensitivity like this program:
    http://symbianwebblog.files.wordpres..._beta40005.jpg
    Hi shynet,

    Unfortunately, that settings screen can't be used with PyS60. The application you showed us is made in Symbian C++, which allows you to use it. The slider for changing sensitivity is not available too

    Although, you can use forms, those have some functions of the settings screen

    Quote Originally Posted by shynet View Post
    and anybody got any idea on how to create a fast switching images?
    What do you mean by fast switching images? You want to do a kind of animation for switching? Please explain better.



    BR,

    Rafael.

  12. #12
    Registered User
    Join Date
    May 2008
    Posts
    25

    Re: New to python - some basic questions (I think)

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

    Unfortunately, that settings screen can't be used with PyS60. The application you showed us is made in Symbian C++, which allows you to use it. The slider for changing sensitivity is not available too

    Although, you can use forms, those have some functions of the settings screen


    What do you mean by fast switching images? You want to do a kind of animation for switching? Please explain better.



    BR,

    Rafael.
    I will try to explain my self better, I'm trying to show image after image, but when I use the method I mentioned it open each image with a bit delay, what I want to do is to "preload" the image to the ram for example so when I will tell python to draw the picture it will be shown immediately, so the final result will look like an animation of switching images (or just animation is good enough I think) by the way talking about C++ for symbian, is it much harder to develop in it for symbian? Thanks again!!

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

    Re: New to python - some basic questions (I think)

    Quote Originally Posted by shynet View Post
    I will try to explain my self better, I'm trying to show image after image, but when I use the method I mentioned it open each image with a bit delay, what I want to do is to "preload" the image to the ram for example so when I will tell python to draw the picture it will be shown immediately, so the final result will look like an animation of switching images (or just animation is good enough I think) by the way talking about C++ for symbian, is it much harder to develop in it for symbian? Thanks again!!
    Hi shynet,

    Well, I'm not on my computer now, but I remember the graphics.Image.load() function, can't remember how it works exactly, though. Check the Python API Reference to see how this function works.

    About Symbian C++, it is much more difficult than Python in my opinion, but I have seen harder things in my life

    You can try to learn, though. It would allow you to use many more features of the device and develop in low-level.



    BR,

    Rafael.

  14. #14
    Regular Contributor
    Join Date
    Mar 2008
    Posts
    151

    Re: New to python - some basic questions (I think)

    Quote Originally Posted by shynet View Post
    I will try to explain my self better, I'm trying to show image after image, but when I use the method I mentioned it open each image with a bit delay, what I want to do is to "preload" the image to the ram for example so when I will tell python to draw the picture it will be shown immediately, so the final result will look like an animation of switching images (or just animation is good enough I think) by the way talking about C++ for symbian, is it much harder to develop in it for symbian? Thanks again!!
    This is how I loaded a bunch of images:

    Code:
    global photolist
    photolist = []
    
    def load_images():
        global photolist
    
        for i in range(9):
            photolist.append(Image.open(u"e:\\July2008\\p%i.jpg" %(i+1)))
    Then you can call each one with something like:
    Code:
    canvas.blit(photolist[9])

  15. #15
    Registered User
    Join Date
    May 2008
    Posts
    25

    Re: New to python - some basic questions (I think)

    Quote Originally Posted by jtullis View Post
    This is how I loaded a bunch of images:

    Code:
    global photolist
    photolist = []
    
    def load_images():
        global photolist
    
        for i in range(9):
            photolist.append(Image.open(u"e:\\July2008\\p%i.jpg" %(i+1)))
    Then you can call each one with something like:
    Code:
    canvas.blit(photolist[9])
    Thanks that helped me alot!!! last question (for this post I think):

    How can I make a loading dialog popup? (For example, if I want to connect to a wifi a loading dialog pops up which shows me it's trying to connect to the certain network) how can I do that?

    it looks like this:
    http://www.symbian-guru.com/wp-conte...es_loading.jpg
    but without any progress just a repeating animation.

Similar Threads

  1. Basic Concepts for Mobile Application in Python
    By Faisal Rehman in forum Symbian
    Replies: 2
    Last Post: 2008-07-13, 19:12
  2. Where to find basic Python reference?
    By carknue in forum Symbian
    Replies: 3
    Last Post: 2007-06-27, 06:07
  3. newbie, some basic questions about mobile application development
    By p_sudheers in forum Mobile Java General
    Replies: 1
    Last Post: 2006-10-04, 21:49
  4. Extremely basic questions
    By greg.fenton in forum Carbide.c++ IDE and plug-ins (Closed)
    Replies: 1
    Last Post: 2004-12-17, 03:24
  5. Basic questions from a college CS major
    By shoelessone in forum Mobile Java General
    Replies: 0
    Last Post: 2004-11-11, 21:08

Posting Permissions

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