1 |
# Copyright (C) 2002 by Intevation GmbH |
# Copyright (C) 2002, 2004 by Intevation GmbH |
2 |
# Authors: |
# Authors: |
3 |
# Bernhard Herzog <[email protected]> |
# Bernhard Herzog <[email protected]> (2002) |
4 |
|
# Jan-Oliver Wagner <[email protected]> (2004) |
5 |
# |
# |
6 |
# This program is free software under the GPL (>=v2) |
# This program is free software under the GPL (>=v2) |
7 |
# Read the file COPYING coming with Thuban for details. |
# Read the file COPYING coming with Thuban for details. |
11 |
""" |
""" |
12 |
|
|
13 |
__version__ = "$Revision$" |
__version__ = "$Revision$" |
14 |
|
# $Source$ |
15 |
|
# $Id$ |
16 |
|
|
17 |
# First import some things we need later. |
# First import some things we need later. |
18 |
import os |
import os |
19 |
from Thuban.UI.command import registry, Command |
from Thuban.UI.command import registry, Command |
20 |
import Thuban.UI.mainwindow |
from Thuban.UI.mainwindow import main_menu |
21 |
|
|
22 |
# a function implementing a command. Such a function is called with one |
# a function implementing a command. Such a function is called with one |
23 |
# argument describing the context in which it is invoked. Currently the |
# argument describing the context in which it is invoked. The context is |
24 |
# context is the mainwindow object. |
# an object with a few public attributes for the application object, the |
25 |
|
# session and the main window. |
26 |
def simple_command(context): |
def simple_command(context): |
27 |
print "simple_command: Main window", context |
print "simple_command: Application", context.application |
28 |
print "simple_command: Map", context.canvas.Map() |
print "simple_command: Session", context.session |
29 |
|
print "simple_command: Main window", context.mainwindow |
30 |
|
print "simple_command: Map", context.mainwindow.canvas.Map() |
31 |
|
|
32 |
# Add the command to the registry. A command is represented by a Command |
# Add the command to the registry. A command is represented by a Command |
33 |
# instance which is instantiated with four parameters here, the name of |
# instance which is instantiated with four parameters here, the name of |
43 |
# Thuban.UI.mainwindow. This object has a few methods to add new menus |
# Thuban.UI.mainwindow. This object has a few methods to add new menus |
44 |
# and menu items. |
# and menu items. |
45 |
# |
# |
46 |
# InsertMenu creates a new submenu in the menu, parameters are its name |
# FindOrInsertMenu creates a new submenu in the menu, parameters are its name |
47 |
# and title which have the same meanings as for a command. The return |
# and title which have the same meanings as for a command. The return |
48 |
# value is a menu object for the new submenu which has the same methods |
# value is a menu object for the new submenu which has the same methods |
49 |
# as main_menu. |
# as main_menu. |
50 |
menu = Thuban.UI.mainwindow.main_menu.InsertMenu("examples", "&Examples") |
# 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") |
53 |
|
|
54 |
# In the new menu we can add new items with InsertItem which takes the |
# In the new menu we can add new items with InsertItem which takes the |
55 |
# name of a command as parameter or with InsertSeparator to add a |
# name of a command as parameter or with InsertSeparator to add a |