Re: Another FruitBasket with Wx

  • From: "Octavian Rasnita" <orasnita@xxxxxxxxx>
  • To: <programmingblind@xxxxxxxxxxxxx>
  • Date: Mon, 19 Nov 2007 23:38:27 +0200

Well, I've just deleted a few hours ago. I uploaded again.
It is at:

http://www.tranzactiibursiere.ro/static/FruitBasketWx.rar

In the script I've just added the OnClose subroutine that I included below, and its event handler, but with or without it it works the same.

I've done this because I've seen that the executable leaves some temporary dll files in the temp directory after the app is close, but this was not a solution for the problem as somebody on the WxPerl mailing list recommended. It seems that it is a known bug in a WxPerl module that will be fixed.

Perlapp includes more dll files than needed in the executable, so I removed 10 files from 14 and the result executable is smaller now.

Packaging with PDK (perlapp) is now a little bit trickyer because it requires using the wxpdk command, however I can say that it is more simple when needing to provide more parameters in the command line.

That OnClose subroutine is:

sub OnClose {
my ($self, $event) = @_;
$self->Destroy();
Wx::wxTheApp->ExitMainLoop();
}

Octavian

----- Original Message ----- From: "Jamal Mazrui" <empower@xxxxxxxxx>
To: <programmingblind@xxxxxxxxxxxxx>
Sent: Monday, November 19, 2007 11:04 PM
Subject: Re: Another FruitBasket with Wx


Hi Octavian,
I just tried downloading the .rar file you posted but am getting a page
not found error.
Jamal
On Sat, 17 Nov 2007, Octavian Rasnita wrote:

Date: Sat, 17 Nov 2007 21:56:28 +0200
From: Octavian Rasnita <orasnita@xxxxxxxxx>
Reply-To: programmingblind@xxxxxxxxxxxxx
To: programmingblind@xxxxxxxxxxxxx
Subject: Another FruitBasket with Wx

Hi,

I've made another FruitBasket made with Wx in perl. I've seen that the
syntax of WxPerl is not so nice as the syntax of Win32::GUI, but I thought
that the source code should be smaller, because it doesn't use that
hash-style of providing parameters to functions.

Finally I've made a Fruit Basket with WxPerl that has only around 750
characters, and it is still pretty clear. The version below has 950
characters because it has some more spaces.

It might be helpful for those who want to learn WxPerl, especially that
there is so little documentation for WxPerl.
(I've created an executable program and I put it and the source code, and a
version with some explanations at:
http://www.tranzactiibursiere.ro/static/FruitBasket_Wx.rar

Here it is:

use strict;
use Wx qw(wxALIGN_RIGHT);
use Wx::Event qw(EVT_BUTTON);

my $frame = Wx::Frame->new(undef, -1, "The app", [-1,-1], [200,150]);

my $panel = Wx::Panel->new($frame, -1);

Wx::StaticText->new($panel, -1, "&Fruit:", [20,20], [30,20], wxALIGN_RIGHT);

my $fruit = Wx::TextCtrl->new($panel, -1, "", [50,20], [100,20]);

my $add = Wx::Button->new($panel, -1, "&Add", [150,20], [50,20]);

$add->SetDefault;

Wx::StaticText->new($panel, -1, "F&ruits:", [20,60], [30,20],
wxALIGN_RIGHT);

my $list = Wx::ListBox->new($panel, -1, [50,60], [100,100]);

my $del = Wx::Button->new($panel, -1, "&Delete", [150,60], [50,20]);

EVT_BUTTON($frame, $add, \&add);
EVT_BUTTON($frame, $del, \&del);

$frame->Show(1);
Wx::SimpleApp->new->MainLoop;

sub add {
my $current_fruit = $fruit->GetValue;

if (defined $current_fruit) {
$list->Append($current_fruit);
$fruit->Clear;
}
}

sub del {
my $index = $list->GetSelection;
$list->Delete($index) if $index >= 0;
}



Octavian

__________
View the list's information and change your settings at
//www.freelists.org/list/programmingblind

__________
View the list's information and change your settings at
//www.freelists.org/list/programmingblind


__________
View the list's information and change your settings at //www.freelists.org/list/programmingblind

Other related posts: