This is my desired goal: I want to create an app that displays an image and then lets me "draw" on it, simple lines mostly, nothing fancy. After scanning through the Wx docs I found the Wx::ClientDC class which has several methods like "DrawBitmap" and "DrawLine" which looked like exactly what I needed.

However, nothing I've done has come close to working. My code is below. Am I simply making a mistake? Is there a better class I should be using? The code below simply opens a 500 x 500 frame. No rectangle or black of any kind.

use strict; use Wx qw/wxSOLID/; package MGV; use base 'Wx::App'; sub OnInit { my $self = shift; my $frame = Wx::Frame->new( undef, -1, 'title', [500,500], [500,500] ); my $dc = Wx::ClientDC->new( $frame ); $dc->SetBrush( Wx::Brush->new( 'black', Wx::wxSOLID ) ); $dc->DrawRectangle( 100,100, 200,200 ); $frame->Show( 1 ); } package main; MGV->new()->MainLoop();


Update: I think I solved my issue. I changed to using a Wx::PaintDC in a EVT_PAINT:
$self->EVT_PAINT( sub{ my $dc = Wx::PaintDC->new( $frame ); $dc->BeginDrawing(); $dc->DrawRectangle( 100,100, 200,200 ); $dc->EndDrawing(); } );

In reply to WxPerl, Wx::ClientDC, displaying images by BUU

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.