Yes, using the keypress extension. Just simulate the red (hang-up) key after telling Python not to close when this happens. Here's an example:
Code:
import appuifw, e32, keypress, sys
from key_codes import *
#Create an active object
app_lock = e32.Ao_lock()
#Define the function to be called when the right softkey is pressed
def quit():
app_lock.signal()
appuifw.app.set_exit()
appuifw.app.exit_key_handler = quit
#Define the function to be called when the red key is simulated
def myexitfunc():
s = appuifw.app.screen
appuifw.app.screen = 'large'
appuifw.app.screen = s
app_lock.wait()
#Set it as the red key's function
sys.exitfunc = myexitfunc
#Your code goes here. For example, an instance of Text
appuifw.app.body = appuifw.Text(u"abc")
#Wait 4 seconds
e32.ao_sleep(4)
#Simulate the red key
keypress.send_raw_event(keypress.EKeyDown,EScancodeNo)
keypress.send_raw_event(keypress.EKeyUp,EScancodeNo)
The first 3 lines in myexitfunc's definition are there to make sure the application looks normal when brought back to the foreground. The information on the title pane would be missing without them. See this post for more about this.
Still, appswitch is a lot better than doing all that