Tk::ObjEditor(3pm)
π 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 to1if 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
- debian trixie: libtk-objeditor-perl 2.010-1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu noble: libtk-objeditor-perl 2.010-1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu resolute: libtk-objeditor-perl 2.010-1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu stonking: libtk-objeditor-perl 2.010-1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms