Archive

Posts Tagged ‘grail interface’

Interfacing in grail application

October 18th, 2008

Grail applets can access certain objects in the Grail application through special attributes of the master argument passed to every applet instance. The most important objects are the App, the Browser, the Viewer, and the Context. The App object represents the entire Grail application, and contains information shared bewteen all browsers. The Browser object represents a top-level browser window. The Viewer object represents a viewer window. Often, there will be one viewer per browser, but when frame sets or tables are used, there may be several subviewers within the same browser. The Context object, finally, represents an intermediate level. Viewer objects representing table cells share their context with the Viewer object containing the table; however Viewer objects representing a frame have their own context (since each frame displays a separate URL).

grail_app
The Application object. Methods:
.get_cache_keys()
Return a list of URLs that are currently in Grail’s cache.

Instance variables:

.global_history
An object representing Grail’s global history (the set of URLs you have visited). Methods:
.remember_url(url [, title])
Add a URL to the global history, optionally with a given title.
.lookup_url(url)
Return a tuple (title, timestamp) representing the information in the global history about the given URL. If the URL is not known, return (None, None).
.inhistory_p(url)
Return true or false depending whether the given URL is in the global history.
.urls()
Return a list of all URLs currently in the global history.
grail_context
The Context object for the applet. Methods:
.get_baseurl([url, ...])
Return the base URL for the current document. If one or more URL arguments are give, resolves the first one relative to the base URL, the second one relative to the first one, and so on, and return the final result. Empty URLs are ignored.
.load(url)
Load the given URL into the context’s viewer, replacing its current contents. Careful: this will usually cause the current applet to be deleted!
.follow(url)
Like .load(url), but interprets the URL relative to the current document’s base URL.
.message(string)
Display a message in the document’s message area.
.get_async_image(url)
Return an “asynchronous image object”. This is a subclass of a Tkinter PhotoImage which will eventually be loaded with the image whose URL is given. Image objects are shared and should be considered read-only.
grail_browser
The Browser object for the applet. A description of the Browser object may be found in The Browser Object Interface in Grail.

grail_viewer
The Viewer object containing the applet. A description of the Viewer object may be found in The Viewer Object Interface in Grail.

Browsers security ,