×

Discussion Board

Results 1 to 9 of 9
  1. #1
    Registered User
    Join Date
    Dec 2004
    Posts
    12

    Question Graphics in background Python processes?

    Hi.

    I'm trying to draw in a background python process.

    In API reference, graphics module, it says:

    "The module is usable from both graphical Python applications and background Python processes."

    But I don't know how to do this. I'm trying launching a script like:

    Code:
    while running:
    
      e32.ao_sleep(3)
    
      canvas=Canvas()
      app.body=canvas
      drc=Draw(canvas)
    
      drc.line((30,40),(100,40),outline=0,fill=0)
    
      e32.ao_yield()
    This draw a simple line each 3 seconds, but only if the script launched is active. If I send it to background (using mobile task key), I see nothing.

    Perhaps this is'nt the correct way for launching a background process, but I do'nt know any other way...

    I need to draw some text from a background process to the mobile main screen, as I have seen in others pure symbian apps.

    Any idea?

    Thanks in advance.

    Using python 1.1.6 over Nokia 7610

  2. #2
    Super Contributor
    Join Date
    Dec 2004
    Posts
    643

    Re: Graphics in background Python processes?

    The reference to background processes refers to processes started with e32.start_server, not normal applications that are just temporarily not visible.

    There is currently no way to draw onto the screen from Python if the application is not visible.

  3. #3
    Super Contributor
    Join Date
    Dec 2004
    Posts
    643

    Re: Graphics in background Python processes?

    A clarification: You can of course any time draw to an in-memory Image and blit it onto the screen when your application returns to the foreground. See the redraw_callback parameter of Canvas.

  4. #4
    Registered User
    Join Date
    Dec 2004
    Posts
    12

    Re: Graphics in background Python processes?

    OK, thanks for the answer.

    I'm thinking on some way to draw to one image, save it, and set that image as wallpaper... I don't need much refresh rate.

    Other solution could be activate the background application from code when some event occurs, showing the new info...

    But I don't know if any of these solutions are possible.

  5. #5
    Registered User
    Join Date
    Jan 2008
    Posts
    3

    Re: Graphics in background Python processes?

    I'm also interested in creating applications that draw to the phone's main screen.

    (I would hope the finished application, once installed from a SIS, would be run from the menu, and simply disappear -- except for drawing on the phone's main screen -- until the process was ended by a utility or turning the phone off. Or perhaps it could have a configuration screen, also!)

    This might not have been possible back in 2005. Does anyone know if Python for S60 is capable of this now?

    Many thanks.

  6. #6
    Regular Contributor
    Join Date
    Sep 2005
    Location
    Finland, Helsinki
    Posts
    323

    Re: Graphics in background Python processes?

    Quote Originally Posted by jasher0 View Post
    I'm also interested in creating applications that draw to the phone's main screen.

    I would hope the finished application, once installed from a SIS, would be run from the menu, and simply disappear -- except for drawing on the phone's main screen --
    Topwindow seems to draw to the screen in some situations even when the application is in the background.

    At least this seems to work. Upload it into your phone's \\python-directory, run it and switch it to background by pressing "application" key. "The counter" remains on the screen. Tested with E70. (BTW, there is no visible topwindow in E70 when keyboard is opened -> screen orientation is horizontal.)

    Code:
    import TopWindow
    global splash
    
    splash = TopWindow.TopWindow()
    splash.size = (200,100)
    splash.position = (5,100)
    splash.shadow = 3
    splash.visible = 1
    splash.corner_type = 'corner2'
    splash.background_color = 0xcccccc
    splash.show()
    import graphics
    import e32
    import appuifw
    
    def splash_text(text):
        im = graphics.Image.new((200,100))
        im.text((5,90),text, 0x000000)
        splash.add_image(im, (0,0))
        #e32.ao_sleep(0.01)
    
    def quit():  
        app_lock.signal()  
    
    appuifw.app.exit_key_handler = quit
    app_lock = e32.Ao_lock()
    
    for i in range(10):
        splash_text(u"%d" % (i))
        e32.ao_sleep(1)
    
    app_lock.wait()
    splash.hide()
    Last edited by aaaaapo; 2008-01-14 at 06:59. Reason: Added code example

  7. #7
    Registered User
    Join Date
    Jan 2008
    Posts
    3

    Re: Graphics in background Python processes?

    Thanks, aaaaapo. This is useful. I had a similar concept script going.

    I think the main thing now is to determine whether it's possible to access the "true desktop" of the phone (sorry, I don't know the proper name for this). In other words, to write an application that functions in a similar way to Active Standby.

    Searching the forums, it seems there's talk of an undocumented Active Standby plugin API. Being able to extend Active Standby (with or without Python) would be really useful.

    --edit: seems that such plugins are only available for E-series phones.
    Check: http://nseries-mobile.blogspot.com/2...y-plugins.html
    This page directs users to a wishlist for plugins on standard S60 handsets:
    http://www.s60.com/life/wishlist/dis...0&activeCat=-2
    --

    Any thoughts on this?

    Thanks.

  8. #8
    Regular Contributor
    Join Date
    Apr 2004
    Posts
    107

    Re: Graphics in background Python processes?

    Quote Originally Posted by aaaaapo View Post
    Topwindow seems to draw to the screen in some situations even when the application is in the background.

    At least this seems to work. Upload it into your phone's \\python-directory, run it and switch it to background by pressing "application" key. "The counter" remains on the screen. Tested with E70. (BTW, there is no visible topwindow in E70 when keyboard is opened -> screen orientation is horizontal.)

    Code:
    import TopWindow
    global splash
    
    splash = TopWindow.TopWindow()
    splash.size = (200,100)
    splash.position = (5,100)
    splash.shadow = 3
    splash.visible = 1
    splash.corner_type = 'corner2'
    splash.background_color = 0xcccccc
    splash.show()
    import graphics
    import e32
    import appuifw
    
    def splash_text(text):
        im = graphics.Image.new((200,100))
        im.text((5,90),text, 0x000000)
        splash.add_image(im, (0,0))
        #e32.ao_sleep(0.01)
    
    def quit():  
        app_lock.signal()  
    
    appuifw.app.exit_key_handler = quit
    app_lock = e32.Ao_lock()
    
    for i in range(10):
        splash_text(u"%d" % (i))
        e32.ao_sleep(1)
    
    app_lock.wait()
    splash.hide()
    Hmm, is this the right way? When I change range to 1000 and decrease sleep to 0.01 in this example I get a system error after 550 cycles. Is it good to add always an image to topwindow without removing them? What a about memory usage?

    I also need an updating text in a topwindow, but my app crashes after 30 cycles, because I load jpg image. How to do it proper?
    Last edited by carknue; 2008-07-21 at 20:51.
    PyNetMony - the ultimate War- and BlueWalking tool and 2G/3G Netmonitor
    http://pynetmony.googlepages.com/home

  9. #9
    Regular Contributor
    Join Date
    Sep 2005
    Location
    Finland, Helsinki
    Posts
    323

    Re: Graphics in background Python processes?

    Quote Originally Posted by carknue View Post
    Hmm, is this the right way? When I change range to 1000 and decrease sleep to 0.01 in this example I get a system error after 550 cycles. Is it good to add always an image to topwindow without removing them? What a about memory usage?

    I also need an updating text in a topwindow, but my app crashes after 30 cycles, because I load jpg image. How to do it proper?
    There seems to happen something strange if splash update count exceeds about 100 (in emulator). Update cycle gets slower and slower even if the image instance is reused.

    I update "the splash screen" in my apps only about 10-20 times, so I have no crashing experiences.

    Perhaps this is a bug in TopWindow? I've no time to examine this better in the near future.

Similar Threads

  1. A Graphics API for Python for Series 60
    By nbsinner in forum Symbian
    Replies: 4
    Last Post: 2005-04-13, 18:44
  2. Background Processes
    By ask@nokia in forum Mobile Java General
    Replies: 1
    Last Post: 2004-06-23, 07:36
  3. BackGround Processes & Push Registry
    By isseyp in forum Mobile Java General
    Replies: 0
    Last Post: 2004-05-09, 06:36
  4. Using the Graphics object outside of paint()?
    By weedy in forum Mobile Java General
    Replies: 4
    Last Post: 2003-06-06, 10:03
  5. is there anyway to create a background graphics?
    By alexwei in forum Mobile Java General
    Replies: 1
    Last Post: 2003-02-27, 08:57

Posting Permissions

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