Developer Example: Shared Image Viewer
SharedImageViewer is a sample shared application for collaborative viewing of images. One user can load an image into SharedImageViewer, and all other users in the same SharedImageViewer session will download and view the image. This is a very simple shared application written to demonstrate the collaborative facilities included in the Access Grid software.


The SharedImageViewer application in action
The application uses two events to indicate that an image has been and should be loaded, and that an image should be shown.
LOAD_IMAGE
SHOW_IMAGE
The state of the application consists only of images that have been loaded.
imagelist = [ filenames ]
Loads the image files, builds thumbnails, and displays them
Displays the selected image in the main panel
SharedImageViewer is derived from ImageViewer
Overrides ImageViewer methods to extend them
Registers for shared application events
Loads the image files, builds thumbnails, and displays them
Sends a LOAD_IMAGE event
Updates the application state 'imagelist' key
# upload the file to venue
self.dataStoreClient.Upload(f)
# send event notifying others to upload
filename = os.path.basename(f)
self.sharedAppClient.SendEvent(SharedImageViewer.LOAD_IMAGE,filename)
# update the application state
keys= self.sharedAppClient.GetDataKeys()
filelist = map( lambda x: os.path.basename(x), filenames)
if SharedImageViewer.imagelist not in keys:
self.sharedAppClient.SetData(SharedImageViewer.imagelist,filelist)
else:
myfileliststr = self.sharedAppClient.GetData(SharedImageViewer.imagelist)
myfilelist = eval(myfileliststr)
myfilelist += filelist
self.sharedAppClient.SetData(SharedImageViewer.imagelist,myfilelist)
except:
import traceback
traceback.print_exc()
self.log.exception('Error in OnLoad')
Downloads the specified image from the Venue and displays it
Displays the selected image in the main panel
Sends a SHOW_IMAGE event
Displays the specified image
SharedImageViewer requires, as do all shared applications, a pointer to the shared application. Also, because it interacts with the Venue Data Store, it needs the connection id of a client in the Venue. This is passed on the command line when the VenueClient executes SharedImageViewer; for example:
pythonw SharedImageViewer.py -c <connection_id> -a <application URL>
Shared image viewing is a powerful way for remote collaborators to share the results of their work. For scientists and non-scientists alike, being able to trivially display images to remote colleagues facilitates the flow of information and discussion in a way that approximates 'being there'. One could argue that this functionality should actually be integrated directly into the Venue Client.
To be used as a proper shared application, SharedImageViewer requires also a SharedImageViewer.app file, and to be zipped up in a bundle as SharedImageViewer.zip.