Hi Guys, Having spent ages trying to get wxSashWindow to work, I decided to post an example on http://wxperl.pvoice.org/w/index.php/SashWindow, with apologies to the wxPython website I borrowed and mutilated it from. wxSashWindow in Python relies heavily on wxSashLayoutWindow, which is not implemented in wxPerl, instead I have used the position and size parameters in the creator to position the panes. In my actual application, I have created a scrolling body by embedding a ScrollingWindow pane within the wxSashWindow.
I'd be grateful if anyone got the chance to have a look at it and provide advice and criticism. Maybe I've misunderstood the whole thing about layout! Anyhow feedback welcome. Regards Steve PS This is what I posted on the Perl Wiki. #!/usr/bin/perl -w -- use Wx 0.15 qw[:allclasses]; use strict; package MyFrame; use Wx qw[:everything]; use base qw(Wx::Frame); use strict; sub new { my( $self, $parent, $id, $title, $pos, $size, $style, $name ) = @_; $parent = undef unless defined $parent; $id = -1 unless defined $id; $title = "" unless defined $title; $pos = wxDefaultPosition unless defined $pos; $size = wxDefaultSize unless defined $size; $name = "" unless defined $name; $style = wxDEFAULT_FRAME_STYLE unless defined $style; $self = $self->SUPER::new( $parent, $id, $title, $pos, Wx::Size->new(1300,768), $style, $name ); # Create some layout windows # A red window at the top like a toolbar $self->{topwin} = Wx::SashWindow->new($self, -1, [0,0], Wx::Size->new(1000, 30), wxNO_BORDER ); $self->{topwin}->SetBackgroundColour(Wx::Colour->new(255, 0, 0)); # $self->{topwin}->SetSashVisible(wxSASH_BOTTOM, 1); # A blue window at the bottom like a statusbar $self->{bottomwin} = Wx::SashWindow->new($self, -1, [0,630], Wx::Size->new(1000, 30),wxNO_BORDER); $self->{bottomwin}->SetBackgroundColour(Wx::Colour->new(0, 0, 255)); # $self->{bottomwin}->SetSashVisible(wxSASH_TOP, 1); # A green window to the left of the client window $self->{leftwin1} = Wx::SashWindow->new($self, -1, [0,30], Wx::Size->new(120, 300),wxNO_BORDER); $self->{leftwin1}->SetBackgroundColour(Wx::Colour->new(0, 255, 0)); # $self->{leftwin1}->SetSashVisible(wxSASH_RIGHT, 1); # Another window to the left (turquoise) of the client window $self->{leftwin2} = Wx::SashWindow->new($self, -1, [0,330], Wx::Size->new(120, 300),wxNO_BORDER); $self->{leftwin2}->SetBackgroundColour(Wx::Colour->new(0, 255, 255)); # $self->{leftwin2}->SetSashVisible(wxSASH_RIGHT, 1); # White will occupy the space not used by the Layout Algorithm $self->{remaining_space} = Wx::Panel->new($self, -1, [120,30], Wx::Size->new(880, 600), wxSUNKEN_BORDER); $self->{remaining_space}->SetBackgroundColour(Wx::Colour->new(255, 255, 255)); # # Video tab - right-hand pane. # $self->{Ctl_Lbl} = Wx::StaticText->new($self->{remaining_space}, wxID_ANY, "Label", wxDefaultPosition, wxDefaultSize, ); $self->{Ctl_Ref_0_Txt} = Wx::TextCtrl->new($self->{remaining_space}, wxID_ANY, "", wxDefaultPosition, wxDefaultSize, wxTE_READONLY); $self->{Ctl_Description_Txt} = Wx::TextCtrl->new($self->{remaining_space}, wxID_ANY, "Name", wxDefaultPosition, wxDefaultSize, wxTE_READONLY); $self->{Ctl_Change_Btn} = Wx::Button->new($self->{remaining_space}, wxID_ANY, "Button"); # # Sizers # $self->{Ctl_Sizer_1b} = Wx::BoxSizer->new(wxHORIZONTAL); $self->{Ctl_Sizer_2} = Wx::BoxSizer->new(wxHORIZONTAL); $self->{remaining_space}->SetSizer($self->{Ctl_Sizer_1b}); $self->{Ctl_Sizer_2}->Add($self->{Ctl_Lbl}, 0, wxALL, 5); $self->{Ctl_Sizer_2}->Add($self->{Ctl_Ref_0_Txt}, 0, wxALL, 5); $self->{Ctl_Sizer_2}->Add($self->{Ctl_Description_Txt}, 0, wxALL, 5); $self->{Ctl_Sizer_2}->Add($self->{Ctl_Change_Btn}, 0, wxALL, 5); $self->{Ctl_Sizer_1b}->Add($self->{Ctl_Sizer_2}, 1, wxEXPAND, 0); # $self->{Ctl_Sizer_1b}->Fit($self); $self->{Ctl_Sizer_1b}->Layout(); # end wxGlade return $self; } 1; 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(); } Regards Steve _____ From: Steve Cookson [mailto:steve.cook...@sca-uk.com] Sent: 08 September 2009 14:42 To: wxperl-users@perl.org Subject: wxSashWindows Hi, Has anyone managed to get wxSashWindows to work? I managed to find a version written in wxRuby on google, but it was full of SashLayoutWindows commands, which don't appear in wxPerl. I played around with it for a while (scroll down for a working version). The alternative, if I want to have multiple windows, seems to be multiple WindowSplitters? What do you think? Do you use SashWindows or WindowSplitter? Regards Steve PS Here is some sample code. #!/usr/bin/perl -w -- use Wx 0.15 qw[:allclasses]; use strict; package MyFrame; use Wx qw[:everything]; use base qw(Wx::Frame); use strict; sub new { my( $self, $parent, $id, $title, $pos, $size, $style, $name ) = @_; $parent = undef unless defined $parent; $id = -1 unless defined $id; $title = "" unless defined $title; $pos = wxDefaultPosition unless defined $pos; $size = wxDefaultSize unless defined $size; $name = "" unless defined $name; $style = wxDEFAULT_FRAME_STYLE unless defined $style; $self = $self->SUPER::new( $parent, $id, $title, $pos, Wx::Size->new(1300,768), $style, $name ); # Create some layout windows # A red window at the top like a toolbar $self->{topwin} = Wx::SashWindow->new($self, -1, [0,0], Wx::Size->new(1000, 30), wxNO_BORDER ); $self->{topwin}->SetBackgroundColour(Wx::Colour->new(255, 0, 0)); # $self->{topwin}->SetSashVisible(wxSASH_BOTTOM, 1); # A blue window at the bottom like a statusbar $self->{bottomwin} = Wx::SashWindow->new($self, -1, [0,630], Wx::Size->new(1000, 30),wxNO_BORDER); $self->{bottomwin}->SetBackgroundColour(Wx::Colour->new(0, 0, 255)); # $self->{bottomwin}->SetSashVisible(wxSASH_TOP, 1); # A green window to the left of the client window $self->{leftwin1} = Wx::SashWindow->new($self, -1, [0,30], Wx::Size->new(120, 300),wxNO_BORDER); $self->{leftwin1}->SetBackgroundColour(Wx::Colour->new(0, 255, 0)); # $self->{leftwin1}->SetSashVisible(wxSASH_RIGHT, 1); $self->{text_window} = Wx::TextCtrl->new($self->{leftwin1}, -1, "", wxDefaultPosition,wxDefaultSize,wxSUNKEN_BORDER); $self->{text_window}->SetValue("A sub window"); # Another window to the left (turquoise) of the client window $self->{leftwin2} = Wx::SashWindow->new($self, -1, [0,330], Wx::Size->new(120, 300),wxNO_BORDER); $self->{leftwin2}->SetBackgroundColour(Wx::Colour->new(0, 255, 255)); # $self->{leftwin2}->SetSashVisible(wxSASH_RIGHT, 1); # White will occupy the space not used by the Layout Algorithm $self->{remaining_space} = Wx::Panel->new($self, -1, [120,30], Wx::Size->new(880, 600), wxSUNKEN_BORDER); $self->{remaining_space}->SetBackgroundColour(Wx::Colour->new(255, 255, 255)); # end wxGlade return $self; } 1; 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(); }
<<Blank Bkgrd.gif>>