示例#1
0
# a dictionary, or if it we register a "children" attribute.

custom.register_children_attr("content", clazz = MyObj)

# Say "content" is hidden (because it is edited as "items", by the tree view).
custom.register_attr("content", None)


# Say that MyObj object can contains other MyObj object in their "items" attribute
# (which is the same that "content") Yes, it is a tree like structure, and EditObj
# deals very well with such structures !
#
# The editor.register_children function register a (non-exhaustive) list of
# possible children for a given class. Children are given as Python strings.

custom.register_available_children(["MyObj('new')"], MyObj)


# Make MyObj available in the evaluation environment

custom.EVAL_ENV["MyObj"] = MyObj


# No main Tk window
root = Tkinter.Tk(className = 'EditObj')
root.withdraw()

# Better Tk look
root.option_add("*bd", 1)
root.option_add("*Entry.background", "#FFFFFF")
root.option_add("*List.background", "#FFFFFF")
示例#2
0
    
custom.register_on_edit(edit_song, song.Song)

def _partition_children(self):
  if self.view.__class__.__name__ in ("Tablature", "DrumView"): return self.view.strings
  return None

song.Partition.children = property(_partition_children)

def NewString(parent):
  if   isinstance(parent.view, tablature.Tablature): return tablature.String()
  elif isinstance(parent.view, drum.DrumView      ): return drum     .String()
  
custom.EVAL_ENV["song"]      = song
custom.EVAL_ENV["NewString"] = NewString
custom.register_available_children("NewString(parent)", song.Partition)

def NewPlaylistItem(parent):
  mesures = {}
  for partition in parent.song.partitions:
    for graphic_note in partition.view.selected_notes():
      mesure = parent.song.mesure_at(graphic_note.note.time)
      mesures[mesure] = 1
  mesures = map(lambda mesure: parent.song.mesures.index(mesure), mesures.keys())
  if mesures: return song.PlaylistItem(parent, min(mesures), max(mesures))
  else:       return song.PlaylistItem(parent, (parent.playlist_items and (parent.playlist_items[-1].to_mesure)) or 0, len(parent.song.mesures) - 1)
  
custom.EVAL_ENV["NewPlaylistItem"] = NewPlaylistItem
custom.register_available_children("NewPlaylistItem(parent)", song.Playlist)

def AddSong(songbook):
示例#3
0
	
	f = soya.Face(None, vertices)
	if _last_face:
		f.double_sided = _last_face.double_sided
		f.material     = _last_face.material
		f.smooth_lit = _last_face.smooth_lit
		f.lit = _last_face.lit
		f.solid = _last_face.solid
		f.static_lit = _last_face.static_lit
	_last_face = f
	return f

soya.Triangle = lambda : _Gone([ImmatureVertex(), ImmatureVertex(), ImmatureVertex()])
soya.Quad     = lambda : _Gone([ImmatureVertex(), ImmatureVertex(), ImmatureVertex(), ImmatureVertex()])

custom.register_available_children(["soya.Triangle()", "soya.Quad()", "soya.Body()", "soya.World()", "soya.Camera()", "soya.Light()", "soya.Portal()", "soya.Fountain()", "laser.Laser()", "ray.Ray()"], soya.World)
custom.register_available_children(["soya.Vertex()"], soya.Face)

custom.register_values("color"       , ["None", "(1.0, 1.0, 1.0, 1.0)", "(0.0, 0.0, 0.0, 1.0)"])
custom.register_values("diffuse"     , ["None", "(1.0, 1.0, 1.0, 1.0)", "(0.0, 0.0, 0.0, 1.0)"])
custom.register_values("specular"    , ["None", "(1.0, 1.0, 1.0, 1.0)", "(0.0, 0.0, 0.0, 1.0)"])
custom.register_values("to_model_args", ["None", """("tree", {})""", """("cell-shading", { 'shader':'shader2', 'line_color':(0.0, 0.0, 0.0, 1.0), 'line_width':8.0 })"""])
#custom.register_values("to_model_args", ["None", """("tree", {"min_node_content":0, "min_node_radius":5.0, "min_node_distance":0.0})""", """("morph", {})"""])

editobj.EVAL_ENV.update({
	"soya"       : soya,
	"laser"      : laser,
	"ray"        : ray,
	"cut"        : facecutter.cut,
	"check_quads": facecutter.check_quads,
	})