Python: package rox

rox | index

`To use ROX-Lib2 you need to copy the findrox.py script into your application
directory and import that before anything else. This module will locate
ROX-Lib2 and add ROX-Lib2/python to sys.path. If ROX-Lib2 is not found, it
will display a suitable error and quit.
Since the name of the gtk2 module can vary, it is best to import it from rox,
where it is named 'g'.
The AppRun script of a simple application might look like this:
#!/usr/bin/env python
import findrox; findrox.version(1, 9, 12)
import rox
window = rox.Window()
window.set_title('My window')
window.show()
rox.mainloop()
This program creates and displays a window. The rox.Window widget keeps
track of how many toplevel windows are open. rox.mainloop() will return
when the last one is closed.
'rox.app_dir' is set to the absolute pathname of your application (extracted
from sys.argv).
The builtin names True and False are defined to 1 and 0, if your version of
python is old enough not to include them already.`

Package Contents
`` |  |
AppInfo InfoWin Menu OptionsBox applet basedir choices debug | filer fileutils i18n icon_theme launch loading master_proxy mime | mime_handler options processes proxy saving session settings singleton | su suchild tasks templates thumbnail uri_handler xattr xxmlrpc

Classes
`` |  | exceptions.Exception(exceptions.BaseException) UserAbort gtk.Button(gtk.Bin, gtk.gtk.Activatable) ButtonMixed gtk.Dialog(gtk.Window) Dialog gtk.StatusIcon(gobject._gobject.GObject) StatusIcon gtk.Window(gtk.Bin) Window
class ButtonMixed(gtk.Button)
`` | `A button with a standard stock icon, but any label. This is useful when you want to express a concept similar to one of the stock ones.`
| Methods defined here: __init__(self, stock, message) `Specify the icon and text for the new button. The text may specify the mnemonic for the widget by putting a _ before the letter, eg: button = ButtonMixed(g.STOCK_DELETE, '_Delete message').`
class Dialog(gtk.Dialog)
`` | `This works in exactly the same way as a GtkDialog, except that it calls the toplevel_(un)ref functions for you automatically.`
| Methods defined here: __init__(*args, **kwargs)
class StatusIcon(gtk.StatusIcon)
`` | `Wrap GtkStatusIcon to call toplevel_(un)ref functions for you. Calling toplevel_unref isn't automatic, because a GtkStatusIcon is not a GtkWidget. GtkStatusIcon was added in GTK+ 2.10, so you will need pygtk 2.10 or later to use this class. Check by using import rox if hasattr(rox, 'StatusIcon'): ....`
| Methods defined here: __init__(self, add_ref=True, menu=None, show=True, icon_pixbuf=None, icon_name=None, icon_stock=None, icon_file=None) `Initialise the StatusIcon. add_ref - if True (the default) call toplevel_ref() for this icon and toplevel_unref() when removed. Set to False if you want the main loop to finish if only the icon is present and no other windows menu - if not None then this is the menu to show when the popup-menu signal is received. Alternatively add a handler for then popup-menu signal yourself for more sophisticated menus show - True to show them icon initially, False to start with the icon hidden. icon_pixbuf - image (a gdk.pixbuf) to use as an icon icon_name - name of the icon from the current icon theme to use as an icon icon_stock - name of stock icon to use as an icon icon_file - file name of the image to use as an icon The icon used is selected is the first of (icon_pixbuf, icon_name, icon_stock, icon_file) not to be None. If no icon is given, it is taken from $APP_DIR/.DirIcon, scaled to 22 pixels. NOTE: even if show is set to True, the icon may not be visible if no system tray application is running.` popup_menu(self, icon, button, act_time) `Show the default menu, if one was specified in the constructor.` remove_icon(self) `Hides the icon and drops the top level reference, if it was holding one. This may cause the main loop to exit.`
class UserAbort(exceptions.Exception)
`` | `Raised when the user aborts an operation, eg by clicking on Cancel or pressing Escape.`
| Methods defined here: __init__(self, message=None)
class Window(gtk.Window)
`` | `This works in exactly the same way as a GtkWindow, except that it calls the toplevel_(un)ref functions for you automatically, and sets the window icon to <app_dir>/.DirIcon if it exists.`
| Methods defined here: __init__(*args, **kwargs)

Functions
`` |  | alert(message) `Display message in an error box. Return when the user closes the box.` bug(message='A bug has been detected in this program. Please report the problem to the authors.') `Display an error message and offer a debugging prompt.` confirm(message, stock_icon, action=None) `Display a <Cancel>/<Action> dialog. Result is true if the user chooses the action, false otherwise. If action is given then that is used as the text instead of the default for the stock item. Eg: if rox.confirm('Really delete everything?', g.STOCK_DELETE): delete()` croak(message) `Display message in an error box, then quit the program, returning with a non-zero exit status.` edit_options(options_file=None) `Edit the app_options (set using setup_app_options()) using the GUI specified in 'options_file' (default <app_dir>/Options.xml). If this function is called again while the box is still open, the old box will be redisplayed to the user.` escape(uri) `Convert each space to %20, etc` get_icon(path) `Looks up an icon for the file named by path, in the order below, using the first found: 1. The Filer's globicons file (not implemented) 2. A directory's .DirIcon file 3. A file in ~/.thumbnails whose name is the md5 hash of os.path.abspath(path), suffixed with '.png' 4. A file in $XDG_CONFIG_HOME/rox.sourceforge.net/MIME-Icons for the full type of the file. 5. An icon of the form 'gnome-mime-media-subtype' in the current GTK icon theme. 6. A file in $XDG_CONFIG_HOME/rox.sourceforge.net/MIME-Icons for the 'media' part of the file's type (eg, 'text') 7. An icon of the form 'gnome-mime-media' in the current icon theme. Returns a gtk.gdk.Pixbuf instance for the chosen icon.` get_local_path(uri) `Convert 'uri' to a local path and return, if possible. If 'uri' is a resource on a remote machine, return None. URI is in the escaped form (%20 for space).` info(message) `Display informational message. Returns when the user closes the box.` isappdir(path) `Return True if the path refers to a valid ROX AppDir. The tests are: - path is a directory - path is not world writable - path contains an executable AppRun - path/AppRun is not world writable - path and path/AppRun are owned by the same user.` mainloop() `This is a wrapper around the gtk2.mainloop function. It only runs the loop if there are top level references, and exits when rox.toplevel_unref() reduces the count to zero.` our_host_name() `Try to return the canonical name for this computer. This is used in the drag-and-drop protocol to work out whether a drop is coming from a remote machine (and therefore has to be fetched differently).` report_exception() `Display the current python exception in an error box, returning when the user closes the box. This is useful in the 'except' clause of a 'try' block. Uses rox.debug.show_exception().` setup_app_options(program, leaf='Options.xml', site=None) `Most applications only have one set of options. This function can be used to set up the default group. 'program' is the name of the directory to use and 'leaf' is the name of the file used to store the group. You can refer to the group using rox.app_options. If site is given, the basedir module is used for saving options (the new system). Otherwise, the deprecated choices module is used. See rox.options.OptionGroup.` toplevel_ref() `Increment the toplevel ref count. rox.mainloop() won't exit until toplevel_unref() is called the same number of times.` toplevel_unref(*unused) `Decrement the toplevel ref count. If this is called while in rox.mainloop() and the count has reached zero, then rox.mainloop() will exit. Ignores any arguments passed in, so you can use it easily as a callback function.` unescape(uri) `Convert each %20 to a space, etc`