update: you must alwaysuse strict;, always!!! The font constants aren't being exported to the correct namespace, so the correct constructor isn't called.

What did you expect to get? I don't know the nitty gritty, but basically if you're going to be using fonts, you need to have some windows, see the hello.pl wxPerl sample

#!/usr/bin/perl ###################################################################### +####### ## Name: hello.pl ## Purpose: Hello wxPerl sample ## Author: Mattia Barbon ## Modified by: ## Created: 2/11/2000 ## RCS-ID: ## Copyright: (c) 2000 Mattia Barbon ## Licence: This program is free software; you can redistribute it + and/or ## modify it under the same terms as Perl itself ###################################################################### +####### use strict; use Wx; # every program must have a Wx::App-derive class package MyApp; use vars qw(@ISA); @ISA = qw(Wx::App); # this is called automatically on object creation sub OnInit { my( $this ) = shift; # create a new frame my( $frame ) = MyFrame->new(); # set as top frame $this->SetTopWindow( $frame ); # show it $frame->Show( 1 ); } package MyFrame; use vars qw(@ISA); @ISA = qw(Wx::Frame); use Wx::Event qw(EVT_PAINT); # this imports some constants use Wx qw(wxDECORATIVE wxNORMAL wxBOLD); use Wx qw(wxDefaultPosition); use Wx qw(wxWHITE); sub new { # new frame with no parent, id -1, title 'Hello, world!' # default position and size 350, 100 my( $this ) = shift->SUPER::new( undef, -1, 'Hello, world!', wxDefaultPosition , [350, 100] ); # create a new font object and store it $this->{FONT} = Wx::Font->new( 40, wxDECORATIVE, wxNORMAL, wxBOLD, 0 + ); # set background colour $this->SetBackgroundColour( wxWHITE ); $this->SetIcon( Wx::GetWxPerlIcon() ); # declare that all paint events will be handled with the OnPaint met +hod EVT_PAINT( $this, \&OnPaint ); return $this; } sub OnPaint { my( $this, $event ) = @_; # create a device context (DC) used for drawing my( $dc ) = Wx::PaintDC->new( $this ); # select the font $dc->SetFont( $this->font ); # darw a friendly message $dc->DrawText( 'Hello, world!', 10, 10 ); } sub font { $_[0]->{FONT}; } package main; # create an instance of the Wx::App-derived class my( $app ) = MyApp->new(); # start processing events $app->MainLoop(); # Local variables: # # mode: cperl # # End: #

MJD says "you can't just make shit up and expect the computer to know what you mean, retardo!"
I run a Win32 PPM repository for perl 5.6.x and 5.8.x -- I take requests (README).
** The third rule of perl club is a statement of fact: pod is sexy.


In reply to Re: using Wx::Font (wxPerl question) by PodMaster
in thread using Wx::Font (wxPerl question) by lilphil

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.