I was looking to create a multi-panel fixed form in wxPerl, however I'm not sure that I chose the right path anymore. I used wxSashWindow with fixed positions and sizes, but I feel that using this defeats the point of sizers in widgets. I wonder whether I should just have used a GridBagSizer with embedded panels.

I borrowed it from and mutilated a wxSashWindow example in Python which relies heavily on wxSashLayoutWindow, (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.

Anyway here it is, judge for yourselves. Is it salvageable? Any opinions gratefully received.

#!/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->n +ew(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::S +ize->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::Siz +e->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::Si +ze->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}, w +xID_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_REA +DONLY); $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(); }

In reply to Using wxSashWindow by Steve_BZ

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.