Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master
Fetching contributors…

Cannot retrieve contributors at this time

46 lines (35 sloc) 1.038 kb
# Cross-Platform GUI Programming with wxWidgets - Smart, Hock, & Csomor
# C++ Example from pg 135 - Drawing on Windows with wxPaintDC
# Ported to wxPerl by James M. Lynes Jr. - Last Modified 9/23/2012
use 5.010;
use strict;
use warnings;
use Wx qw(:everything);
use Wx::Event qw(EVT_PAINT);
# create the WxApplication
my $app = Wx::SimpleApp->new;
my $frame = Wx::Frame->new(undef, -1,
wxDefaultPosition, wxDefaultSize,);
# Example specific code
sub OnPaint {
my ( $self, $event) = @_;
my $dc = Wx::PaintDC->new($self);
my $pen = Wx::Pen->new(wxBLACK,1,wxSOLID);
my $brush=Wx::Brush->new(wxRED,wxSOLID);
my $sz=$self->GetClientSize();
my $szx=$sz->x;
my $szy=$sz->y;
my $w=100;
my $h=50;
my $x=($szx - $w)/2;
my $y=($szy - $h)/2;
$dc->DrawRectangle($x,$y,$w,$h); # Centered on the window, try resizing...
Jump to Line
Something went wrong with that request. Please try again.