Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options

Comment on

( #3333=superdoc: print w/replies, xml ) Need Help??

I used your code and tried to force it to do what you describe. Unfortunately, I was unable to get it to work, but I'll keep trying.

What's happening is that you are creating a Frame widget then packing it, and creating a Canvas widget, then packing it ON TOP of the Frame widget.

To see this, I added the following, right before the MainLoop();...

This lowers the Canvas widget, $c in the stack of displayed widgets, placing it below the $cf Frame widget.

It sounds as though you are trying to mix widgets here... The Canvas widget allows you to draw lines, other shapes and create text. The Frame widget allows you to place other widgets, but not draw lines. A big difference between the two, as far as I can tell, is that the Canvas widget only allows you to place a Bitmap object, not other graphical formats, like those allowed by the $mw->Photo() method, like .gif files...

I'll keep digging around and see if I come up with anything... It's definitely an interesting question...


Update: I found a way to do this!! Basically, I put everything into the Canvas widget... And I did find a way to put other image types into a Canvas widget other than bitmaps... the $c->createImage() method works for that...

Here's the code I used to do this...

#!c:\perl\bin\perl.exe use strict; use warnings; use diagnostics; use Tk; my $mw = MainWindow->new(-title => "Line over an image"); my $c = $mw->Scrolled("Canvas", -cursor => 'crosshair', -scrollbars => 'se', ) ->pack(-anchor => 'nw', -fill => 'both', -expand => 1, ); my $tile = $c->createImage(50, 50, -image => $mw->Photo(-file => Tk->findINC('Xcamel.gif')), ); my $line = $c->createLine(0, 0, 100, 100, -width => 2, -fill => "red", ); MainLoop();

In reply to Re: Transparent draw with tk by Daruma
in thread Transparent draw with tk by traveler

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, 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, 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.
  • Log In?

    What's my password?
    Create A New User
    and all is quiet...

    How do I use this? | Other CB clients
    Other Users?
    Others cooling their heels in the Monastery: (2)
    As of 2018-03-19 03:22 GMT
    Find Nodes?
      Voting Booth?
      When I think of a mole I think of:

      Results (232 votes). Check out past polls.