# But one typically wants that the "name" attribute can be only a string, "x" a # float number, or "filename" a valid file name. EditObj can do that too, if you # take the time to teach that to him. # # EditObj edits each attribute of an object in an editor. The default one is a # one-line Python console, but many other are supported (See editobj.editor for # more info). # If you want so, you can map an attribute name to a specific editor with the # editobj.editor.register_attr(attr, editor_class) function. Notice that only attribute # names are mapped, and the class of the object is NOT involved (contrary to systems # like Java Bean); this is pretty logic because Python is dynamic and often does so. # It can also save you a lot of time, since you have to enter each attribute only # once ! # Say "name" is a string. custom.register_attr("name", editor.StringEditor) # Say that for "name", the values "me" and "you" should be proposed to the user. # Possible values are given as text; as if they were entered by the user in the # editor. custom.register_values("name", ["me", "you"]) # Say "filename" is a file name. custom.register_attr("filename", editor.FilenameEditor) # Say "x" and "y" are float numbers. custom.register_attr("x", editor.FloatEditor) custom.register_attr("y", editor.FloatEditor) # Say "visible" is a boolean. custom.register_attr("visible", editor.BoolEditor)
if val in (9, 18, 36, 72, 144, 288, 576): val = int(val / 1.5) self.doted.set(1) else: self.doted.set(0) if val in (4, 8, 16, 32, 64, 128, 256): val = int(val * 1.5) self.triplet.set(1) else: self.triplet.set(0) self.scale.set({ 0: 0, 6 : 0, 12 : 1, 24: 2, 48 : 3, 96 : 4, 192 : 5, 384 : 6 }[val]) return 1 custom.register_attr("filename" , None) custom.register_attr("title" , None, songbook.SongRef) custom.register_attr("songs" , None) custom.register_attr("songbook" , None) custom.register_attr("children" , None) custom.register_attr("playlist_items" , None) custom.register_attr("playlist" , editor.EditButtonEditor) custom.register_attr("playlist" , None, song.PlaylistItem) custom.register_attr("view" , editor.ListEditor(view.view_types), song.Partition) custom.register_attr("view" , None, song.Lyrics2) custom.register_attr("partitions" , None) custom.register_attr("mesures" , None) custom.register_attr("version" , None) custom.register_attr("title" , editor.StringEditor) custom.register_attr("authors" , editor.StringEditor) custom.register_attr("copyright" , editor.StringEditor)
self.image_width = self.label.winfo_width() self.image_height = (self.image.size[1] / float(self.image.size[0])) * self.image_width self.imagetk = ImageTk.PhotoImage(self.image.resize((int(self.image_width), int(self.image_height)))) self.label.configure(image = self.imagetk) def get_value(self): return self.internal_editor.get_value() def set_value(self, value): self.internal_editor.set_value(value) def update(self): self.internal_editor.update() def motion(self, event): self.obj.tex_x = max(0.0, min(1.0, float(event.x) / self.image_width )) self.obj.tex_y = max(0.0, min(1.0, float(event.y) / self.image_height)) custom.register_attr("lefthanded" , None) custom.register_attr("matrix" , None) custom.register_attr("root_matrix" , None) custom.register_attr("inverted_root_matrix", None) custom.register_attr("face" , None) custom.register_attr("normal" , None) custom.register_attr("vertices" , None) custom.register_attr("name" , editor.StringEditor) custom.register_attr("filename" , editor.StringEditor) custom.register_attr("x" , editor.FloatEditor) custom.register_attr("y" , editor.FloatEditor) custom.register_attr("z" , editor.FloatEditor) custom.register_attr("scale_x" , editor.FloatEditor) custom.register_attr("scale_y" , editor.FloatEditor) custom.register_attr("scale_z" , editor.FloatEditor) custom.register_attr("front" , editor.FloatEditor)