Tk::ObjEditor(3pm)

πŸ“¦
version 2.010 Β· 3 versions
, in debian trixie, ubuntu noble, ubuntu resolute, ubuntu stonking

πŸ’– Tk::ObjEditor β€” the manual page, but make it cute πŸ’–

okay so bestie, you know Tk::ObjEditor from the User Contributed Perl Documentation? yeah. that one. it's a Tk composite widget Obj editor and honestly it's giving main character energy. sit down, grab a strawberry πŸ“, we're doing this.


✨ NAME ✨

Tk::ObjEditor β€” a Tk composite widget Obj editor. that's it, that's the name, no cap πŸ’…


🌸 SYNOPSIS 🌸

here's the vibe, copy it exactly bestie:

use Tk::ObjEditor;

my $editor = $mw->ObjEditor( caller => $object,
                              direct => [1|0],
                              [title=>"windows"]) -> pack ;

like. look at it. gorgeous. pack it and go 🫢


πŸ¦‹ DESCRIPTION πŸ¦‹

so this widget hands you a whole GUI to edit the attributes of an object, or the elements of a simple hash or array. iconic behavior fr.

the editor is a Tk::ObjScanner with extra function to actually edit data. and it can also fly solo β€” there's an edit_object function for that, we'll get to it.

when the user double clicks (with the left button) on an item, the value of that item gets displayed in the HList. yes. the HList. keep up ✨

if the value is a scalar, the scalar gets displayed in the text window. which is super handy if the value is a multi-line string, lowkey a lifesaver 😌

if you use the middle button and the item (whether it's a hash, an array or a scalar) is tied to an object, you'll open the object hidden behind the tied variable. spooky. love that for you πŸ‘»

use the right button of the mouse on an element to modify its value. and depending on the context, you'll also be able to delete the element or add a sub-element. multitasking queen πŸ’…

ngl this may be not clear. if it is clear, amazing, but honestly? trying this widget will be way clearer than any explanation I could write. so run the Tk widget demo and you'll find the Obj editor demo in the "User Contributed Demonstration" section. go. run it. i'll wait πŸŽ€

🌈 Direct or undirect edit 🌈

since the constructor passes a reference to the data structure to be edited, the data can be edited in two whole ways:

  • not directly β€” in this case, the data structure is cloned. the widget edits the cloned version of the data structure. this enables the user to cancel the edition 🫢. the catch: any reference to the internals of the old data structure will stay on the old data structure and will not be aware of the new values entered with this widget. unfortunate. (the original says "Unforunately" and honestly, mood.)
⚠️ undirect edition will break if the cloned data structure contains code reference. like, break break. be careful bestie 😭
  • directly β€” in this case, the data structure is not cloned. the edition is performed on the passed reference. any reference to the internals of the old data structure will be updated on-line ✨. the drawback? the user cannot cancel (or undo) the edition. no take-backs. periodt.

πŸ‘‘ Constructor parameters πŸ‘‘

  • -caller β€” the ref of the object or hash or array to edit. mandatory, bestie, you literally cannot skip this one πŸ’€
  • -title β€” the title of the menu created by the editor. optional, but cute.
  • -direct β€” set to 1 if you want to perform direct edition.

🧚 Autonomous widget 🧚

edit_object( data )

this function is not exported and must be called this way:

Tk::ObjEditor::edit_object($data);

this function will load Tk and pop up an editor widget. when the user destroys the widget (with the "File -" destroy> menu), the user code is resumed. bye widget, hi again code 🌸


πŸ’€ CAVEATS πŸ’€

like Tk::ObjScanner, ObjEditor does not detect recursive data structures. it will just keep on displaying the tree until the user gets tired of clicking on the HList items. which, honestly, could be a while. hope you have snacks πŸ“

ObjEditor cannot edit code reference. the module will break if you try undirect edition of data containing code references. do not test this. do not. πŸ™ˆ


πŸ’œ AUTHOR πŸ’œ

Dominique Dumont (ddumont at cpan.org), Guillaume Degremont. legends, both of them πŸ‘‘


⭐ LICENSE ⭐

Copyright (c) 1997-2004,2007,2014 Dominique Dumont, Guillaume Degremont. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

(that's the legal bit and we keep it word-for-word, no edits, no vibes-based reinterpretation πŸ’…)


🌟 SEE ALSO 🌟

perl(1), Tk, Tk::HList, Tk::ObjScanner


and that's the whole page bestie!! this was documented by the User Contributed Perl Documentation crew, from perl v5.36.0, dated 2023-11-01 β€” so when you cite it, cite it right πŸŽ€πŸ’– slay, go edit some objects ✨

πŸ“¦ where this page comes from