def OnNewObject(self, event): if event is not None: event.GetId() dlg = ObjDialog(self) #dlg.AddChoice(wx.ArtProvider_GetBitmap(str(ed_glob.ID_DECA_EMPTY), wx.ART_MENU, wx.Size(16, 16)), '', '') repo = Deca.world.GetLayer(Deca.World.ID_Repository) dlg.Repository = repo dlg.CurrentLayer = self.graph # fill templates list img = wx.ArtProvider_GetBitmap(str(ed_glob.ID_CLASS_TYPE), wx.ART_MENU, wx.Size(16, 16)) for o in repo.GetTemplates(): dlg.AddChoice(img, o.Name, o.ID) # fill objects list img = wx.ArtProvider_GetBitmap(str(ed_glob.ID_ATTR_TYPE), wx.ART_MENU, wx.Size(16, 16)) for o in repo.GetObjects(): dlg.AddChoice(img, o.GetTitle(), o.ID) for o in self.graph.GetObjects(): dlg.AddChoice(img, o.GetTitle(), o.ID) dlg.EnableReflection() dlg.cbProto.Select(0) dlg.OnPrototype(event) if dlg.ShowModal() == wx.ID_OK: source = dlg.cbProto.GetSelection() if source != wx.NOT_FOUND: source = dlg.cbProto.GetClientData(source) obj = Deca.Object() if dlg.chReflection.Value: obj.ID = source obj.IsReflection = True for x in xrange(dlg.attrGrid.GetNumberRows()) : nm = dlg.attrGrid.GetCellValue(row=x, col=0) vl = dlg.attrGrid.GetCellValue(row=x, col=1) obj.Attributes[nm] = vl if dlg.TitlePos > -1: obj.TitleAttr = dlg.attrGrid.GetCellValue(row=dlg.TitlePos, col=0) obj.TemplateName = dlg.cbProto.GetString(dlg.cbProto.GetSelection()) if obj.TemplateName == "": obj.TemplateName = repo.GetTemplate(repo.ID_DefaultTemplate).Name # attributes copied self.graph.AddObject(obj) self.graph.AddObjectShape(obj, getattr(event, 'x', None), getattr(event, 'y', None)) self.Refresh() Deca.world.Modified = True if self.graph.propsGrid: self.graph.propsGrid.UpdateGrid() # end if wx.ID_OK dlg.Destroy()
def AddObject(self, event): event.GetId() dlg = ObjDialog(self) #dlg.AddChoice(wx.ArtProvider_GetBitmap(str(ed_glob.ID_DECA_EMPTY), wx.ART_MENU, wx.Size(16, 16)), '', '') repo = Deca.world.GetLayer(Deca.World.ID_Repository) dlg.Repository = repo dlg.CurrentLayer = repo # fill templates list img = wx.ArtProvider_GetBitmap(str(ed_glob.ID_CLASS_TYPE), wx.ART_MENU, wx.Size(16, 16)) for o in repo.GetTemplatesNames(): dlg.AddChoice(img, o, o) # fill objects list img = wx.ArtProvider_GetBitmap(str(ed_glob.ID_ATTR_TYPE), wx.ART_MENU, wx.Size(16, 16)) for o in repo.GetObjects(): dlg.AddChoice(img, o.GetTitle(), o.ID) res = dlg.ShowModal() if res == wx.ID_OK: pass