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

« back to all changes in this revision

Viewing changes to Examples/simple_extensions/simple_command.py

  • Committer: Bazaar Package Importer
  • Author(s): Francesco Paolo Lovergine
  • Date: 2007-04-07 21:03:28 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20070407210328-9a20n4dmbim3c3yc
Tags: 1.2.0-1
* New upstream release.
* Patchset updated.
* Policy bumped to 3.7.2 (no changes).
* Updated for current Python Policy by using python-support.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2002 by Intevation GmbH
 
1
# Copyright (C) 2002, 2004 by Intevation GmbH
2
2
# Authors:
3
 
# Bernhard Herzog <bh@intevation.de>
 
3
# Bernhard Herzog <bh@intevation.de> (2002)
 
4
# Jan-Oliver Wagner <jan@intevation.de> (2004)
4
5
#
5
6
# This program is free software under the GPL (>=v2)
6
7
# Read the file COPYING coming with Thuban for details.
9
10
Extend thuban with a simple command.
10
11
"""
11
12
 
12
 
__version__ = "$Revision: 1.2 $"
 
13
__version__ = "$Revision: 2410 $"
 
14
# $Source$
 
15
# $Id: simple_command.py 2410 2004-11-20 21:57:43Z jan $
13
16
 
14
17
# First import some things we need later.
15
18
import os
16
19
from Thuban.UI.command import registry, Command
17
 
import Thuban.UI.mainwindow
 
20
from Thuban.UI.mainwindow import main_menu
18
21
 
19
22
# a function implementing a command. Such a function is called with one
20
23
# argument describing the context in which it is invoked. The context is
40
43
# Thuban.UI.mainwindow. This object has a few methods to add new menus
41
44
# and menu items.
42
45
#
43
 
# InsertMenu creates a new submenu in the menu, parameters are its name
 
46
# FindOrInsertMenu creates a new submenu in the menu, parameters are its name
44
47
# and title which have the same meanings as for a command. The return
45
48
# value is a menu object for the new submenu which has the same methods
46
49
# as main_menu.
47
 
menu = Thuban.UI.mainwindow.main_menu.InsertMenu("examples", "&Examples")
 
50
# If the menu already exist, this previous one will be returned an
 
51
# no new one be created.
 
52
menu = main_menu.FindOrInsertMenu("examples", "&Examples")
48
53
 
49
54
# In the new menu we can add new items with InsertItem which takes the
50
55
# name of a command as parameter or with InsertSeparator to add a