From: Thomas M. <to...@gm...> - 2006-11-13 00:32:50
|
Hi, this has been bothering me for a while now, and i can't figure out what's going wrong. I'm importing this: use Wx; use Wx::Grid; use base qw(Wx::Frame); use Wx::Event qw(EVT_BUTTON EVT_GRID_SELECT_CELL); use Wx qw( :all ); I would like $alignment to use a fixed width font. The commented lines are from previous tries. I pasted them in to show you what I've tried already. $alignment = Wx::TextCtrl->new( $panel, -1, "", [20, 470], [850, 200], 100); # my $style = Wx::TextAttr->new(); # my $font = $style->GetFont();#Wx::Font->new(12, wxMODERN); # if ($font->SetFamily( wxMODERN )) { # print "success\n"; # } # else { # print "fail\n"; # } # if( $style->SetFont($font)){ # print "font is modern\n"; # } $alignment->SetDefaultStyle(0, 2, Wx::TextAttr->new( Wx::Font(wxModern) ) ); # $alignment->SetFont( $font ); This is the current error: Error while autoloading 'Wx::Font' at guilibsrch.pl line 716 I'm using version 0.22 on OS X. Is this problem due to me not seeing the obvious, or is this a bug that's been fixed in more recent versions? Thanks for your help, Tom -- No discipline is ever requisite to force attendance upon lectures which are really worth the attending. -- Adam Smith, "The Wealth of Nations" |
From: Mark D. <mar...@zn...> - 2006-11-13 00:43:39
|
Hi, I haven't got 0.22 to test on, but I'm fairly sure the following worked on wxMSW $alignment->SetFont(Wx::Font->new(12,wxMODERN,wxNORMAL,wxNORMAL,0)); Regards Mark Thomas Margraf wrote: > Hi, > this has been bothering me for a while now, and i can't figure out > what's going wrong. > > I'm importing this: > > use Wx; > use Wx::Grid; > use base qw(Wx::Frame); > use Wx::Event qw(EVT_BUTTON EVT_GRID_SELECT_CELL); > use Wx qw( :all ); > > I would like $alignment to use a fixed width font. The commented lines > are from previous tries. I pasted them in to show you what I've tried > already. > > $alignment = Wx::TextCtrl->new( $panel, -1, "", [20, 470], [850, 200], 100); > # my $style = Wx::TextAttr->new(); > # my $font = $style->GetFont();#Wx::Font->new(12, wxMODERN); > # if ($font->SetFamily( wxMODERN )) { > # print "success\n"; > # } > # else { > # print "fail\n"; > # } > # if( $style->SetFont($font)){ > # print "font is modern\n"; > # } > $alignment->SetDefaultStyle(0, 2, Wx::TextAttr->new( > Wx::Font(wxModern) > ) > ); > # $alignment->SetFont( $font ); > > This is the current error: > > Error while autoloading 'Wx::Font' at guilibsrch.pl line 716 > > I'm using version 0.22 on OS X. Is this problem due to me not seeing > the obvious, or is this a bug that's been fixed in more recent > versions? > Thanks for your help, > Tom |
From: Thomas M. <to...@gm...> - 2006-11-13 00:56:18
|
On 11/13/06, Mark Dootson <mar...@zn...> wrote: > Hi, > > I haven't got 0.22 to test on, but I'm fairly sure the following worked > on wxMSW > > $alignment->SetFont(Wx::Font->new(12,wxMODERN,wxNORMAL,wxNORMAL,0)); > > > Regards > > Mark > Wow. thanks for the quick reply. Unfortunately, that didn't work either. the error was: Usage: Wx::Font::newNativeInfo(CLASS, info) at guilibsrch.pl line 720. Tom > > Thomas Margraf wrote: > > Hi, > > this has been bothering me for a while now, and i can't figure out > > what's going wrong. > > > > I'm importing this: > > > > use Wx; > > use Wx::Grid; > > use base qw(Wx::Frame); > > use Wx::Event qw(EVT_BUTTON EVT_GRID_SELECT_CELL); > > use Wx qw( :all ); > > > > I would like $alignment to use a fixed width font. The commented lines > > are from previous tries. I pasted them in to show you what I've tried > > already. > > > > $alignment = Wx::TextCtrl->new( $panel, -1, "", [20, 470], [850, 200], 100); > > # my $style = Wx::TextAttr->new(); > > # my $font = $style->GetFont();#Wx::Font->new(12, wxMODERN); > > # if ($font->SetFamily( wxMODERN )) { > > # print "success\n"; > > # } > > # else { > > # print "fail\n"; > > # } > > # if( $style->SetFont($font)){ > > # print "font is modern\n"; > > # } > > $alignment->SetDefaultStyle(0, 2, Wx::TextAttr->new( > > Wx::Font(wxModern) > > ) > > ); > > # $alignment->SetFont( $font ); > > > > This is the current error: > > > > Error while autoloading 'Wx::Font' at guilibsrch.pl line 716 > > > > I'm using version 0.22 on OS X. Is this problem due to me not seeing > > the obvious, or is this a bug that's been fixed in more recent > > versions? > > Thanks for your help, > > Tom > > > -- No discipline is ever requisite to force attendance upon lectures which are really worth the attending. -- Adam Smith, "The Wealth of Nations" |
From: Mark D. <mar...@zn...> - 2006-11-13 01:51:36
|
Tom, I've tested below on a Mac mini - 10.3, wx version 0.22. It works as desired. I think the problem with your code is you are using Wx qw( :all ); and you are not using 'strict'. Wx does not export ':all', but uses ':everything' instead. This would have been apparent if 'use strict' were switched on. Best regards Mark #------------ EXAMPLE ------------------------------------- package MyFrame; use strict; use Wx qw( :everything ); use vars qw(@ISA); @ISA = qw(Wx::Frame); sub new{ if(not exists $_[4]){ $_[4] = wxDefaultPosition;} if(not exists $_[5]){ $_[5] = wxDefaultSize;} my( $self ) = shift->SUPER::new( @_ ); $self->{panel} = Wx::Panel->new($self,-1,wxDefaultPosition,wxDefaultSize); $self->{txtCheck} = Wx::TextCtrl->new($self->{panel},-1,"",wxDefaultPosition,wxDefaultSize,wxTE_MULTILINE); $self->{txtCheck}->SetFont(Wx::Font->new(12,wxMODERN,wxNORMAL,wxNORMAL,0)); $self->{szVmain} = Wx::BoxSizer->new(wxVERTICAL); $self->{szVpanel} = Wx::BoxSizer->new(wxVERTICAL); $self->{szVmain}->Add($self->{panel},1,wxTOP|wxLEFT|wxBOTTOM|wxRIGHT|wxEXPAND,3); $self->{szVpanel}->Add($self->{txtCheck},1,wxTOP|wxLEFT|wxBOTTOM|wxRIGHT|wxEXPAND,3); $self->SetSizer($self->{szVmain}); $self->SetAutoLayout(1); $self->Layout(); $self->{panel}->SetSizer($self->{szVpanel}); $self->{panel}->SetAutoLayout(1); $self->{panel}->Layout(); $self->Refresh(); $self->Centre(); return $self; } package MyApp; use Wx; use base 'Wx::App'; use vars qw(@ISA ); @ISA = qw(Wx::App); sub OnInit { my( $self ) = shift; my( $frame ) = MyFrame->new(undef, -1); $frame->Show(1); return 1; } package main; my( $app ) = MyApp->new(); $app->MainLoop(); #------------ END EXAMPLE ------------------------------------- |
From: Thomas M. <to...@gm...> - 2006-11-13 02:00:32
|
brilliant! That was in fact the problem. Thanks a bunch! Tom On 11/13/06, Mark Dootson <mar...@zn...> wrote: > Tom, > > I've tested below on a Mac mini - 10.3, wx version 0.22. > It works as desired. > > I think the problem with your code is you are using > Wx qw( :all ); > > and you are not using 'strict'. > > Wx does not export ':all', but uses ':everything' instead. > This would have been apparent if 'use strict' were switched on. > > Best regards > > Mark > > #------------ EXAMPLE ------------------------------------- > > package MyFrame; > use strict; > use Wx qw( :everything ); > use vars qw(@ISA); > @ISA = qw(Wx::Frame); > > sub new{ > if(not exists $_[4]){ $_[4] = wxDefaultPosition;} > if(not exists $_[5]){ $_[5] = wxDefaultSize;} > my( $self ) = shift->SUPER::new( @_ ); > $self->{panel} = > Wx::Panel->new($self,-1,wxDefaultPosition,wxDefaultSize); > $self->{txtCheck} = > Wx::TextCtrl->new($self->{panel},-1,"",wxDefaultPosition,wxDefaultSize,wxTE_MULTILINE); > > $self->{txtCheck}->SetFont(Wx::Font->new(12,wxMODERN,wxNORMAL,wxNORMAL,0)); > $self->{szVmain} = Wx::BoxSizer->new(wxVERTICAL); > $self->{szVpanel} = Wx::BoxSizer->new(wxVERTICAL); > > $self->{szVmain}->Add($self->{panel},1,wxTOP|wxLEFT|wxBOTTOM|wxRIGHT|wxEXPAND,3); > > $self->{szVpanel}->Add($self->{txtCheck},1,wxTOP|wxLEFT|wxBOTTOM|wxRIGHT|wxEXPAND,3); > $self->SetSizer($self->{szVmain}); > $self->SetAutoLayout(1); > $self->Layout(); > $self->{panel}->SetSizer($self->{szVpanel}); > $self->{panel}->SetAutoLayout(1); > $self->{panel}->Layout(); > $self->Refresh(); > $self->Centre(); > return $self; > } > > > package MyApp; > use Wx; > use base 'Wx::App'; > use vars qw(@ISA ); > > @ISA = qw(Wx::App); > > sub OnInit { > my( $self ) = shift; > my( $frame ) = MyFrame->new(undef, -1); > $frame->Show(1); > return 1; > } > > > package main; > > my( $app ) = MyApp->new(); > $app->MainLoop(); > > > #------------ END EXAMPLE ------------------------------------- > > > -- No discipline is ever requisite to force attendance upon lectures which are really worth the attending. -- Adam Smith, "The Wealth of Nations" |