×

Discussion Board

Results 1 to 7 of 7
  1. #1
    Regular Contributor
    Join Date
    Mar 2008
    Posts
    151

    how to make buttons on touch phone

    Will python let me make buttons wherever I want on a form? I just want two buttons, one at the top, and one at the bottom, of my nokia 5800.

    How do I define a square button, and how do I trigger a callback function whenever that button is pressed?

    I've checked out the keyviewer.py code, but I don't see any code for creating the cursor buttons at the bottom of the screen. I want my form to be fullscreen, but I want to choose where my buttons go.

    Easy?
    Thanks

  2. #2
    Super Contributor
    Join Date
    Mar 2003
    Location
    Espoo, Finland
    Posts
    976

    Re: how to make buttons on touch phone

    This is not a form, but on the other hand might give you some ideas how to create and handle "buttons" (as a part of screen area) in touch device:

    http://jouni.miettunen.googlepages.c...hme-lighttouch

    If that's too difficult to read, I could write an example code with visible Options/Exit buttons which I did in e.g. Sweet Memories: http://jouni.miettunen.googlepages.com/sweetmemories (check the second screenshot, that's from 5800)

    Cheers,

    --jouni

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

    Re: how to make buttons on touch phone

    I think I meant canvas instead of form!

    Anyway, here is my code for binding events to buttons on the 5800 screen - when you tap the button areas, something happens!

    Hope it might be useful to someone

    Code:
    import appuifw, audio, e32, key_codes
    
    def draw_state():
        pass
        canvas.clear()
        canvas.text((0,12),u"event",0x008000)
        #audio.say("cleared")
    
    def left(arg):
        audio.say("left")
    
    def right(arg):
        audio.say("right")
    
    def quit(arg):
        audio.say("quit")
        e32.ao_sleep(1)
        lock.signal()    
    
    def callback(event):
        #print event
        #canvas.text((0,12),event,0x008000)
        pass
    
    canvas=appuifw.Canvas(redraw_callback=lambda rect:draw_state())
    
    appuifw.app.screen = 'full'
    appuifw.app.directional_pad = False
    appuifw.app.body=canvas
    
    canvas.bind(key_codes.EButton1Down, left, ((0,0),(360,200)))
    canvas.bind(key_codes.EButton1Down, right, ((0,440),(360,640)))
    canvas.bind(key_codes.EButton1Down, quit, ((160,300),(200,340)))
    
    
    canvas.rectangle(((0,0),(360,200)), fill=(255,0,0))
    canvas.rectangle(((0,440),(360,640)), fill = (0,255,0))
    canvas.rectangle(((160,300),(200,340)), fill = (0,0,255))
    
    lock=e32.Ao_lock()
    appuifw.app.exit_key_handler=lock.signal
    lock.wait()

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

    Re: how to make buttons on touch phone

    hello jtullis

    it will be great if you put a article on the wiki explaining this.

    Regards

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

    Re: how to make buttons on touch phone

    Quote Originally Posted by gaba88 View Post
    hello jtullis

    it will be great if you put a article on the wiki explaining this.

    Regards
    Actually there is already How to use touch events with PyS60 so another article about the same thing would be pointless.

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

    Re: how to make buttons on touch phone

    there is, but it is like 100s of lines long, and very complicated. beginners need something simple, so maybe it is worth doing an example.

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

    Re: how to make buttons on touch phone

    Then perhaps it would be best to add your material to that article as a beginner's tutorial and the long code example would remain an advanced tutorial. That way it's all in one article and easier to find.

Similar Threads

  1. Make Phone To send text only
    By jazzkeme in forum General Development Questions
    Replies: 6
    Last Post: 2009-05-16, 13:41
  2. Menu System(-1) error
    By logan04x in forum Symbian
    Replies: 15
    Last Post: 2009-02-08, 08:57
  3. Replies: 1
    Last Post: 2007-06-05, 10:17
  4. Replies: 7
    Last Post: 2006-03-31, 07:56

Posting Permissions

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