/[thuban]/branches/WIP-pyshapelib-bramz/Thuban/UI/command.py
ViewVC logotype

Diff of /branches/WIP-pyshapelib-bramz/Thuban/UI/command.py

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

revision 6 by bh, Tue Aug 28 15:41:52 2001 UTC revision 2700 by dpinte, Mon Sep 18 14:27:02 2006 UTC
# Line 1  Line 1 
1  # Copyright (C) 2001 by Intevation GmbH  # Copyright (C) 2001, 2002 by Intevation GmbH
2  # Authors:  # Authors:
3  # Bernhard Herzog <[email protected]>  # Bernhard Herzog <[email protected]>
4  #  #
# Line 26  class Command: Line 26  class Command:
26      """      """
27      Represent a single command.      Represent a single command.
28    
29      A is identified by a name, it has a title (used in menu items and      A command is identified by a name, it has a title (used in menu
30      buttons, etc) and a callable object that can be invoked with the      items and buttons, etc) and a callable object that can be invoked
31      context as a single parameter. The context is currently the      with the context as a single parameter. The context is an object
32      mainwindow object.      with a few public attributes for the application object, the session
33        and the main window.
34    
35      Additionally, a command may have functions that can determine      Additionally, a command may have functions that can determine
36      whether the command can be invoked or whether it is checked in case      whether the command can be invoked or whether it is checked in case
37      of a toggled command. These functions are called with just the      of a toggled command. These functions are called with just the
38      context as parameters.      context as parameters.
39      """      """
40        
41      args = ()      args = ()
42      kwargs = None      kwargs = None
43      sensitive  = None      sensitive  = None
# Line 103  class Command: Line 104  class Command:
104                  or self.checked is not None                  or self.checked is not None
105                  or self.dyntext is not None)                  or self.dyntext is not None)
106    
107        def IsTool(self):
108            """Return whether the command represents a tool.
109    
110            This default implementation always returns 0.
111            """
112            return 0
113    
114      def Execute(self, context, args = ()):      def Execute(self, context, args = ()):
115          kw = self.kwargs          kw = self.kwargs
116          if kw is None:          if kw is None:
# Line 112  class Command: Line 120  class Command:
120          #print self.name, self.args, args          #print self.name, self.args, args
121          apply(self.function, (context,) + self.args + args, kw)          apply(self.function, (context,) + self.args + args, kw)
122    
123    class ToolCommand(Command):
124    
125        """A command tool activating a tool"""
126    
127        def IsTool(self):
128            """Return whether the command represents a tool, i.e. always 1"""
129            return 1
130    
131    
132  class CommandRegistry:  class CommandRegistry:
133    

Legend:
Removed from v.6  
changed lines
  Added in v.2700

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26