2/19/2023 0 Comments Perl tutorials![]() ![]() =18= my $frame = Wx::Frame->new( undef, # Parent window =15= # be called when the constructor is called. =14= # Every application has its own OnInit method that will =11= use base qw(Wx::App) # Inherit from Wx::App =7= # Define our HelloWorld class that extends Wx::App Examine this script: =1= #!/usr/bin/perl -w Like every tutorial, this tutorial has its own ``Hello World!” application to get started and create the first application. But after reading this first wxPerl tutorial you might become interested and find your own way into wxPerl. That takes quite a bit of effort, though. And if you try hard enough, then you can use that documentation for wxPerl. That is to say: wxWindows has lots of documentation. But unfortunately it lacks the named parameter approach Tk uses, which makes Tk look more Perlish.Ĭurrently, there is one big disadvantage to wxPerl: It is very poorly documented. This is a much more object-oriented approach than Tk and Gtk use. If you want to add controls to a window, you subclass a default windowclass and add the controls to it. If you want a default window, you use the default classes. This subclass has to have at least one method called OnInit which defines the windows (called ``Frames” in Wx-terms) the application uses. When you want to create a new wxPerl application you start creating a new class that inherits from Wx::App. The main reason for this is the source of the library, which is a C++ library. It’s not better or worse than the Tk or Gtk interfaces, but it’s a totally different approach. ![]() This is a particularly big difference from, for example, Tk, where it is a real pain to define new widgets. All needed controls are available ``off the shelf,” and if there is still a complex control you want to create yourself, then you can do so with little effort. This makes it a good GUI to create full-featured applications. ![]() WxPerl has a very rich set of standard widgets (called ``controls” in Wx-terms), ranging from simple buttons to complex HTML windows and Font dialogs. Also it has been around for a while so it has had the chance to become a stable product. It’s not a GUI that has been ported from a certain platform where it had its roots: wx stands for Windows and X – it has been designed to be cross-platform. wxWindows has been developed since 1992 with version 2 (the current version) being developed since 1997. When I say cross-platform, I indeed mean cross-platform: There is wxWindows for Windows, Gtk, Motif and Macintosh. wxPerl is the Perl binding for wxWindows ( ), which is a cross-platform GUI library for C++. No, not the unmaintained Qt and FWTK modules, but wxPerl, which is being developed by Mattia Barbon. Recently, I discovered another GUI for Perl. Of course, Tk looks more like Windows when you use it on a Win32 machine and looks more like Gtk when you run it under Gnome, but still it is a different interface. Tk has a motif-like interface, while Gnome users will want the Gtk look-and-feel, and Windows users will want the Windows look-and-feel. The main reason for this is probably that Tk does not have the slickest interface that exactly matches the environment that people use. However, more and more people are using other GUIs, such as Gtk and Win32::GUI. It’s certainly the most stable, best documented and widest used GUI that’s available for Perl. You might use the Curses library, but if you want a nice GUI, you will probably use Tk. If you don’t just use Perl for creating CGI scripts, you’ll probably have to create some kind of front-end for your applications sooner or later. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |