コード例 #1
0
ファイル: ScGraph.py プロジェクト: Alwnikrotikz/decada
	def EditObject(self) :
		shape = self.GetShape()
		canvas = shape.GetCanvas()
		obj = canvas.GetObject(shape.GetRegionName())
		if obj:
			dlg = ObjDialog(self.statbarFrame)
			# fill the dialog
			dlg.AddChoice(wx.ArtProvider_GetBitmap(str(ed_glob.ID_CLASS_TYPE), wx.ART_MENU, wx.Size(16, 16)),
							obj.TemplateName, None)
			if obj.IsReflection:
				dlg.chReflection.Value = True
			dlg.AppendRows(len(obj.Attributes))
			x = 0
			dlg.SetEditMode()
			for k,v in obj.Attributes.items():
				dlg.attrGrid.SetRowLabelValue(x, '')
				if k == obj.TitleAttr:
					dlg.attrGrid.SetRowLabelValue(x, '*')
					dlg.TitlePos = x
					dlg.stTitle.Label = _("Title attribute: %s") % k
				dlg.attrGrid.SetCellValue(row=x, col=0, s=k)
				dlg.attrGrid.SetCellValue(row=x, col=1, s=v)
				x += 1
			if not dlg.shapeSel.SetStringSelection(str(obj.Graphics)):
				dlg.shapeSel.SetSelection(0)
			# show dialog
			if dlg.ShowModal() == wx.ID_OK:
				obj.Attributes.clear()
				for x in xrange(dlg.attrGrid.GetNumberRows()) :
					nm = dlg.attrGrid.GetCellValue(row=x, col=0)
					vl = dlg.attrGrid.GetCellRawValue(row=x, col=1)
					obj.Attributes[nm] = vl
				if dlg.TitlePos > -1:
					obj.TitleAttr = dlg.attrGrid.GetCellValue(row=dlg.TitlePos, col=0)
				# update vision
				obj.Graphics = dlg.GetShapeName()
				shape.Update()
				canvas.GetParent().UpdateView(None)
			dlg.FixGrid()
			dlg.Destroy()
		pass