×

Discussion Board

Results 1 to 4 of 4
  1. #1
    Regular Contributor
    Join Date
    Oct 2007
    Posts
    73

    Creating multiple views in python

    Hi all,
    I am a symbian developer and have just started python. I have one query regarding creation of an application having multiple views.
    say view1: having menu1 and displaying image1 in appuifw.app.body part.
    view2: having menu2 and displaying image2 in appuifw.app.body part.
    Using a menu option , i should be able to move from one view to other.
    In smbian i used multiview architecture. I want to know how i do it in python (a small snippet will help me a lot).
    Also when i use exit_key_handler, i get exit option for right soft key. I want to know how i can generate back option for right soft key.

    thanks in advance,
    kumar_sai

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

    Re: Creating multiple views in python

    Hi,

    Well, the conventional way of doing this is to save all the attributes of appuifw.app before you modify them so that when you want to go back to the initial view, you just set appuifw.app to what you saved.

    The appuifw2 extension has the View class that allows you to achieve what you want in a more elegant way.

  3. #3
    Regular Contributor
    Join Date
    Sep 2008
    Location
    London, UK
    Posts
    176

    Re: Creating multiple views in python

    appuifw2 is not available for 1.9.x yet though. So saving all the appuifw.app data for each view would be required if you're using the PyS60.

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

    Re: Creating multiple views in python

    Quote Originally Posted by kumar_sai123 View Post
    Hi all,
    I am a symbian developer and have just started python. I have one query regarding creation of an application having multiple views.
    say view1: having menu1 and displaying image1 in appuifw.app.body part.
    view2: having menu2 and displaying image2 in appuifw.app.body part.
    Using a menu option , i should be able to move from one view to other.
    Hi,

    First of all, save your menu options into to different variables:

    Code:
    menu1 = [(u"Option 1", callback), (u"Option 2", callback)]
    menu2 = [(u"Option 3", callback), (u"Option 4", callback)]
    Then, open the image and blit the one you need for the current view:

    Code:
    img1 = graphics.Image.open('E:\\img1.jpg')
    img2 = graphics.Image.open('E:\\img2.jpg')
    
    if view == 1:
        img = img1
    elif view == 2:
        img = img2
    
    canvas.blit(img)
    Quote Originally Posted by kumar_sai123 View Post
    In smbian i used multiview architecture. I want to know how i do it in python (a small snippet will help me a lot).
    Just create a function to switch your views:

    Code:
    def load_view(view):
        if view == 1:
            img = img1
            menu = menu1
            # ... 
        if view == 2:
            img = img2
            menu = menu2
    
    canvas.blit(img)
    appuifw.app.menu = menu

    Quote Originally Posted by kumar_sai123 View Post
    Also when i use exit_key_handler, i get exit option for right soft key. I want to know how i can generate back option for right soft key.
    Use the callback to do what you want:

    Code:
    def key_handler_cbk(vw):
        load_view(vw)
    
    appuifw.exit_key_handler = lambda:key_handler_cbk(view)

    Obviously, those codes are very ugly. I wrote them just for you to understand the logic. Write yourself your own code so it will be much nicer than those examples



    Hope it helps,

    Rafael.

Similar Threads

  1. Python for S60 1.9.5 is now released
    By tvijayan in forum Symbian
    Replies: 8
    Last Post: 2009-05-30, 05:33
  2. Replies: 3
    Last Post: 2009-02-14, 13:37
  3. Replies: 5
    Last Post: 2008-10-07, 08:44
  4. Key Events in Multiple Grid Views
    By nair.shanker in forum Symbian User Interface
    Replies: 2
    Last Post: 2008-10-07, 07:12
  5. Replies: 4
    Last Post: 2008-09-18, 11:48

Posting Permissions

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