Very nice looking GUI. I'm not much of an expert on POE, and usually just rely on Tk's event-loop.....but you may have your reasons.

To your questions:

1. Is there a Tk::Zinc(::Graphics) way of building multiple items with similar characteristics? (and how good is my hacked solution)

Yes, look at the clone() method. Look in the zinc-demos, under User Contributed Demos, for TripleRotatingWheel. I make one wheel object, then clone it, then translate it into position. Like: my $arc2 = $zinc->clone($arc1);

2.Is there a reliable way to position text at center of group?

Here is a snippet to show you how. I also throw in a useful trick for reversing the y-axis direction, so coords are more like standard cartesian.

#!/usr/bin/perl use warnings; use strict; use Tk; use Tk::Zinc; my $mw = MainWindow->new; my $width = 700; my $height = 600; $mw->geometry($width.'x'.$height); my $zinc = $mw->Zinc(-width => $width, -height => $height, -backcolor => 'black', -borderwidth => 3, -relief => 'sunken', )->pack; $zinc->fontCreate( "fonta", -family => 'arial', -size => 30, -weight => 'normal' ); #create a group with it's origin at center my $centergroup= $zinc->add('group',1,-visible=> 1); $zinc->scale($centergroup,1,-1); #reverse direction of y axis $zinc->translate($centergroup,$width/2,$height/2); # Then we create a gray filled rectangle, in which we will display exp +lain text. $zinc->add('rectangle', $centergroup , [-100, -100, 100, 100], -linewidth => 2, -filled => 1, -fillcolor => 'SkyBlue', ); my $text = $zinc->add('text', $centergroup, -position => [0,0], -text => 'foobaz', -font => 'fonta', -anchor => 'center', -priority => 2 ); MainLoop;

3. Is there a way to correctly calulate delta x/y if scaling is active?

Your dragging works fine by itself, and your scaling works fine by itself. Maybe just make them mutually exclusive, and pop a warning saying scaling is disabled during dragging? How often is someone going to want to do that anyways? I saw a similar problem in the Gnome2::Canvas and Goo::Canvas where I needed to do some clever multiplications/divisions to account for the current scale when saving to pdf. All I can say is I spent a few hours experimenting before I got it right. :-)

4. Did I missing something when it comes to calculating positions of items relative to display settings?

If you are referring to the drag/scale problem, what I think you will need to do is have 2 separate code blocks for calculating dx/dy. One if scaling is active, and 1 for simple dragging. Since your scaling factor can constantly be changing while the darg is occurring, I think it will mean alot of recalculations for each pixel of drag. Think about it....how can Zinc know what your dx/dy is, if the scale is changing while you drag. At best, it will be jerky( visually not codewise :-) ). I have 2 suggestions. One is to pop a warning, saying scaling is disabled during a drag. Or two, get rid of the +/- button press for scaling, and use a SpinBox instead, to set the scale. That way, the mouse can only be in 1 place at a time...either setting the scale-SpinBox or dragging an item.


I'm not really a human, but I play one on earth Remember How Lucky You Are

In reply to Re: Total Newbies TkZinc questions by zentara
in thread Total Newbies TkZinc questions by rocklee

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.