PERL TK - PowerPoint PPT Presentation

1 / 28
About This Presentation
Title:

PERL TK

Description:

mw- Button(-text = 'Button1')- pack(qw/-side top -pady 2 ... Button(-text = 'Button1')- pack(qw/-side ... mw- Button(-text = 'Button1')- place(qw/-x 1 -y 1 ... – PowerPoint PPT presentation

Number of Views:20
Avg rating:3.0/5.0
Slides: 29
Provided by: Lea79
Category:
Tags: perl | button1

less

Transcript and Presenter's Notes

Title: PERL TK


1
PERL TK
2
1.Learn the basics
2. Experiment.
3 . Use the documentation!
4.Use an IDE http//spectcl.sourceforge
.net/
3
Simple Window use Tk mwMainWindow-gtnew() Mai
nLoop
4
Widget Tour use Tk mwMainWindow-gtnew()
lmw-gtLabel(-text gt "this is a label")
l-gtpack() bmw-gtButton(-text gt "this is a
button") b-gtpack() tmw-gtText(-width gt
10,height gt 10) t-gtinsert(end,"this is a
text") t-gtpack() emw-gtEntry(width gt 0)
e-gtinsert(end,"this is an entry") e-gtpack()
imw-gtListbox(height gt 2)
i-gtinsert(end,"listbox element1")
i-gtinsert(end,"listbox element2")
i-gtselectionSet(1) i-gtpack() be
mw-gtBrowseEntry(-label gt "Label", -variable gt
\var) be-gtinsert("end", "opt1")
be-gtinsert("end", "opt2") be-gtinsert("end",
"opt3") be-gtpack() MainLoop
5
(No Transcript)
6

BUTTONS use Tk mwMainWindow-gtnew(
-name gt "Buttons", -title gt 'Button
Demonstration', ) lmw-gtLabel(-text gt "If
you click on any of the four buttons below, the
background of the button area will change to the
color indicated in the button. You can press Tab
to move among the buttons, then press Space to
invoke the current button.", -wraplength gt
"4i", -justify gt left) l-gtpack() foreach
my color (qw/PeachPuff1 LightBlue1 SeaGreen2
Yellow1/) my b mw-gtButton(
-text gt color, -width gt 10, -command gt
submw-gtconfigure(-background gt
lc(color)), ) b-gtpack(qw/-side
top -expand yes -pady 2/) MainLoop
7
(No Transcript)
8

LABELS use Tk
mwMainWindow-gtnew( -name gt "Label", -title gt
'Label', ) lmw-gtLabel(-text gt "Five labels
are displayed below three textual ones on the
left, and an image label and a text label on the
right. Labels are pretty boring because you
can\'t do anything with them.", -wraplength gt
"4i", -justify gt left) l-gtpack() my _at_pl
qw/-side left -expand yes -padx 10 -pady 10 -fill
both/ my left mw-gtFrame-gtpack(-side gt left,
-expand gt yes, -padx gt 10, -pady gt 10, -fill
gt both) my right mw-gtFrame-gtpack(_at_pl)
_at_pl qw/-side top -expand yes -pady 2 -anchor
w/ my left_l1 left-gtLabel(-text gt 'First
label')-gtpack(_at_pl) my left_l2 left-gtLabel(
-text gt 'Second label, raised just for fun',
-relief gt 'raised', )-gtpack(_at_pl) my left_l3
left-gtLabel( -text gt 'Third label, sunken',
-relief gt 'sunken', )-pack(_at_pl) _at_pl qw/-side
top/ my right_bitmap right-gtLabel( -image
gt mw-gtPhoto(-file gt Tk-gtfindINC('Xcamel.gif')),
-borderwidth gt 2, -relief gt 'sunken',
)-gtpack(_at_pl) my right_caption
right-gtLabel(-text gt 'Perl/Tk')-gtpack(_at_pl)
MainLoop
9
(No Transcript)
10

RADIOBUTTON use Tk sub click
mw-gtDialog(-title gt "Title", -buttons gt
"OK",text gt _0)-gtShow()
mwMainWindow-gtnew( -name gt "Radio", -title gt
'Radio', ) v2 bmw-gtRadiobutton(-command
gt \click ,"The Radio 1 clicked,\v),-variabl
e gt \v,-value gt 1) b1mw-gtRadiobutton(-comm
and gt \click("The Radio 2 clicked",\v1),-vari
able gt \v,-value gt 2) b-gtpack()
b1-gtpack() MainLoop
11
(No Transcript)
12
Try to pack the "Button 10" at the left use Tk
mwMainWindow-gtnew() mw-gtButton(-text gt
"Button1")-gtpack(qw/-side top -pady 2/)
mw-gtButton(-text gt "Button2")-gtpack(qw/-side
top -pady 2/) mw-gtButton(-text gt
"Button3")-gtpack(qw/-side top -pady 2/)
mw-gtButton(-text gt "Button4")-gtpack(qw/-side
top -pady 2/) mw-gtButton(-text gt "Button
10")-gtpack(qw/-side left -expand yes -pady 2/)
MainLoop
13
(No Transcript)
14
use Tk mwMainWindow-gtnew()
mw-gtButton(-text gt "Button 10")-gtpack(qw/-side
left -pady 2/) mw-gtButton(-text gt
"Button1")-gtpack(qw/-side top -pady 2/)
mw-gtButton(-text gt "Button2")-gtpack(qw/-side
top -pady 2/) mw-gtButton(-text gt
"Button3")-gtpack(qw/-side top -pady 2/)
mw-gtButton(-text gt "Button4")-gtpack(qw/-side
top -pady 2/) MainLoop
15
(No Transcript)
16
Make it to take all the extra space use Tk
mwMainWindow-gtnew() mw-gtButton(-text gt
"Button 10", -height gt 8 )-gtpack(qw/-side left
-expand yes -pady 2/) mw-gtButton(-text gt
"Button1")-gtpack(qw/-side top -expand yes -pady
2/) mw-gtButton(-text gt "Button2")-gtpack(qw/-si
de top -expand yes -pady 2/) mw-gtButton(-text
gt "Button3")-gtpack(qw/-side top -expand yes
-pady 2/) mw-gtButton(-text gt
"Button4")-gtpack(qw/-side top -expand yes -pady
2/) MainLoop
17
(No Transcript)
18
use Tk mwMainWindow-gtnew()
mw-gtButton(-text gt "Button 10", -height gt 8
)-gtpack(qw/-side left -expand yes -pady 2 fill
y/) mw-gtButton(-text gt "Button1")-gtpack(qw/-si
de top -expand yes -pady 2/) mw-gtButton(-text
gt "Button2")-gtpack(qw/-side top -expand yes
-pady 2/) mw-gtButton(-text gt
"Button3")-gtpack(qw/-side top -expand yes -pady
2/) mw-gtButton(-text gt "Button4")-gtpack(qw/-si
de top -expand yes -pady 2/) MainLoop
19
(No Transcript)
20
Make the "Button 1" and "Button 2" to be at the
left ,one under another use Tk
mwMainWindow-gtnew() mw-gtButton(-text gt
"Button 10", -height gt 8 )-gtpack(qw/-side left
-expand yes -pady 2 -fill y/) mw-gtButton(-text
gt "Button 20", -height gt 8 )-gtpack(qw/-side
left -expand yes -pady 2 -fill y/)
mw-gtButton(-text gt "Button1")-gtpack(qw/-side
top -expand yes -pady 2/) mw-gtButton(-text gt
"Button2")-gtpack(qw/-side top -expand yes -pady
2/) mw-gtButton(-text gt "Button3")-gtpack(qw/-sid
e top -expand yes -pady 2/) mw-gtButton(-text gt
"Button4")-gtpack(qw/-side top -expand yes -pady
2/) MainLoop
21
(No Transcript)
22
Use Frames! use Tk mwMainWindow-gtnew()
f1mw-gtFrame() f2mw-gtFrame()
f1-gtButton(-text gt "Button 10")-gtpack(qw/-side
top -expand yes -pady 2 -fill y/)
f1-gtButton(-text gt "Button 20")-gtpack(qw/-side
top -expand yes -pady 2 -fill y/)
f2-gtButton(-text gt "Button1")-gtpack(qw/-side
top -expand yes -pady 2/) f2-gtButton(-text gt
"Button2")-gtpack(qw/-side top -expand yes -pady
2/) f2-gtButton(-text gt "Button3")-gtpack(qw/-si
de top -expand yes -pady 2/) f2-gtButton(-text
gt "Button4")-gtpack(qw/-side top -expand yes
-pady 2/) f1-gtpack(qw/-side left -expand yes
-pady 2 -fill y/) f2-gtpack(qw/-side left
-expand yes -pady 2 -fill y/) MainLoop
23
(No Transcript)
24
Placer use Tk mwMainWindow-gtnew()
mw-gtButton(-text gt "Button1")-gtplace(qw/-x 1 -y
1/) mw-gtButton(-text gt "Button2")-gtplace(qw/-x
1 -y 1/) MainLoop
25
(No Transcript)
26
use Tk mwMainWindow-gtnew()
mw-gtButton(-text gt "Button1")-gtplace(qw/-x 4
-y 4/) mw-gtButton(-text gt "Button2")-gtplace(qw
/-x 1 -y 1/) MainLoop
27
(No Transcript)
28
That is not all Open the real application in the
browser
Write a Comment
User Comments (0)
About PowerShow.com