/[thuban]/trunk/thuban/Examples/simple_extensions/simple_command.py
ViewVC logotype

Diff of /trunk/thuban/Examples/simple_extensions/simple_command.py

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 208 by bh, Tue Jul 9 14:57:03 2002 UTC revision 2410 by jan, Sat Nov 20 21:57:43 2004 UTC
# Line 1  Line 1 
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.
# Line 10  Extend thuban with a simple command. Line 11  Extend thuban with a simple command.
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
# Line 37  registry.Add(Command("simple_command", " Line 43  registry.Add(Command("simple_command", "
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

Legend:
Removed from v.208  
changed lines
  Added in v.2410

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26