~ubuntu-branches/ubuntu/lucid/thuban/lucid

« back to all changes in this revision

Viewing changes to Examples/simple_extensions/hello_world.py

  • Committer: Bazaar Package Importer
  • Author(s): Silke Reimer
  • Date: 2004-01-28 12:47:34 UTC
  • Revision ID: james.westby@ubuntu.com-20040128124734-6xotwcqilok6ngut
Tags: upstream-1.0.0
ImportĀ upstreamĀ versionĀ 1.0.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# Copyright (C) 2003 by Intevation GmbH
 
2
# Authors:
 
3
# Jan-Oliver Wagner <jan@intevation.de>
 
4
#
 
5
# This program is free software under the GPL (>=v2)
 
6
# Read the file COPYING coming with Thuban for details.
 
7
 
 
8
"""
 
9
Extend Thuban with a sample Hello World to demonstrate simple
 
10
extensions.
 
11
"""
 
12
 
 
13
__version__ = '$Revision: 1.1 $'
 
14
 
 
15
# use _() already now for all strings that may later be translated
 
16
from Thuban import _
 
17
 
 
18
# Thuban has named commands which can be registered in the central
 
19
# instance registry.
 
20
from Thuban.UI.command import registry, Command
 
21
 
 
22
# The instance of the main menu of the Thuban application
 
23
# See Thuban/UI/menu.py for the API of the Menu class
 
24
from Thuban.UI.mainwindow import main_menu
 
25
 
 
26
def hello_world_dialog(context):
 
27
    """Just raise a simple dialog to greet the world.
 
28
 
 
29
    context -- The Thuban context.
 
30
    """
 
31
    context.mainwindow.RunMessageBox(_('Hello World'), _('Hello World!'))
 
32
 
 
33
 
 
34
# create a new command and register it
 
35
registry.Add(Command('hello_world', _('Hello World'), hello_world_dialog,
 
36
                     helptext = _('Welcome everyone on this planet')))
 
37
 
 
38
# find the extensions menu (create it anew if not found)
 
39
extensions_menu = main_menu.find_menu('extensions')
 
40
if extensions_menu is None:
 
41
    extensions_menu = main_menu.InsertMenu('extensions', _('E&xtensions'))
 
42
 
 
43
# finally bind the new command with an entry in the extensions menu
 
44
extensions_menu.InsertItem('hello_world')