# The editor.ListEditor() function create a new class of editor with the given list # of possible values. custom.register_attr("power2", editor.ListEditor(["1", "2", "4", "8"])) # "any" can be anything, so we do not provide a specific editor. # It will be edited with a one-line Python console. # Say that for "any", the value "None" should be proposed to the user. custom.register_values("any", ["None"]) # Say that "content" contains the items of a MyObj object. # # EditObj automatically display a tree view if the object is a list or # 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)
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA from __future__ import nested_scopes import Tkinter import editobj, editobj.editor as editor, editobj.custom as custom import song, globdef, tablature, drum, staff, view, songbook custom.TRANSLATOR = _ custom.register_children_attr("partitions", clazz = song.Song) custom.register_children_attr("playlist_items", clazz = song.Playlist) custom.register_children_attr("songs", "on_add_song", "on_del_song", clazz = songbook.Songbook) def edit_songref(songref, window): import main s = songref.get_song() main.App(edit_song = s) custom.register_on_edit(edit_songref, songbook.SongRef) def edit_song(song, window): if getattr(song, "app", None): if not window.hierarchyedited is song: song.app.tkraise() else: import main
import editobj, editobj.main, editobj.editor as editor, editobj.custom as custom import soya, soya.editor.material, soya.editor.world import soya.laser as laser import soya.ray as ray import soya.facecutter as facecutter import soya.widget # # Config and hacks for EditObj. # custom.register_method("rotate_y", soya.CoordSyst, editor.FloatEditor) custom.register_method("rotate_x", soya.CoordSyst, editor.FloatEditor) custom.register_method("rotate_z", soya.CoordSyst, editor.FloatEditor) custom.register_children_attr("children" , "add", "__delitem__", clazz = soya.World) custom.register_children_attr("vertices" , clazz = soya.Face) custom.register_children_attr("generators", clazz = soya.Particles) soya.Particles.generators = property(lambda self: [self.generator], None) # Register properties' editors class XTextureCoordEditor(editor.Editor, Tkinter.Frame): require_right_menu = 0 def __init__(self, master, obj, attr): editor.Editor.__init__(self, master, obj, attr) Tkinter.Frame.__init__(self, master) self.columnconfigure(0, weight = 1)