App

class rumps.App(name, title=None, icon=None, template=None, menu=None, quit_button='Quit')

Represents the statusbar application.

Provides a simple and pythonic interface for all those long and ugly PyObjC calls. rumps.App may be subclassed so that the application logic can be encapsulated within a class. Alternatively, an App can be instantiated and the various callback functions can exist at module level.

Changed in version 0.2.0: name parameter must be a string and title must be either a string or None. quit_button parameter added.

Parameters:
  • name – the name of the application.
  • title – text that will be displayed for the application in the statusbar.
  • icon – file path to the icon that will be displayed for the application in the statusbar.
  • menu – an iterable of Python objects or pairs of objects that will be converted into the main menu for the application. Parsing is implemented by calling rumps.MenuItem.update().
  • quit_button – the quit application menu item within the main menu. If None, the default quit button will not be added.
icon

A path to an image representing the icon that will be displayed for the application in the statusbar. Can be None in which case the text from title will be used.

Changed in version 0.2.0: If the icon is set to an image then changed to None, it will correctly be removed.

menu

Represents the main menu of the statusbar application. Setting menu works by calling rumps.MenuItem.update().

name

The name of the application. Determines the application support folder name. Will also serve as the title text of the application if title is not set.

open(*args)

Open a file within the application support folder for this application.

app = App('Cool App')
with app.open('data.json') as f:
    pass

Is a shortcut for,

app = App('Cool App')
filename = os.path.join(application_support(app.name), 'data.json')
with open(filename) as f:
    pass
quit_button

The quit application menu item within the main menu. This is a special rumps.MenuItem object that will both replace any function callback with rumps.quit_application() and add itself to the end of the main menu when rumps.App.run() is called. If set to None, the default quit button will not be added.

Warning

If set to None, some other menu item should call rumps.quit_application() so that the application can exit gracefully.

New in version 0.2.0.

run(**options)

Performs various setup tasks including creating the underlying Objective-C application, starting the timers, and registering callback functions for click events. Then starts the application run loop.

Changed in version 0.2.1: Accepts debug keyword argument.

Parameters:debug – determines if application should log information useful for debugging. Same effect as calling rumps.debug_mode().
template

Template mode for an icon. If set to None, the current icon (if any) is displayed as a color icon. If set to True, template mode is enabled and the icon will be displayed correctly in dark menu bar mode.

title

The text that will be displayed for the application in the statusbar. Can be None in which case the icon will be used or, if there is no icon set the application text will fallback on the application name.

Changed in version 0.2.0: If the title is set then changed to None, it will correctly be removed. Must be either a string or None.