Example #1
0
 def addImages(self):
   self.il = wxImageList(16,16)
   self.societyImage   = self.il.Add(images.getSocietyBitmap())
   self.hostImage      = self.il.Add(images.getHostBitmap())
   self.nodeImage      = self.il.Add(images.getNodeBitmap())
   self.agentImage     = self.il.Add(images.getAgentBitmap())
   self.componentImage = self.il.Add(images.getComponentBitmap())
   self.argumentImage  = self.il.Add(images.getArgumentBitmap())
   self.questionImage  = self.il.Add(images.getQuestionBitmap())
   self.SetImageList(self.il)
Example #2
0
  def __init__( self, parent, frame, log ):
    wx.Panel.__init__( self, parent, -1 )
    self.log = log
    sizer = rcs.RowColSizer()
    self.frame = frame # top-level frame that contains this wx.Panel
    self.frame.societyOpen = 0
    self.infoFrameOpen = 0
    self.societyFile = None
    self.frame.societyFile = None
    self.itemGrabbed = False
### static controls:

    btnBox = wx.BoxSizer(wx.HORIZONTAL)

    self.openSocietyButton = wx.Button(self, 10, "Open Society")
#    EVT_BUTTON(self, 10, self.OnOpenSociety)
    self.Bind(wx.EVT_BUTTON, self.OnOpenSociety, self.openSocietyButton) 
    self.openSocietyButton.SetBackgroundColour(wx.BLUE)
    self.openSocietyButton.SetForegroundColour(wx.WHITE)
    self.openSocietyButton.SetDefault()
    btnBox.Add(self.openSocietyButton, flag=wx.ALIGN_CENTER_VERTICAL | wx.BOTTOM, border=20)

    self.saveSocietyButton = wx.Button(self, 20, "Save Society")
#    EVT_BUTTON(self, 20, self.OnSaveSociety)
    self.Bind(wx.EVT_BUTTON, self.OnSaveSociety, self.saveSocietyButton) 

    self.saveSocietyButton.Enable(False)
    btnBox.Add(self.saveSocietyButton, flag=wx.ALIGN_CENTER_VERTICAL | wx.LEFT | wx.BOTTOM, border=20)

    self.closeSocietyButton = wx.Button(self, 15, "Close Society")
#    EVT_BUTTON(self, 15, self.OnCloseSociety)
    self.Bind(wx.EVT_BUTTON, self.OnCloseSociety, self.closeSocietyButton) 
    self.closeSocietyButton.Enable(False)
    btnBox.Add(self.closeSocietyButton, flag=wx.ALIGN_CENTER_VERTICAL | wx.LEFT | wx.BOTTOM, border=20)

    nextHighlightBtnId = wx.NewId()
    self.nextHighlightButton = wx.Button(self, nextHighlightBtnId, "Next Highlight")
#    EVT_BUTTON(self, nextHighlightBtnId, self.OnShowNextHighlight)
    self.Bind(wx.EVT_BUTTON, self.OnShowNextHighlight, self.nextHighlightButton) 
    self.nextHighlightButton.Enable(False)
    btnBox.Add(self.nextHighlightButton, flag=wx.ALIGN_CENTER_VERTICAL | wx.LEFT | wx.BOTTOM, border=20)

    self.getHnaMapButton = wx.Button(self, 25, "Get HNA Map")
#    EVT_BUTTON(self, 25, self.OnGetHnaMap)
    self.Bind(wx.EVT_BUTTON, self.OnGetHnaMap, self.getHnaMapButton) 
    self.getHnaMapButton.Enable(False)
    btnBox.Add(self.getHnaMapButton, flag=wx.ALIGN_CENTER_VERTICAL | wx.LEFT | wx.BOTTOM, border=20)

    sizer.Add(btnBox, pos=(1,1),  flag=wx.ALIGN_LEFT|wx.ALIGN_CENTER_VERTICAL)

    lesImages = [gizmoImages.catalog[i].getBitmap() for i in gizmoImages.index]
    self.gizmo = Gizmo(self, -1, lesImages, size=(36, 36), frameDelay = 0.1)
#    EVT_UPDATE_SOCIETY(self, self.OnUpdate)
    self.Bind(EVT_UPDATE_SOCIETY, self.OnUpdate)
    sizer.Add(self.gizmo, pos=(1,2), flag=wx.BOTTOM | wx.ALIGN_RIGHT, border=20)

    self.il = wx.ImageList(16,16)
    self.societyImage   = self.il.Add(images.getSocietyBitmap())
    self.hostImage      = self.il.Add(images.getHostBitmap())
    self.nodeImage      = self.il.Add(images.getNodeBitmap())
    self.agentImage     = self.il.Add(images.getAgentBitmap())
    self.componentImage = self.il.Add(images.getComponentBitmap())
    self.argumentImage  = self.il.Add(images.getArgumentBitmap())
    self.questionImage  = self.il.Add(images.getQuestionBitmap())

    tID = wx.NewId()
    self.frame.societyViewer = SocietyViewer(self, tID, 'societyViewer', size=(240, 100),
                               style=wx.TR_HAS_BUTTONS | wx.TR_EDIT_LABELS | wx.TR_MULTIPLE,
                               log=self.log)
    sizer.Add(self.frame.societyViewer, flag=wx.EXPAND, pos=(2,1), colspan=2)
    dropTarget = CougaarDropTarget(self.frame.societyViewer, self.log, self.frame, True)
    self.frame.societyViewer.SetDropTarget(dropTarget)

### Event handlers for various
#    EVT_TREE_END_LABEL_EDIT(self, tID, self.OnEndLabelEdit) #fired by call to wx.TreeCtrl.EditLabel()
    self.Bind(wx.EVT_TREE_END_LABEL_EDIT, self.OnEndLabelEdit, self.frame.societyViewer)
#    EVT_TREE_SEL_CHANGED    (self, tID, self.OnSelChanged)
    self.Bind(wx.EVT_TREE_SEL_CHANGED, self.OnSelChanged,  self.frame.societyViewer)
#    EVT_TREE_SEL_CHANGING(self, tID, self.OnSelChanging)
    self.Bind(wx.EVT_TREE_SEL_CHANGING, self.OnSelChanging,  self.frame.societyViewer)
#    EVT_RIGHT_DOWN(self.frame.societyViewer, self.OnRightClick)  # emits a wx.MouseEvent
#    self.Bind(wx.EVT_RIGHT_DOWN, self.OnRightClick,  self.frame.societyViewer)
    self.frame.societyViewer.Bind(wx.EVT_RIGHT_DOWN, self.OnRightClick)
#    EVT_RIGHT_UP(self.frame.societyViewer, self.OnRightUp)  # emits a wx.MouseEvent
#    self.Bind(wx.EVT_RIGHT_UP, self.OnRightUp,  self.frame.societyViewer)
    self.frame.societyViewer.Bind(wx.EVT_RIGHT_UP, self.OnRightUp)
#    EVT_LEFT_DOWN(self.frame.societyViewer, self.OnLeftDown)  # emits a wx.MouseEvent
    self.Bind(wx.EVT_LEFT_DOWN, self.OnLeftDown,  self.frame.societyViewer)
#    EVT_LEFT_UP(self.frame.societyViewer, self.OnLeftUp)  # emits a wx.MouseEvent
    self.Bind(wx.EVT_LEFT_UP, self.OnLeftUp,  self.frame.societyViewer)
#    EVT_MOTION(self.frame.societyViewer, self.OnMotion)  # emits a wx.MouseEvent
    self.Bind(wx.EVT_MOTION, self.OnMotion,  self.frame.societyViewer)
###

    self.bg_bmp = images.getGridBGBitmap()
#    EVT_ERASE_BACKGROUND(self, self.OnEraseBackground)
    self.Bind(wx.EVT_ERASE_BACKGROUND, self.OnEraseBackground)
    sizer.AddSpacer(10,10, pos=(1,3)) # adds a constant size space along the right edge
    sizer.AddSpacer(10,10, pos=(3,1)) # adds a constant size space along the bottom
    sizer.AddGrowableCol(1) # makes rule styled text box and Society Viewer expand to the right on window resize
    sizer.AddGrowableRow(2) # makes Society Viewer expand downward on window resize

    self.SetSizer(sizer)
    self.SetAutoLayout(True)
Example #3
0
  def SetMenu(self):

    tID1 = 0
    tID2 = 1
    tID3 = 2
    tID4 = 3
    tID5 = 4
    tID6 = 5
    tID7 = 6
    tID8 = 7
    tID9 = 8
    tID10 = 9
    tID11 = 10
    tID12 = 11
    tID13 = 12
    tID14 = 13
    tID15 = 14
    tID16 = 15
    tID17 = 16
    tID18 = 17
    tID19 = 18
    tID20 = 19
    tID21 = 20
    tID22 = 21
    tID23 = 22
    tID24 = 23
    tID25 = 24

    menu = wx.Menu()

    if self.frame.societyViewer.isEmptyTree():
      item = wx.MenuItem(menu, tID24, "Open Society")
      item.SetBitmap(images.getSocietyBitmap())
      menu.AppendItem(item)
      item = wx.MenuItem(menu, tID25, "Create New Society")
      item.SetBitmap(images.getSocietyBitmap())
      menu.AppendItem(item)
#      EVT_MENU(self, tID24, self.OnOpenSociety)
      self.Bind(wx.EVT_MENU, output.OnOpenSociety, id=tID24)
#      EVT_MENU(self, tID25, self.OnCreateSociety)
      self.Bind(wx.EVT_MENU, output.OnCreateSociety, id=tID25)
      return menu

    if isinstance(self.entityObj, Society):
      # we either want to add a host or delete the society and all its subs.
      item = wx.MenuItem(menu, tID1, "Add Host")
      item.SetBitmap(images.getHostBitmap())
      menu.AppendItem(item)
      item = wx.MenuItem(menu, tID2, "Delete This Society")
      item.SetBitmap(images.getSocietyBitmap())
      menu.AppendItem(item)
      item = wx.MenuItem(menu, tID3, "Rename Society")
      item.SetBitmap(images.getSocietyBitmap())
      menu.AppendItem(item)
#      EVT_MENU(self, tID1, self.OnAddHost)
      self.Bind(wx.EVT_MENU, self.OnAddHost, id=tID1)
#      EVT_MENU(self, tID2, self.OnDeleteSociety)
      self.Bind(wx.EVT_MENU, self.OnDeleteSociety, id=tID2)
#      EVT_MENU(self, tID3, self.OnRename)
      self.Bind(wx.EVT_MENU, self.OnRename, id=tID3)
      return menu

    if isinstance(self.entityObj, Host):
      # we either want to add a node or delete the host and all its subs.
      item = wx.MenuItem(menu, tID4, "Add Node")
      item.SetBitmap(images.getNodeBitmap())
      menu.AppendItem(item)
      item = wx.MenuItem(menu, tID5, "Delete This Host")
      item.SetBitmap(images.getHostBitmap())
      menu.AppendItem(item)
      item = wx.MenuItem(menu, tID6, "Rename Host")
      item.SetBitmap(images.getHostBitmap())
      menu.AppendItem(item)
      item = wx.MenuItem(menu, tID23, "View/Edit Info")
      item.SetBitmap(images.getHostBitmap())
      menu.AppendItem(item)
#      EVT_MENU(self, tID4, self.OnAddNode)
      self.Bind(wx.EVT_MENU, self.OnAddNode, id=tID4)
#      EVT_MENU(self, tID5, self.OnDeleteEntity)
      self.Bind(wx.EVT_MENU, self.OnDeleteEntity, id=tID5)
#      EVT_MENU(self, tID6, self.OnRename)
      self.Bind(wx.EVT_MENU, self.OnRename, id=tID6)
#      EVT_MENU(self, tID23, self.OnEditNodeInfo)
      self.Bind(wx.EVT_MENU, self.OnEditNodeInfo, id=tID23)
      return menu

    if isinstance(self.entityObj, Node):
      # we either want to add a agent or delete the node and all its subs.
      item = wx.MenuItem(menu, tID7, "Add Agent")
      item.SetBitmap(images.getAgentBitmap())
      menu.AppendItem(item)
      item = wx.MenuItem(menu, tID8, "Delete This Node")
      item.SetBitmap(images.getNodeBitmap())
      menu.AppendItem(item)
      item = wx.MenuItem(menu, tID9, "Rename Node")
      item.SetBitmap(images.getNodeBitmap())
      menu.AppendItem(item)
      item = wx.MenuItem(menu, tID10, "View/Edit Info")
      item.SetBitmap(images.getNodeBitmap())
      menu.AppendItem(item)
#      EVT_MENU(self, tID7, self.OnAddAgent)
      self.Bind(wx.EVT_MENU, self.OnAddAgent, id=tID7)
#      EVT_MENU(self, tID8, self.OnDeleteEntity)
      self.Bind(wx.EVT_MENU, self.OnDeleteEntity, id=tID8)
#      EVT_MENU(self, tID9, self.OnRename)
      self.Bind(wx.EVT_MENU, self.OnRename, id=tID9)
#      EVT_MENU(self, tID10, self.OnEditNodeInfo)
      self.Bind(wx.EVT_MENU, self.OnEditNodeInfo, id=tID10)      
#      EVT_MENU(self, tID22, self.OnAddComponent)
      self.Bind(wx.EVT_MENU, self.OnAddComponent, id=tID22)
      return menu

    if isinstance(self.entityObj, Agent):
      # we either want to add a component or delete the agent and all its subs.
      item = wx.MenuItem(menu, tID11, "Add Component")
      item.SetBitmap(images.getComponentBitmap())
      menu.AppendItem(item)
      item = wx.MenuItem(menu, tID12, "Delete This Agent")
      item.SetBitmap(images.getAgentBitmap())
      menu.AppendItem(item)
      item = wx.MenuItem(menu, tID13, "Rename Agent")
      item.SetBitmap(images.getAgentBitmap())
      menu.AppendItem(item)
      if self.entityObj == self.entityObj.parent.nodeAgent:
        item.Enable(False)
      item = wx.MenuItem(menu, tID14, "View/Edit Info")
      item.SetBitmap(images.getAgentBitmap())
      menu.AppendItem(item)
#      EVT_MENU(self, tID11, self.OnAddComponent)
      self.Bind(wx.EVT_MENU, self.OnAddComponent, id=tID11)
#      EVT_MENU(self, tID12, self.OnDeleteEntity)
      self.Bind(wx.EVT_MENU, self.OnDeleteEntity, id=tID12)      
#      EVT_MENU(self, tID13, self.OnRename)
      self.Bind(wx.EVT_MENU, self.OnRename, id=tID13)
#      EVT_MENU(self, tID14, self.OnEditNodeInfo)
      self.Bind(wx.EVT_MENU, self.OnEditNodeInfo, id=tID14)
      return menu

    if isinstance(self.entityObj, Component):
      # we either want to add a argument or delete the component and all its subs.
      item = wx.MenuItem(menu, tID15, "Add Argument")
      item.SetBitmap(images.getArgumentBitmap())
      menu.AppendItem(item)
      item = wx.MenuItem(menu, tID16, "Delete This Component")
      item.SetBitmap(images.getComponentBitmap())
      menu.AppendItem(item)
      item = wx.MenuItem(menu, tID17, "Rename Component")
      item.SetBitmap(images.getComponentBitmap())
      menu.AppendItem(item)
      item = wx.MenuItem(menu, tID18, "View/Edit Info")
      item.SetBitmap(images.getComponentBitmap())
      menu.AppendItem(item)
#      EVT_MENU(self, tID15, self.OnAddArgument)
      self.Bind(wx.EVT_MENU, self.OnAddArgument, id=tID15)
#      EVT_MENU(self, tID16, self.OnDeleteEntity)
      self.Bind(wx.EVT_MENU, self.OnDeleteEntity, id=tID16)
#      EVT_MENU(self, tID17, self.OnRename)
      self.Bind(wx.EVT_MENU, self.OnRename, id=tID17)
#      EVT_MENU(self, tID18, self.OnEditNodeInfo)
      self.Bind(wx.EVT_MENU, self.OnEditNodeInfo, id=tID18)
      return menu

    if isinstance(self.entityObj, Argument):
      # we either want to add a argument or delete the component and all its subs.
      item = wx.MenuItem(menu, tID19, "Delete This Argument")
      item.SetBitmap(images.getArgumentBitmap())
      menu.AppendItem(item)
      item = wx.MenuItem(menu, tID20, "Edit Argument")
      item.SetBitmap(images.getArgumentBitmap())
      menu.AppendItem(item)
#      EVT_MENU(self, tID19, self.OnDeleteEntity)
      self.Bind(wx.EVT_MENU, self.OnDeleteEntity, id=tID19)
#      EVT_MENU(self, tID20, self.OnRename)
      self.Bind(wx.EVT_MENU, self.OnRename, id=tID20)
      return menu