コード例 #1
0
ファイル: ObjRepo.py プロジェクト: pombreda/decada
	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
コード例 #2
0
ファイル: ObjRepo.py プロジェクト: pombreda/decada
	def OnListDouble(self, event):
		"""Edit selected item"""
		event.GetId()
		repo = Deca.world.GetLayer(Deca.World.ID_Repository)
		idx = self.mRepoList.GetFirstSelected()
		if idx > -1:
			itm = self.mRepoList.GetItem(idx)
			tp = itm.Image
			if not tp:
				# edit the template
				code = uuid.UUID(itm.GetText())
				dlg = TmplDialog(self)
				dlg.EditMode = True
				dlg.cbProto.Clear()
				dlg.cbProto.Append("")
				dlg.cbProto.AppendItems(repo.GetTemplatesNames())
				dlg.txtName.Value = self.mRepoList.GetItem(idx, col = 1).Text
				dlg.cbProto.StringSelection = dlg.txtName.Value
				dlg.OnPrototype(event)
				tpl = repo.GetTemplate(code)
				try:
					dlg.shapeSel.SetStringSelection(tpl.Graphics)
				except Exception:
					dlg.shapeSel.SetStringSelection("DefaultShape")
				if code == repo.ID_DefaultTemplate:
					dlg.txtName.Enabled = False
				res = dlg.ShowModal()
				if res == wx.ID_OK:
					tpl = repo.GetTemplate(code)
					tpl.Name = dlg.txtName.Value
					tpl.TitleAttr = None
					tpl.Attributes.clear()
					for x in xrange(dlg.attrGrid.GetNumberRows()) :
						nm = dlg.attrGrid.GetCellValue(row = x, col= 0)
						vl = dlg.attrGrid.GetCellValue(row = x, col= 1)
						tpl.Attributes[nm] = vl
					if dlg.TitlePos > -1:
						tpl.TitleAttr = dlg.attrGrid.GetCellValue(row = dlg.TitlePos, col= 0)
					tpl.Graphics = dlg.shapeSel.GetStringSelection()
					repo.LazyReindex()
					self.UpdateView(None)
					if repo.propsGrid is not None :
						repo.propsGrid.UpdateGrid()
				dlg.Destroy()
			elif tp == 1:
				# edit the object
				#code = uuid.UUID(itm.GetText())
				dlg = ObjDialog(self)
				dlg.AddChoice(wx.NullBitmap, '', '')
				repo = Deca.world.GetLayer(Deca.World.ID_Repository)
				# 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
			elif tp == 2:
				# edit the shape
				path = Deca.world.ShapesPath
				path = os.path.join(path, itm.GetText() + '.py')
				self._OpenShapeEditor(path)
				pass