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

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

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

revision 192 by bh, Tue May 28 16:04:49 2002 UTC revision 193 by bh, Wed May 29 10:33:41 2002 UTC
# Line 78  class MainWindow(wxFrame): Line 78  class MainWindow(wxFrame):
78          self.current_id = 6000          self.current_id = 6000
79          self.id_to_name = {}          self.id_to_name = {}
80          self.name_to_id = {}          self.name_to_id = {}
81            self.events_bound = {}
82    
83      def get_id(self, name):      def get_id(self, name):
84          """Return the wxWindows id for the command named name.          """Return the wxWindows id for the command named name.
# Line 91  class MainWindow(wxFrame): Line 92  class MainWindow(wxFrame):
92              self.id_to_name[ID] = name              self.id_to_name[ID] = name
93          return ID          return ID
94    
95        def bind_command_events(self, command, ID):
96            """Bind the necessary events for the given command and ID"""
97            if not self.events_bound.has_key(ID):
98                # the events haven't been bound yet
99                EVT_MENU(self, ID, self.invoke_command)
100                if command.IsDynamic():
101                    EVT_UPDATE_UI(self, ID, self.update_command_ui)
102    
103      def build_menu_bar(self, menudesc):      def build_menu_bar(self, menudesc):
104          """Build and return the menu bar from the menu description"""          """Build and return the menu bar from the menu description"""
105          menu_bar = wxMenuBar()          menu_bar = wxMenuBar()
# Line 157  class MainWindow(wxFrame): Line 166  class MainWindow(wxFrame):
166                  ID = self.get_id(name)                  ID = self.get_id(name)
167                  menu.Append(ID, command.Title(), command.HelpText(),                  menu.Append(ID, command.Title(), command.HelpText(),
168                              command.IsCheckCommand())                              command.IsCheckCommand())
169                  EVT_MENU(self, ID, self.invoke_command)                  self.bind_command_events(command, ID)
                 if command.IsDynamic():  
                     EVT_UPDATE_UI(self, ID, self.update_command_ui)  
170              else:              else:
171                  print "Unknown command %s" % name                  print "Unknown command %s" % name
172    
# Line 181  class MainWindow(wxFrame): Line 188  class MainWindow(wxFrame):
188                  toolbar.AddTool(ID, bitmap,                  toolbar.AddTool(ID, bitmap,
189                                  shortHelpString = command.HelpText(),                                  shortHelpString = command.HelpText(),
190                                  isToggle = command.IsCheckCommand())                                  isToggle = command.IsCheckCommand())
191                    self.bind_command_events(command, ID)
192              else:              else:
193                  print "Unknown command %s" % name                  print "Unknown command %s" % name
194    

Legend:
Removed from v.192  
changed lines
  Added in v.193

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26