Hi Monks
I'm trying to load from an XML or HTML file into Wx::RichTextCtrl.
I have 2 pieces of code:
The relevant piece of code is:
my $XML_handler = Wx::RichTextXMLHandler->new; $XML_handler->LoadFile ( my $XML_buffer, "output.xml"); $self->{rich_text_ctrl_1}->SetValue ( $XML_buffer );
Which creates a handler (no error), tries to load the file and crashes the Perl interpreter with no error message.
Whether I use this code, or the HTML equivalent, which does nothing, except not crash, and no error message. Either way $XML_buffer/$HTML_buffer remains resolutely empty.
What am I doing wrong?
All suggestions gratefully received.
Regards
Steve
Attachment 1 - richtext_test.pl
#!/usr/bin/perl -w -- use Wx 0.15 qw[:allclasses]; use strict; package MyFrame; use Wx qw[:everything]; use base qw(Wx::Frame); use base qw(Class::Accessor::Fast); use Wx qw(:richtextctrl :textctrl :font :sizer :color); __PACKAGE__->mk_accessors( qw(richtext stylesheet control) ); sub new { my( $self, $parent, $id, $title, $pos, $size, $style, $name ) = @_ +; $style = wxDEFAULT_FRAME_STYLE unless defined $style; $self = $self->SUPER::new( undef, wxID_ANY, "Rich Text Control", w +xDefaultPosition, wxDefaultSize, wxDEFAULT_FRAME_STYLE, "" ); $self->SetTitle("Rich Text Control"); $self->{Ctl_Post_Exam_Videos_Sizer_2} = Wx::BoxSizer->new(wxVERTIC +AL); # Top-level left-hand sizer (contains media) $self->{rich_text_ctrl_1} = Wx::RichTextCtrl->new( $self, -1, '', +[-1, -1], [800, 600] ); $self->richtext( $self->{rich_text_ctrl_1} ); my $sizer = Wx::BoxSizer->new( wxHORIZONTAL ); $sizer->Add( $self->{rich_text_ctrl_1}, 1, wxGROW|wxALL, 5 ); $self->SetSizerAndFit( $sizer ); $self->control ( $self ); my $XML_handler = Wx::RichTextXMLHandler->new; $XML_handler->LoadFile ( my $XML_buffer, "output.xml"); $self->{rich_text_ctrl_1}->SetValue ( $XML_buffer ); $self->SetSizer ($self->{Ctl_Post_Exam_Videos_Sizer_2}); $self->Layout(); return $self; ###### Updated, sorry I missed this bit out. package main; unless(caller){ local *Wx::App::OnInit = sub{1}; my $app = Wx::App->new(); Wx::InitAllImageHandlers(); my $frame_1 = MyFrame->new(); $app->SetTopWindow($frame_1); $frame_1->Show(1); $app->MainLoop(); } }
Attachment 2 - output.xml
<?xml version="1.0" encoding="UTF-8"?> <richtext version="1.0.0.0" xmlns="http://www.wxwidgets.org"> <paragraphlayout textcolor="#000000" fontsize="8" fontstyle="90" fon +tweight="90" fontunderlined="0" fontface="MS Shell Dlg 2" alignment=" +1" parspacingafter="10" parspacingbefore="0" linespacing="10"> <paragraph> <text>Test </text> </paragraph> </paragraphlayout> </richtext>
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |