Hi Johan,

Yes it's true I don't change it when I have a simple form.

But most of my forms are more complicated so I have to create them 
programmatically.  Eg I have a form with a wxNotebook with a variable
number of tabs.  I have to create the tabs dynamically in a loop, so
it is easier to set the properties and add them to the sizer all
at the same time.  So I have a sub-routine to do it, (see below). In
This routine, you should ignore the $i parameter.
I am gradually creating little routines like this for all my control 
types.

Regards

Steve

sub __new_TextCtrl{

# sets field properties, format:
# __new_TextCtrl(\$loc_self_ptr, $loc_enabled, $loc_max_length,
$loc_minsize_x, $loc_minsize_y, $loc_validation_string, $loc_tooltip,
\$loc_sizer_ptr, \$loc_panel_ptr, $loc_control_value);
        
        my $loc_self_ptr=shift;                 # pointer to control (Pass
by reference)
        my $loc_enabled=shift;                  #Enabled or disabled
        my $loc_max_length=shift;               # Hold maximum number of
characters the control will accept before beeping.
        my $loc_minsize_x=shift;                # Holds minimum size of
control (x-axis)
        my $loc_minsize_y=shift;                # Holds minimum size of
control (y-axis)
        my $loc_validation_string=shift;        # Holds validation string
        my $loc_tooltip=shift;                  # Holds tooltip already
translated.
        my $loc_sizer_ptr=shift;                # pointer to sizer (Pass by
reference)
        my $loc_panel_ptr=shift;                # pointer to panel (Pass by
reference)
        my $loc_control_value=shift;            # Holds default value of
control
        
        #       Use wxTE_READONLY instead of Enabled/Disabled
        if ($loc_enabled=0){
            $$loc_self_ptr = Wx::TextCtrl->
                    new($$loc_panel_ptr, wxID_ANY,
__trim($loc_control_value), wxDefaultPosition, wxDefaultSize,
wxTE_READONLY); 
        } else {
            $$loc_self_ptr = Wx::TextCtrl->
                    new($$loc_panel_ptr, wxID_ANY,
__trim($loc_control_value), wxDefaultPosition, wxDefaultSize, );        
            
        }
        
        if ($loc_max_length ne "")
{$$loc_self_ptr->SetMaxLength($loc_max_length)};        #Set maximum length
of text control
        if ($loc_minsize_x ne "") {
# Set minimum physical size of field in pixels
                $$loc_self_ptr->SetMinSize(Wx::Size->new($loc_minsize_x,
$loc_minsize_y))
                };
        if ($loc_tooltip ne "")
{$$loc_self_ptr->SetToolTipString($loc_tooltip)};       #Set tooltip
        if ($loc_validation_string ne "") {
            my $loc_numval = Wx::Perl::TextValidator->new(
$loc_validation_string );       # Set validation string
            $$loc_self_ptr->SetValidator( $loc_numval );
# Set validation
        }       
        $$loc_sizer_ptr->Add($$loc_self_ptr, 0, 0, 0);
# Add to grid
}

-----Original Message-----
From: Johan Vromans [mailto:jvrom...@squirrel.nl] 
Sent: 14 August 2009 09:27
To: wxperl-users@perl.org
Subject: Re: wxGlade Generated Code

"Steve Cookson" <steve.cook...@sca-uk.com> writes:

> However on the Glade code, while I wrote my whole prototype In
> Glade, and I wouldn't have progressed as fast as I have without it,
> I don't like its programmatic structure. [...] This makes the code
> much more maintainable.

I think there's a misunderstanding here. wxGlade is not a prototype
generator, it's an UI designer/generator. The idea is to leave the
maintainance of the wxGlade generated code to wxGlade.

Personally I find wxGlade's programmatic structure okay to work with.

-- Johan

Reply via email to