Your skill will accomplish what the force of many cannot |
|
PerlMonks |
Tk::Canvas createGroup() Undocumentedby kcott (Archbishop) |
on Mar 20, 2021 at 12:16 UTC ( [id://11130002]=perlquestion: print w/replies, xml ) | Need Help?? |
kcott has asked for the wisdom of the Perl Monks concerning the following question: G'day All, Background: I've been playing around in Tk, looking at the feasibility of using Tk::Canvas to generate some simple, interactive maps for use with RPGs. I came across the createGroup() method, which would help enormously with abstraction and code reduction; however, I'm unable to find any substantial documentation for this. I found this method in "Mastering Perl/Tk" (Chapter 9: The Canvas Widget; The Group Item; pp. 212-213). Over half of that is taken up with a couple of screenshots. There's a minimal code example, with very little explanation, which looks like:
I've no idea what the [0, 0] is supposed to do. My first thought was that it was related to placement; but, after putting all sorts of different numbers in there, I see no change. It's also unclear why the update() is necessary — but it is. I've checked for documentation, or other references, in the following places:
I put together the following test script. This was mainly to check that what was written in the book was valid.
That worked: I got (using a modicum of imagination) a creek running through a grassy area (three blocks wide). That's the type of abstraction I was looking for but I still wasn't happy with the cargo-cult programming. I wondered if the ARRAYREF ([0, 0]) had something to do with the number of members in the group. I put a bend in the last part of the creek using a group with four members; this worked, still with [0, 0]. Here's the important part of the code for that test:
The full code is somewhat lengthy; it's in the following spoiler: <Reveal this spoiler or all in this thread>
I'm using Perl 5.32.0 and Tk 804.035. So, this leads to the questions. Can anyone point me to any documentation about this? In the absence of doco, does anyone have an explanation for the [0, 0] and the need for the update()? Thanks in advance. — Ken
Back to
Seekers of Perl Wisdom
|
|