You Are Here:

Community: Developer Discussion Boards

#1 Old Question Graphics in background Python processes? - 2005-09-15, 23:03

Join Date: Dec 2004
Posts: 12
canopus961
Offline
Registered User
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
Reply With Quote

#2 Old Re: Graphics in background Python processes? - 2005-09-17, 01:29

Join Date: Dec 2004
Posts: 646
jplauril's Avatar
jplauril
Offline
Forum Nokia Expert
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.
Reply With Quote

#3 Old Re: Graphics in background Python processes? - 2005-09-20, 10:11

Join Date: Dec 2004
Posts: 646
jplauril's Avatar
jplauril
Offline
Forum Nokia Expert
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.
Reply With Quote

#4 Old Re: Graphics in background Python processes? - 2005-09-20, 22:30

Join Date: Dec 2004
Posts: 12
canopus961
Offline
Registered User
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.
Reply With Quote

#5 Old Re: Graphics in background Python processes? - 2008-01-14, 00:30

Join Date: Jan 2008
Posts: 3
jasher0
Offline
Registered User
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.
Reply With Quote

#6 Old Re: Graphics in background Python processes? - 2008-01-14, 07:27

Join Date: Sep 2005
Posts: 314
Location: Finland, Helsinki
aaaaapo
Offline
Regular Contributor
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 07:59. Reason: Added code example
Reply With Quote

#7 Old Re: Graphics in background Python processes? - 2008-01-15, 00:39

Join Date: Jan 2008
Posts: 3
jasher0
Offline
Registered User
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.
Reply With Quote

#8 Old Re: Graphics in background Python processes? - 2008-07-21, 21:44

Join Date: Apr 2004
Posts: 107
Send a message via ICQ to carknue
carknue
Offline
Regular Contributor
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?


PyNetMony - the ultimate War- and BlueWalking tool and 2G/3G Netmonitor
http://pynetmony.googlepages.com/home
Last edited by carknue : 2008-07-21 at 21:51.
Reply With Quote

#9 Old Re: Graphics in background Python processes? - 2008-07-21, 22:31

Join Date: Sep 2005
Posts: 314
Location: Finland, Helsinki
aaaaapo
Offline
Regular Contributor
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.
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
A Graphics API for Python for Series 60 nbsinner Python 4 2005-04-13 19:44
Background Processes ask@nokia Mobile Java General 1 2004-06-23 08:36
BackGround Processes & Push Registry isseyp Mobile Java General 0 2004-05-09 07:36
Using the Graphics object outside of paint()? weedy Mobile Java General 4 2003-06-06 11:03
is there anyway to create a background graphics? alexwei Mobile Java General 1 2003-02-27 09:57

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