From: David C. <dpc...@ho...> - 2008-02-21 05:30:31
|
perl-win32-gui-users: I'm a Win32::GUI newbie who went through the tutorials the other night: http://perl-win32-gui.sourceforge.net/cgi-bin/docs.cgi?doc=tutorial and was shocked to see: 1. No "use strict" nor "use warnings". 2. The scripts used global variables to pass around references to the windows, controls, etc.. 3. There were no sender or eventargs arguments. (Not even a $self arg?) RTFM, I don't see them either. Am I missing something? I was looking for an OO GUI toolkit in Perl. I intend to build an application that will feature pop-up forms for editing objects persisted in a database. My idea is to create a class and a table for each object type. The class includes a method to create and display a window for editing that type of object. When the user needs to create/ edit an object, I create an object, stuff it/ get it stuffed with data, and/or create/ display the editor window. The user may have many such windows open at the same time, including multiple windows from the same class. When the user interacts with the windows and controls, the event handlers need to be able to find the right object. Microsoft's "sender" argument solves this need nicely. Microsoft's "eventargs" argument solves other needs nicely. Does Win32::GUI have equivalents? TIA, David |
Re: [perl-win32-gui-users] tutorials use strict? use warnings?
globals? sender and eventargs? $self?
From: David C. <dpc...@ho...> - 2008-02-22 06:54:34
|
Glenn Linderman wrote: > #3. I've read bunches of Windows API documentation, and have never > found anything called "sender", "eventargs", or "self". You must be > reading stuff at some higher level of abstraction. http://search.cpan.org/~robertmay/Win32-GUI-1.06/docs/GUI/UserGuide/Read me.pod "Win32::GUI is a Win32-platform native graphical user interface toolkit for perl. Basically, it's an XS implementation of most of the functions found in user32.dll and gdi32.dll, with an object oriented perl interface and an event-based dialog model that mimic the functionality of visual basic." I was expecting something like Visual Basic (although I prefer C#): http://msdn2.microsoft.com/en-us/library/system.windows.forms.control.cl ick(VS.71).aspx jez_whit wrote: > To do this have a look at the UserData method. It allows you to > associate data to a window. When you use NEM events the first parm is > the object that the event fired on. Say for example you have a button > on a form, and you have many instances of that form your even handler > would look like: > My $self=shift; #the button object > My $parent = $self->parent; #the parent window > My $object = $parent->UserData; #the instance data for the window I guessed at a solution like that, but didn't see $self in the documentation for Button_Click(): http://perl-win32-gui.sourceforge.net/cgi-bin/docs.cgi?doc=button Where is this documented? David |
Re: [perl-win32-gui-users] tutorials use strict? use warnings?
globals? sender and eventargs? $self?
From: Robert M. <ro...@th...> - 2008-03-03 18:13:24
|
On 21/02/2008, David Christensen <dpc...@ho...> wrote: > perl-win32-gui-users: > > I'm a Win32::GUI newbie who went through the tutorials the other night: > > http://perl-win32-gui.sourceforge.net/cgi-bin/docs.cgi?doc=tutorial > > and was shocked to see: > > 1. No "use strict" nor "use warnings". If you look at the tutorial demo code distributed with Win32::GUI (run win32-gui-demos from a cmd prompt) you'll see that it is all strict and warnings safe. There is a line to be drawn somewhere with respect to clarity of the documentation and 'correctness'. We'll never satify everyone with the style used, and so I have tried to err on the side of keeping the task at hand clear. This is not supposed to be a tutorial in good perl coding style, but a tutorial showing the Win32::GUI concepts. Patches are always welcome if you think you can make things clearer. > 2. The scripts used global variables to pass around references to the > windows, controls, etc.. Again, this is one possible style. Possibly not a good one, but it makes it very clear what is being done. I didn't write the tutorials, but have inherited their maintainance based on the lack of anyone else willing to do it. Again, patches welcome. > 3. There were no sender or eventargs arguments. Before this email I wasn't even aware what these things were. Remember this is Perl, not some MS language, so you shouldn't expect the idioms to be the same. There is more than enough support within Win32::GUI to provide an interface like this if you'd like to invest the time in creating all the necessary objects, but there will be a speed and memory hit from doing so (although it's probably not very significant). I think, more importantly, the procedural interface with the parameters decoded is more familiar to perl programmers. > (Not even a $self arg?) RTFM, I don't see them either. You probably want to read about the differences between the OEM and NEM event models (although there's not much in the docs, the samples provide quite a lot of material, as does searching the list archives). > Am I missing something? I was looking for an OO GUI toolkit in Perl. I > intend to build an application that will feature pop-up forms for > editing objects persisted in a database. My idea is to create a class > and a table for each object type. The class includes a method to create > and display a window for editing that type of object. When the user > needs to create/ edit an object, I create an object, stuff it/ get it > stuffed with data, and/or create/ display the editor window. The user > may have many such windows open at the same time, including multiple > windows from the same class. When the user interacts with the windows > and controls, the event handlers need to be able to find the right > object. Microsoft's "sender" argument solves this need nicely. > Microsoft's "eventargs" argument solves other needs nicely. Does > Win32::GUI have equivalents? Yes, it does. If the other replies have not helped you find the right direction, then please post back and we'll see what we can do to help you - there's nothing very hard if you're familiar with perl (and, in some cases, the Win32 API). Regards, Rob. > > > TIA, > > David > > > ------------------------------------------------------------------------- > This SF.net email is sponsored by: Microsoft > Defy all challenges. Microsoft(R) Visual Studio 2008. > http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/ > _______________________________________________ > Perl-Win32-GUI-Users mailing list > Per...@li... > https://lists.sourceforge.net/lists/listinfo/perl-win32-gui-users > http://perl-win32-gui.sourceforge.net/ > -- Please update your address book with my new email address: ro...@th... |