/[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 183 by bh, Thu May 23 14:59:11 2002 UTC revision 2700 by dpinte, Mon Sep 18 14:27:02 2006 UTC
# Line 28  class Command: Line 28  class Command:
28    
29      A command is identified by a name, it has a title (used in menu      A command is identified by a name, it has a title (used in menu
30      items and buttons, etc) and a callable object that can be invoked      items and buttons, etc) and a callable object that can be invoked
31      with the 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.183  
changed lines
  Added in v.2700

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26