Hi Guys, Still trying to load from an XML or HTML file.
Here I have 2 pieces of code: 1 (see below) is the Perl file with Wx::RichTextHTMLHandler->LoadFile 2 (see below) is the HTML file I am trying to load (created by ->SaveFile) The relevant piece of code is: my $HTML_handler = Wx::RichTextHTMLHandler->new; $HTML_handler->LoadFile ( my $HTML_buffer, "output.htm"); $self->{rich_text_ctrl_1}->SetValue ( $HTML_buffer ); Which creates a handler (no error), loads the file (no error, but creates an empty $HTML_buffer with no type) and moves the buffer into the RTC control (error: "variable is not an object: it must have type Wx::RichTextFileHandler at C:\... RichText2.pl line 32") - which is true, because it is empty with no type or value. The RTC then (correctly, given the load error) displays an empty control. Whether I use this formula or even if I initialise $HTML_buffer first with: $HTML_buffer = $self->{rich_text_ctrl_1}->GetBuffer(); $HTML_buffer remains stubbornly empty. What am I doing wrong? All suggestions gratefully received. Regards Steve Attachment 1 (wxPerl file) __________________________ #!/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", wxDefaultPosition, wxDefaultSize, wxDEFAULT_FRAME_STYLE, "" ); $self->SetTitle("Rich Text Control"); $self->{Ctl_Post_Exam_Videos_Sizer_2} = Wx::BoxSizer->new(wxVERTICAL); # 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 $HTML_handler = Wx::RichTextHTMLHandler->new; $HTML_handler->LoadFile ( my $HTML_buffer, "output.htm"); $self->{rich_text_ctrl_1}->SetValue ( $HTML_buffer ); $self->SetSizer ($self->{Ctl_Post_Exam_Videos_Sizer_2}); $self->Layout(); return $self; } Attachment 2 (HTML) ___________________ <html><head></head><body> <font face="MS Shell Dlg 2" size="1" color="#000000" ><p align="center"><font size="4" ><b>Welcome to wxRichTextCtrl, a wxWidgets control for editing and presenting styled text and images</b></font></p> <p align="center"><b><i>by Julian Smart</i></b></p> <p align="left"></p> <p align="left"></p> <p align="left"><table border=0 cellpadding=0 cellspacing=0><tr><td width="15"></td><td><font face="MS Shell Dlg 2" size="1" color="#000000" >What can you do with this thing? Well, you can change text <font color="#FF0000" >colour, like this red bit.</font><font color="#0000FF" > And this blue bit.</font> Naturally you can make things <b>bold </b><i>or italic </i><u>or underlined.</u><font size="4" > Different font sizes on the same line is allowed, too.</font> Next we'll show an indented paragraph.</font></td></tr></table></p> <p align="left">Indented paragraph.</p> <p align="left"><table border=0 cellpadding=0 cellspacing=0><tr><td width="15"></td><td><font face="MS Shell Dlg 2" size="1" color="#000000" > Next, we'll show a first-line indent, achieved using BeginLeftIndent(100, -40).</font></td></tr></table></p> <p align="left">It was in January, the most down-trodden month of an Edinburgh winter.</p> <p align="left"><ol type="1"><li> Numbered bullets are possible, again using subindents:</p> <li> This is my first item. Note that wxRichTextCtrl doesn't automatically do numbering, but this will be added later.</p> </ol><p align="left">This is my second item.</p> <p align="left">The following paragraph is right-indented:</p> <p align="left">It was in January, the most down-trodden month of an Edinburgh winter. An attractive woman came into the cafe, which is nothing remarkable.</p> <p align="left">This line contains tabs: First tab Second tab Third tab</p> <p align="left"><ul><li> Other notable features of wxRichTextCtrl include:</p> </ul><p align="left">Compatibility with wxTextCtrl API</p> </font></body></html>