WX Perl - Hello. Comments

xiaoxiao2021-03-06  35

Below is one of WXPERL's example, which can be opened from it (I have some changes) #! / Usr / bin / perl

######################################################################################################################################################################################################################################################################################################## ##########################################

## Name: Samples / Hello / Hello.pl

## purpose: Hello wxperl sample

## Author: Mattia Barbon

## Modified by:

## Created: 02/11/2000

## rcs-id: $ ID: Hello.pl, V 1.3 2004/10/19 20:28:14 Mbarbon Exp $

## Copyright: (C) 2000 Mattia Barbon

## lence: this program is free software; you can redistribute it and / or

## Modify It Under The Same Terms As Perl Itself

######################################################################################################################################################################################################################################################################################################## ##########################################

Use strict;

Use wx; # import wx

Package myapp; # Each WXPERL program has a class inheritance wx :: app

Use base QW (wx :: app);

# OnNit Inherited from WX :: App, this method will automatically run when you are created.

Sub oninit {

MY ($ this) = shift;

# Create a new frame and set to top (top?) FRAME

MY ($ frame) = myframe-> new ();

$ this-> settopwindow ($ frame);

# Show this frame

$ FRAME-> Show (1);

} # Below define this frame

Package myframe;

# uSE VARS QW (@ISA);

# @isa = qw (wx :: frame);

Use base qw (wx :: frame);

Use wx :: Event QW (EVT_PAINT);

# this imports some constants

Use wx qw (wxdecoative wxnormal wxbold);

Use wx qw (wxdefaultposition);

USE WX QW (WXWHITE);

Sub new {

# New frame with no pient, id -1, title 'hello, world!'

# Default position and size 350, 100

My ($ this) = shift-> super :: new (undef, -1, 'hello, world! ",

WxDefaultPosition, [350, 100]);

# create a new font Object and store it

$ this -> {font} = wx :: font-> new (40, wxdecoative, wxnormal, wxbold, 0);

# set background colour

$ this-> setbackgroundcolour (wxwhite);

$ this-> seticon (wx :: getwxperlicon ()); # declare what all Paint Events Will Be Handled with the onpaint mix

EVT_PAINT ($ this, / & onpaint);

Return $ THIS;

}

Sub onpaint {

MY ($ this, $ Event) = @_;

# Create a Device Context (DC) Used for Drawing

MY ($ DC) = wx :: PainTDC-> New ($ this);

# SELECT The FONT

$ DC-> setFont ($ this-> font);

# darw a friendly message

$ DC-> DrawText ('Hello, World!', 10, 10);

}

Sub font {

$ _ [0] -> {font};

} # Home Program Create a MyApp object

Package main;

# create an instance of the wx :: app-derived class

MY ($ app) = myapp-> new ();

# Start processing events

$ app-> mainloop;

转载请注明原文地址:https://www.9cbs.com/read-62968.html

New Post(0)