On not repainting dialog boxes.

Hi People,

I just thought I'd post this thought.

I've variously been having problems with pieces of code if I run them 
too often (actually, it turned out that this was because I had created 
but not activated my swap file.  Who'd have guessed?). Anyway in the 
course of trying to track this down, I came up with the following piece 
of code, which I decided to circulate (maybe you all do it anyway).

First of all I create a global variable called $gl_dialog_base, then if 
I want to create a screen, say i_Booking, I use a derived function 
i_Booking -> new, which creates the dialog box and paints the controls.  
Then I populates the controls with data (setInitialDataState).

I update the global variable and the next time round I just populate the 
data.

Like this:

     if (not $gl_dialog_base{bookingNew}){
         $dlg_booking= i_Booking -> new ($i_frame, wxID_ANY, wxID_ADD, 
wxDefaultPosition,[$gl_cfg->{monitor_resolution_x}, 
$gl_cfg->{monitor_resolution_y}],  wxNO_BORDER, "" );
         $dlg_booking->setInitialDataState(wxID_ADD);
         $gl_dialog_base{bookingNew} = {
                         instantiated => 1,
                         dialog_pointer => $dlg_booking,
                           };
     } else {
         $dlg_booking= $gl_dialog_base{bookingNew}{dialog_pointer};
         $dlg_booking->setInitialDataState(wxID_ADD);
     }

It's more efficient, much quicker, uses less memory and crashes less 
frequently (if you haven't activated your swap file).

If anyone else has any ideas for efficiency, I'd love to hear.

Have fun,

Regards,

Steve.
0
steve
9/10/2015 11:39:11 AM
perl.wxperl.users 3070 articles. 0 followers. Follow

0 Replies
275 Views

Similar Articles

[PageSpeed] 51

Reply:

Similar Artilces:

[wxperl-users] Help in understanding wxPerl and non-modal dialog boxes
Greetings. I am at wit's end here. This message is similar to one I sent to wx-users earlier today. From more testing, I am suspecting that my problem is in a misunderstand of some wxPerl-specific idiom. If anyone here can suggest a fix, I would be most appreciative. I have hand-crafted a non-modal dialog (derived from Wx::Dialog) to show the user the progress of a process. It has a StaticText, a Gauge, and a button for stopping the operation. The program changes the value of the StaticText and updates the position on the Gauge, and that works just fine. What is perplexing me ...

Re: [wxperl-users] Help in understanding wxPerl and non-modal dialog boxes
> Yes, simplifying always helps. In this case, it helped me get all the > way down to the base problem, which may not be part of wxPerl at all > (but it might be, due to the slightly different way that events are > handled). It is a common problem; it will happen in C++, too. > Note that the "sleep 5" comes after the $AppFrame->Show(1). What I am > unclear about is why the frame isn't up and responsive after the Show. Because the frame will be responsive after you enter the main loop ($app->MainLoop); a modal dialog works because modal ...

Re:[wxperl-users] Help in understanding wxPerl and non-modal dialog boxes
Hello, > Greetings. I am at wit's end here. This message is similar to one I > sent to wx-users earlier today. From more testing, I am suspecting > that my problem is in a misunderstand of some wxPerl-specific idiom. > If anyone here can suggest a fix, I would be most appreciative. I doubt your problem is wxPerl-specific; I think an equivalent C++ program would show the same problem. The symptoms you describe do not ring any bell, but if you could send a minimal example (and your wxPerl/wxWidgets/OS versions) I will have a look at it (eventually...). Reg...

[wxperl-users] Dialog Box Rendering problem
This is a multi-part message in MIME format. ------_=_NextPart_001_01C52421.5C00F840 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable =20 Hi I'm trying to use the Wx::Dialog boxes, using ShowModal, and all I'm getting is about 7/8th's of the title bar and that's it see=20 =20 http://img219.exs.cx/img219/7517/screenshot5gp.png =20 Now I can use show but show is async vs. showModal which is sync and I need the later, has anyone seen this bug before? =20 Dialog Package Code=20 ----- =20 pa...

[wxperl-users] Making a TextCtrl fit a dialog box
This is a multi-part message in MIME format. ------=_NextPart_000_0073_01C5D8BE.0036BBA0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Hello all, I'm trying to do the above. No other controls required. Just = plain old textctrl. My code is as follows: my $dlg =3D Wx::Dialog->new($self,-1,'title',[-1,-1],[400,300]); =20 my $TextBox =3D Wx::TextCtrl->new($dlg,-1, 'xxx',wxDefaultPosition, wxDefaultSize, wxTE_READONLY|wxTE_MULTILINE); $dlg->ShowModal; Unfortunately the text ctrl does...

[wxperl-users] Re: Dialog Box Rendering problem
I haven't counted the pixels, but could it be that the size you specify, [240,21] is exactly what you get? -- Johan I just did count the pixels and you are absolutely right ! Good call... ----- Original Message ----- From: "Johan Vromans" <jvromans@squirrel.nl> To: <wxperl-users@lists.sourceforge.net> Sent: Friday, March 11, 2005 9:30 AM Subject: [wxperl-users] Re: Dialog Box Rendering problem > I haven't counted the pixels, but could it be that the size you > specify, [240,21] is exactly what you get? > > -- Johan > >...

[wxperl-users] Question about WxPerl, Dialogs, ShowModal
This is a multi-part message in MIME format. ------_=_NextPart_001_01C54142.27EA8D10 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable I'm curious if any of you have seen the same problem as I =20 When I make a Wx Frame and call a Wx Dialog with ShowModal, everything interacts correctly. However when I go to end the program It destroys the main frame like it's supposed to, the application doesn't end, it just sits there waiting for your to hit ctrl+c to kill it. I have tested this under Linux and win32 and see t...

[wxperl-users] Using wxPerl for Login-Dialog
The recent wxPerl articles on www.perl.com left me curious, so I decided = to have a closer look. The result is the code below a simple Login dialog (two = text entry fields, two text labels & two buttons) that I cobbled together = from samples in the mailinglist and sourceforge's samples archive..=20 Writing the code proved fairly easy, despite a nagging feeling that I = don't realy understand what's going on... but I ended up with two problems I = can't seem to solve: 1.I can't seem to find a sample for a (blind) textentry,=20 that doesn't show...

RE: [wxperl-users] Question about WxPerl, Dialogs, ShowModal
Ok Because the way I understood ShowModal was that you used ShowModal to start it and then EndModal to end it and pass back the return code, I'll add the destroy next and see what happends. Thanks Scott Forbis Intel Corporation -----Original Message----- From: Huub Peters [mailto:huub@trendesign.nl]=20 Sent: Thursday, April 14, 2005 11:59 PM To: Forbis, ScottX; wxperl-users@lists.sourceforge.net Subject: Re: [wxperl-users] Question about WxPerl, Dialogs, ShowModal On Friday, April 15, 2005 12:34 AM, ScottX Forbis Wrote > When I make a Wx Frame and call a Wx Dialo...

Re:[wxperl-users] Question about WxPerl, Dialogs, ShowModal
Hello, > I'm curious if any of you have seen the same problem as I=0D = I can't remember... > When I make a Wx Frame and call a Wx Dialog = with ShowModal, everything > interacts correctly. However when I go to = end the program It destroys > the main frame like it's supposed to, the = application doesn't end, it > just sits there waiting for your to hit ct= rl+c to kill it. I have > tested this under Linux and win32 and see the= same result. I'm curious > if anyone has seen this before, found a way= around it, or if it'...

[wxperl-users] [ wxperl-Bugs-1723667 ] DirDialog under GTK produces wrong dialog
Bugs item #1723667, was opened at 2007-05-22 10:40 Message generated for change (Tracker Item Submitted) made by Item Submitter You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=115655&aid=1723667&group_id=15655 Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: None Group: None Status: Open Resolution: None Priority: 5 Private: No Submitted By: Nobody/Anonymous (nobody) Assigned to: Nobody/Anonymous (nobody) Summa...

Fileopen dialog box + folder open dialog box
Hi everybodycan some one post a reply that how to use file open dialog box  and folder open dialog box  same like windows forms using asp.net 2.0  ?many thanksregardssuis  First tell waht you want to do ? by showing that Thanks & Regards Sandeep If you want something you never had, do something you have never done!  Hi,Actually i have a list box in my web application and i have a file select and directory button in my web form,when user clicks on a file select button it  should shows file open dialog button and select what ever the file he need to add t...

[wxperl-users] dialogs segfaulting
I find that on Debian with perl 5.8.1 and WxWindows GTK 2.4 installed with apt-get package manager, and Wx.pm installed with CPAN, that 1) the example in the 'samples' directory dialog/dialog.pl segfaults after the program exits, 2) the example dialogs/dialogs.pl segfaults even when it starts up. I believe it has something to do with $dialog->Destroy() as I had the same problem in my own application. If I don't call Destroy, the main app window will remain open after existing, so that doesn't work (also it probably uses more memory). On Fri, 31 Oct 2003 lannin...

[wxperl-users] Dialog only window
How do you create a dialog-only application in wxPerl? I know there's a C++ example, but I'm not sure how to translate it to Perl. Thanks, Marcus Check out the dialog.pl script in the samples distro. In case you don't have that (yet) I'll paste it here: #!/usr/bin/perl ############################################################################ # ## Name: dialog.pl ## Purpose: Dialog wxPerl sample ## Author: Mattia Barbon ## Modified by: ## Created: 12/11/2000 ## RCS-ID: ## Copyright: (c) 2000 Mattia Barbon ## Licence: Thi...

Web resources about - On not repainting dialog boxes. - perl.wxperl.users

Photos: Repainting Mission Library
Volunteers from TEP help repaint the Mission Branch Library

Town official criminally charged for repainting faded crosswalks
George Simolaris, a selectman in Billerica, Massachusetts, is in trouble with the law for repainting six faded crosswalks in his town.

Hard-up RAF flies second-hand jets in US air force colours to save £3million cost of repainting them ...
Instead of the RAF's uniform light grey, the three RC-135 Rivet Joint aircraft will keep their design of a white top, black nose and grey underside ...

Photos: Repainting Mission Library
Volunteers from TEP help repaint the Mission Branch Library

Resources last updated: 12/2/2015 2:18:43 PM