Archived:Using TopWindow in PySymbian
This snippet shows how to use TopWindow class from the topwindow module to show a window on top of other applications in Python.
Display sizes may vary from one device to another. Available sizes can be found by using the display_pixels() function of the sysinfo module.
import appuifw, e32, graphics, topwindow
app_lock = e32.Ao_lock()
#Define the exit function
#Hide the window
appuifw.app.exit_key_handler = quit
#Create an instance of TopWindow
window = topwindow.TopWindow()
#Set its size
window.size = (210, 160)
#Set the position of it upper left corner
window.position = (10, 40)
#Create a new, red image to display
img = graphics.Image.new((195, 110))
#Write text on it
img.text((25, 25), u"This is a pop-up", font = 'title')
#Add it to the window specifying coordinates for its upper left corner
window.add_image(img, (10, 10))
#Make the window's background green
window.background_color = 0x00FF00
#Add a shadow effect
window.shadow = 4
#Make the corners round
window.corner_type = 'corner5'
#Display the window
#Wait for the user to request the exit
A pop-up window containing the specified image and other elements is shown on top of the application that is currently in the foreground.
A TopWindow object also has the visible attribute which can be read in order to determine whether the object is visible, or written (1 for visible, 0 for invisible).